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