Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / FlexContainer.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
18 namespace Tizen.NUI.BaseComponents
19 {
20     /// <summary>
21     /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br />
22     /// It aims at providing a more efficient way to layout, align, and distribute space among items in the container, even when their size is unknown or dynamic.<br />
23     /// FlexContainer has the ability to alter the width and the height of its children (i.e., flex items) to fill the available space in the best possible way on different screen sizes.<br />
24     /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br />
25     /// </summary>
26     public class FlexContainer : View
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexContainer obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         /// <summary>
41         /// To make the FlexContainer instance be disposed.
42         /// </summary>
43         /// <since_tizen> 3 </since_tizen>
44         protected override void Dispose(DisposeTypes type)
45         {
46             if(disposed)
47             {
48                 return;
49             }
50
51             if(type == DisposeTypes.Explicit)
52             {
53                 //Called by User
54                 //Release your own managed resources here.
55                 //You should release all of your own disposable objects here.
56             }
57
58             //Release your own unmanaged resources here.
59             //You should not access any managed member here except static instance.
60             //because the execution order of Finalizes is non-deterministic.
61
62             if (swigCPtr.Handle != global::System.IntPtr.Zero)
63             {
64                 if (swigCMemOwn)
65                 {
66                     swigCMemOwn = false;
67                     NDalicPINVOKE.delete_FlexContainer(swigCPtr);
68                 }
69                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70             }
71
72             base.Dispose(type);
73         }
74
75
76         internal new class Property
77         {
78             internal static readonly int CONTENT_DIRECTION = NDalicPINVOKE.FlexContainer_Property_CONTENT_DIRECTION_get();
79             internal static readonly int FLEX_DIRECTION = NDalicPINVOKE.FlexContainer_Property_FLEX_DIRECTION_get();
80             internal static readonly int FLEX_WRAP = NDalicPINVOKE.FlexContainer_Property_FLEX_WRAP_get();
81             internal static readonly int JUSTIFY_CONTENT = NDalicPINVOKE.FlexContainer_Property_JUSTIFY_CONTENT_get();
82             internal static readonly int ALIGN_ITEMS = NDalicPINVOKE.FlexContainer_Property_ALIGN_ITEMS_get();
83             internal static readonly int ALIGN_CONTENT = NDalicPINVOKE.FlexContainer_Property_ALIGN_CONTENT_get();
84
85         }
86
87         /// <summary>
88         /// Enumeration for the instance of child properties belonging to the FlexContainer class.
89         /// </summary>
90         public class ChildProperty
91         {
92             internal static readonly int FLEX = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_get();
93             internal static readonly int ALIGN_SELF = NDalicPINVOKE.FlexContainer_ChildProperty_ALIGN_SELF_get();
94             internal static readonly int FLEX_MARGIN = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_MARGIN_get();
95         }
96
97         /// <summary>
98         /// Creates a FlexContainer handle.
99         /// Calling member functions with an uninitialized handle is not allowed.
100         /// </summary>
101         public FlexContainer() : this(NDalicPINVOKE.FlexContainer_New(), true)
102         {
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104
105         }
106
107         /// <summary>
108         /// Enumeration for the direction of the main axis in the flex container. This determines
109         /// the direction that flex items are laid out in the flex container.
110         /// </summary>
111         /// <since_tizen> 3 </since_tizen>
112         public enum FlexDirectionType
113         {
114             /// <summary>
115             /// The flexible items are displayed vertically as a column.
116             /// </summary>
117             /// <since_tizen> 3 </since_tizen>
118             Column,
119             /// <summary>
120             /// The flexible items are displayed vertically as a column, but in reverse order.
121             /// </summary>
122             /// <since_tizen> 3 </since_tizen>
123             ColumnReverse,
124             /// <summary>
125             /// The flexible items are displayed horizontally as a row.
126             /// </summary>
127             /// <since_tizen> 3 </since_tizen>
128             Row,
129             /// <summary>
130             /// The flexible items are displayed horizontally as a row.
131             /// </summary>
132             /// <since_tizen> 3 </since_tizen>
133             RowReverse
134         }
135
136         /// <summary>
137         /// Enumeration for the primary direction in which content is ordered in the flex container
138         /// and on which sides the ?�start??and ?�end??are.
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         public enum ContentDirectionType
142         {
143             /// <summary>
144             /// Inherits the same direction from the parent.
145             /// </summary>
146             /// <since_tizen> 3 </since_tizen>
147             Inherit,
148             /// <summary>
149             /// From left to right.
150             /// </summary>
151             /// <since_tizen> 3 </since_tizen>
152             LTR,
153             /// <summary>
154             /// From right to left.
155             /// </summary>
156             /// <since_tizen> 3 </since_tizen>
157             RTL
158         }
159
160         /// <summary>
161         /// Enumeration for the alignment of the flex items when the items do not use all available
162         /// space on the main axis.
163         /// </summary>
164         /// <since_tizen> 3 </since_tizen>
165         public enum Justification
166         {
167             /// <summary>
168             /// Items are positioned at the beginning of the container.
169             /// </summary>
170             /// <since_tizen> 3 </since_tizen>
171             JustifyFlexStart,
172             /// <summary>
173             /// Items are positioned at the center of the container.
174             /// </summary>
175             /// <since_tizen> 3 </since_tizen>
176             JustifyCenter,
177             /// <summary>
178             /// Items are positioned at the end of the container.
179             /// </summary>
180             /// <since_tizen> 3 </since_tizen>
181             JustifyFlexEnd,
182             /// <summary>
183             /// Items are positioned with equal space between the lines.
184             /// </summary>
185             /// <since_tizen> 3 </since_tizen>
186             JustifySpaceBetween,
187             /// <summary>
188             /// Items are positioned with equal space before, between, and after the lines.
189             /// </summary>
190             /// <since_tizen> 3 </since_tizen>
191             JustifySpaceAround
192         }
193
194         /// <summary>
195         /// Enumeration for the alignment of the flex items or lines when the items or lines do not
196         /// use all the available space on the cross axis.
197         /// </summary>
198         /// <since_tizen> 3 </since_tizen>
199         public enum Alignment
200         {
201             /// <summary>
202             /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
203             /// </summary>
204             /// <since_tizen> 3 </since_tizen>
205             AlignAuto,
206             /// <summary>
207             /// At the beginning of the container.
208             /// </summary>
209             /// <since_tizen> 3 </since_tizen>
210             AlignFlexStart,
211             /// <summary>
212             /// At the center of the container.
213             /// </summary>
214             /// <since_tizen> 3 </since_tizen>
215             AlignCenter,
216             /// <summary>
217             /// At the end of the container.
218             /// </summary>
219             /// <since_tizen> 3 </since_tizen>
220             AlignFlexEnd,
221             /// <summary>
222             /// Stretch to fit the container.
223             /// </summary>
224             /// <since_tizen> 3 </since_tizen>
225             AlignStretch
226         }
227
228         /// <summary>
229         /// Enumeration for the wrap type of the flex container when there is no enough room for
230         /// all the items on one flex line.
231         /// </summary>
232         /// <since_tizen> 3 </since_tizen>
233         public enum WrapType
234         {
235             /// <summary>
236             /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
237             /// </summary>
238             /// <since_tizen> 3 </since_tizen>
239             NoWrap,
240             /// <summary>
241             /// Flex items laid out in multiple lines if needed.
242             /// </summary>
243             /// <since_tizen> 3 </since_tizen>
244             Wrap
245         }
246
247         /// <summary>
248         /// The primary direction in which content is ordered.
249         /// </summary>
250         /// <since_tizen> 3 </since_tizen>
251         public ContentDirectionType ContentDirection
252         {
253             get
254             {
255                 int temp = 0;
256                 GetProperty(FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
257                 return (ContentDirectionType)temp;
258             }
259             set
260             {
261                 SetProperty(FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
262             }
263         }
264
265         /// <summary>
266         /// The direction of the main axis which determines the direction that flex items are laid out.
267         /// </summary>
268         /// <since_tizen> 3 </since_tizen>
269         public FlexDirectionType FlexDirection
270         {
271             get
272             {
273                 int temp = 0;
274                 GetProperty(FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
275                 return (FlexDirectionType)temp;
276             }
277             set
278             {
279                 SetProperty(FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
280             }
281         }
282
283         /// <summary>
284         /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
285         /// </summary>
286         /// <since_tizen> 3 </since_tizen>
287         public WrapType FlexWrap
288         {
289             get
290             {
291                 int temp = 0;
292                 GetProperty(FlexContainer.Property.FLEX_WRAP).Get(out temp);
293                 return (WrapType)temp;
294             }
295             set
296             {
297                 SetProperty(FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)value));
298             }
299         }
300
301         /// <summary>
302         /// The alignment of flex items when the items do not use all available space on the main axis.
303         /// </summary>
304         /// <since_tizen> 3 </since_tizen>
305         public Justification JustifyContent
306         {
307             get
308             {
309                 int temp = 0;
310                 GetProperty(FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
311                 return (Justification)temp;
312             }
313             set
314             {
315                 SetProperty(FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)value));
316             }
317         }
318
319         /// <summary>
320         /// The alignment of flex items when the items do not use all available space on the cross axis.
321         /// </summary>
322         /// <since_tizen> 3 </since_tizen>
323         public Alignment AlignItems
324         {
325             get
326             {
327                 int temp = 0;
328                 GetProperty(FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
329                 return (Alignment)temp;
330             }
331             set
332             {
333                 SetProperty(FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)value));
334             }
335         }
336
337         /// <summary>
338         /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
339         /// </summary>
340         /// <since_tizen> 3 </since_tizen>
341         public Alignment AlignContent
342         {
343             get
344             {
345                 int temp = 0;
346                 GetProperty(FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
347                 return (Alignment)temp;
348             }
349             set
350             {
351                 SetProperty(FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)value));
352             }
353         }
354
355     }
356
357 }