Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Panes.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     /// <summary>
22     /// The Panes is a widget that adds a draggable bar between two contents.
23     /// When dragged this bar resizes contents' size.
24     /// </summary>
25     public class Panes : Layout
26     {
27         SmartEvent _press;
28         SmartEvent _unpressed;
29
30         /// <summary>
31         /// Creates and initializes a new instance of the Panes class.
32         /// </summary>
33         /// <param name="parent">The EvasObject to which the new Panes will be attached as a child.</param>
34         public Panes(EvasObject parent) : base(parent)
35         {
36             _press = new SmartEvent(this, this.RealHandle, "press");
37             _unpressed = new SmartEvent(this, this.RealHandle, "unpress");
38
39             _press.On += (s, e) => Pressed?.Invoke(this, e);
40             _unpressed.On += (s, e) => Unpressed?.Invoke(this, e);
41         }
42
43         /// <summary>
44         /// Pressed will be triggered when panes have been pressed (button isn't released yet).
45         /// </summary>
46         public event EventHandler Pressed;
47
48         /// <summary>
49         /// Unpressed will be triggered when panes are released after being pressed.
50         /// </summary>
51         public event EventHandler Unpressed;
52
53         /// <summary>
54         /// Sets or gets resize mode of a given Panes widget.
55         /// True means the left and right panes resize homogeneously.
56         /// </summary>
57         public bool IsFixed
58         {
59             get
60             {
61                 return Interop.Elementary.elm_panes_fixed_get(RealHandle);
62             }
63             set
64             {
65                 Interop.Elementary.elm_panes_fixed_set(RealHandle, value);
66             }
67         }
68
69         /// <summary>
70         /// Sets or Gets the size proportion of the Panes widget's left side.
71         /// </summary>
72         /// <remarks>
73         /// By default it's homogeneous, i.e., both sides have the same size.If something different is required,
74         /// it can be set with this function. For example, if the left content should be displayed over 75% of the panes size,
75         /// size should be passed as 0.75. This way, the right content is resized to 25% of the panes size.
76         /// If displayed vertically, left content is displayed at the top, and right content at the bottom.
77         /// This proportion changes when the user drags the panes bar.
78         ///
79         /// The value is float type and between 0.0 and 1.0 representing the size proportion of the left side.
80         /// </remarks>
81         public double Proportion
82         {
83             get
84             {
85                 return Interop.Elementary.elm_panes_content_left_size_get(RealHandle);
86             }
87             set
88             {
89                 Interop.Elementary.elm_panes_content_left_size_set(RealHandle, value);
90             }
91         }
92
93         /// <summary>
94         /// Sets or gets the orientation of a given Panes widget.
95         /// </summary>
96         /// <remarks>
97         /// Uses this function to change how your panes are to be disposed: vertically or horizontally.
98         /// By default it's displayed horizontally.
99         /// </remarks>
100         public bool IsHorizontal
101         {
102             get
103             {
104                 return Interop.Elementary.elm_panes_horizontal_get(RealHandle);
105             }
106             set
107             {
108                 Interop.Elementary.elm_panes_horizontal_set(RealHandle, value);
109             }
110         }
111
112         /// <summary>
113         /// Sets or gets the absolute minimum size of panes widget's left side.
114         /// If displayed vertically, left content is displayed at top.
115         /// value representing minimum size of left side in pixels.
116         /// </summary>
117         public int LeftMinimumSize
118         {
119             get
120             {
121                 return Interop.Elementary.elm_panes_content_left_min_size_get(RealHandle);
122             }
123             set
124             {
125                 Interop.Elementary.elm_panes_content_left_min_size_set(RealHandle, value);
126             }
127         }
128
129         /// <summary>
130         /// Sets or gets the relative minimum size of panes widget's left side.
131         /// proportion of minimum size of left side.
132         /// If displayed vertically, left content is displayed at top.
133         /// value between 0.0 and 1.0 representing size proportion of minimum size of left side.
134         /// </summary>
135         public double LeftMinimumRelativeSize
136         {
137             get
138             {
139                 return Interop.Elementary.elm_panes_content_left_min_relative_size_get(RealHandle);
140             }
141             set
142             {
143                 Interop.Elementary.elm_panes_content_left_min_relative_size_set(RealHandle, value);
144             }
145         }
146
147         /// <summary>
148         /// Sets or gets the absolute minimum size of panes widget's right side.
149         /// If displayed vertically, right content is displayed at top.
150         /// value representing minimum size of right side in pixels.
151         /// </summary>
152         public int RightMinimumSize
153         {
154             get
155             {
156                 return Interop.Elementary.elm_panes_content_right_min_size_get(RealHandle);
157             }
158             set
159             {
160                 Interop.Elementary.elm_panes_content_right_min_size_set(RealHandle, value);
161             }
162         }
163
164         /// <summary>
165         /// Sets or gets the relative minimum size of panes widget's right side.
166         /// proportion of minimum size of right side.
167         /// If displayed vertically, right content is displayed at top.
168         /// value between 0.0 and 1.0 representing size proportion of minimum size of right side.
169         /// </summary>
170         public double RightMinimumRelativeSize
171         {
172             get
173             {
174                 return Interop.Elementary.elm_panes_content_right_min_relative_size_get(RealHandle);
175             }
176             set
177             {
178                 Interop.Elementary.elm_panes_content_right_min_relative_size_set(RealHandle, value);
179             }
180         }
181
182         protected override IntPtr CreateHandle(EvasObject parent)
183         {
184             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
185             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
186
187             RealHandle = Interop.Elementary.elm_panes_add(handle);
188             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
189
190             return handle;
191         }
192     }
193 }