sync ElmSharp source code latest
[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         /// Use this function to change how your panes is to be disposed: vertically or horizontally.
98         /// Horizontal panes have "top" and "bottom" contents, vertical panes have "left" and "right" contents.
99         /// By default panes is in a vertical mode.
100         /// </remarks>
101         public bool IsHorizontal
102         {
103             get
104             {
105                 return Interop.Elementary.elm_panes_horizontal_get(RealHandle);
106             }
107             set
108             {
109                 Interop.Elementary.elm_panes_horizontal_set(RealHandle, value);
110             }
111         }
112
113         /// <summary>
114         /// Sets or gets the absolute minimum size of panes widget's left side.
115         /// If displayed vertically, left content is displayed at top.
116         /// value representing minimum size of left side in pixels.
117         /// </summary>
118         public int LeftMinimumSize
119         {
120             get
121             {
122                 return Interop.Elementary.elm_panes_content_left_min_size_get(RealHandle);
123             }
124             set
125             {
126                 Interop.Elementary.elm_panes_content_left_min_size_set(RealHandle, value);
127             }
128         }
129
130         /// <summary>
131         /// Sets or gets the relative minimum size of panes widget's left side.
132         /// proportion of minimum size of left side.
133         /// If displayed vertically, left content is displayed at top.
134         /// value between 0.0 and 1.0 representing size proportion of minimum size of left side.
135         /// </summary>
136         public double LeftMinimumRelativeSize
137         {
138             get
139             {
140                 return Interop.Elementary.elm_panes_content_left_min_relative_size_get(RealHandle);
141             }
142             set
143             {
144                 Interop.Elementary.elm_panes_content_left_min_relative_size_set(RealHandle, value);
145             }
146         }
147
148         /// <summary>
149         /// Sets or gets the absolute minimum size of panes widget's right side.
150         /// If displayed vertically, right content is displayed at top.
151         /// value representing minimum size of right side in pixels.
152         /// </summary>
153         public int RightMinimumSize
154         {
155             get
156             {
157                 return Interop.Elementary.elm_panes_content_right_min_size_get(RealHandle);
158             }
159             set
160             {
161                 Interop.Elementary.elm_panes_content_right_min_size_set(RealHandle, value);
162             }
163         }
164
165         /// <summary>
166         /// Sets or gets the relative minimum size of panes widget's right side.
167         /// proportion of minimum size of right side.
168         /// If displayed vertically, right content is displayed at top.
169         /// value between 0.0 and 1.0 representing size proportion of minimum size of right side.
170         /// </summary>
171         public double RightMinimumRelativeSize
172         {
173             get
174             {
175                 return Interop.Elementary.elm_panes_content_right_min_relative_size_get(RealHandle);
176             }
177             set
178             {
179                 Interop.Elementary.elm_panes_content_right_min_relative_size_set(RealHandle, value);
180             }
181         }
182
183         protected override IntPtr CreateHandle(EvasObject parent)
184         {
185             IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
186             Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
187
188             RealHandle = Interop.Elementary.elm_panes_add(handle);
189             Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
190
191             return handle;
192         }
193     }
194 }