Add Toggled event in Panel
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Panel.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace ElmSharp
8 {
9     public enum PanelDirection
10     {
11         /// <summary>
12         /// Top to bottom
13         /// </summary>
14         Top = 0,
15         /// <summary>
16         /// Bottom to top
17         /// </summary>
18         Bottom,
19         /// <summary>
20         /// Left to right
21         /// </summary>
22         Left,
23         /// <summary>
24         /// Right to left
25         /// </summary>
26         Right,
27     }
28
29     public class Panel : Layout
30     {
31         Interop.SmartEvent _toggled;
32         public Panel(EvasObject parent) : base(parent)
33         {
34             _toggled = new Interop.SmartEvent(this, Handle, "toggled");
35             _toggled.On += (s, e) => Toggled?.Invoke(this, EventArgs.Empty);
36         }
37
38         public bool IsOpen
39         {
40             get
41             {
42                 return !Interop.Elementary.elm_panel_hidden_get(Handle);
43             }
44             set
45             {
46                 Interop.Elementary.elm_panel_hidden_set(Handle, !value);
47             }
48         }
49
50         public PanelDirection Direction
51         {
52             get
53             {
54                 return (PanelDirection)Interop.Elementary.elm_panel_orient_get(Handle);
55             }
56             set
57             {
58                 Interop.Elementary.elm_panel_orient_set(Handle, (int)value);
59             }
60         }
61
62         public event EventHandler Toggled;
63
64         public void SetScrollable(bool enable)
65         {
66             Interop.Elementary.elm_panel_scrollable_set(Handle, enable);
67         }
68
69         public void SetScrollableArea(double ratio)
70         {
71             Interop.Elementary.elm_panel_scrollable_content_size_set(Handle, ratio);
72         }
73
74         public void Toggle()
75         {
76             Interop.Elementary.elm_panel_toggle(Handle);
77         }
78
79         protected override IntPtr CreateHandle(EvasObject parent)
80         {
81             return Interop.Elementary.elm_panel_add(parent);
82         }
83     }
84 }