c6aac69753803e283d47b2b277782edbf7d5d6c6
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Panel.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     public enum PanelDirection
22     {
23         /// <summary>
24         /// Top to bottom
25         /// </summary>
26         Top = 0,
27         /// <summary>
28         /// Bottom to top
29         /// </summary>
30         Bottom,
31         /// <summary>
32         /// Left to right
33         /// </summary>
34         Left,
35         /// <summary>
36         /// Right to left
37         /// </summary>
38         Right,
39     }
40
41     public class Panel : Layout
42     {
43         SmartEvent _toggled;
44         public Panel(EvasObject parent) : base(parent)
45         {
46             _toggled = new SmartEvent(this, this.RealHandle, "toggled");
47             _toggled.On += (s, e) => Toggled?.Invoke(this, EventArgs.Empty);
48         }
49
50         public bool IsOpen
51         {
52             get
53             {
54                 return !Interop.Elementary.elm_panel_hidden_get(RealHandle);
55             }
56             set
57             {
58                 Interop.Elementary.elm_panel_hidden_set(RealHandle, !value);
59             }
60         }
61
62         public PanelDirection Direction
63         {
64             get
65             {
66                 return (PanelDirection)Interop.Elementary.elm_panel_orient_get(RealHandle);
67             }
68             set
69             {
70                 Interop.Elementary.elm_panel_orient_set(RealHandle, (int)value);
71             }
72         }
73
74         public event EventHandler Toggled;
75
76         public void SetScrollable(bool enable)
77         {
78             Interop.Elementary.elm_panel_scrollable_set(RealHandle, enable);
79         }
80
81         public void SetScrollableArea(double ratio)
82         {
83             Interop.Elementary.elm_panel_scrollable_content_size_set(RealHandle, ratio);
84         }
85
86         public void Toggle()
87         {
88             Interop.Elementary.elm_panel_toggle(RealHandle);
89         }
90
91         protected override IntPtr CreateHandle(EvasObject parent)
92         {
93             IntPtr handle = Interop.Elementary.elm_layout_add(parent);
94             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
95
96             RealHandle = Interop.Elementary.elm_panel_add(handle);
97             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
98
99             return handle;
100         }
101     }
102 }