Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / FlexContainer.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI.BaseComponents
18 {
19     /// <summary>
20     /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br>
21     /// It aims at providing a more efficient way to lay out, align and distribute space among items in the container, even when their size is unknown or dynamic.<br>
22     /// FlexContainer has the ability to alter the width and height of its children (i.e. flex items) to fill the available space in the best possible way on different screen sizes.<br>
23     /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br>
24     /// </summary>
25     public class FlexContainer : View
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28
29         internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
30         {
31             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32         }
33
34         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexContainer obj)
35         {
36             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37         }
38
39         protected override void Dispose(DisposeTypes type)
40         {
41             if(disposed)
42             {
43                 return;
44             }
45
46             if(type == DisposeTypes.Explicit)
47             {
48                 //Called by User
49                 //Release your own managed resources here.
50                 //You should release all of your own disposable objects here.
51             }
52
53             //Release your own unmanaged resources here.
54             //You should not access any managed member here except static instance.
55             //because the execution order of Finalizes is non-deterministic.
56
57             if (swigCPtr.Handle != global::System.IntPtr.Zero)
58             {
59                 if (swigCMemOwn)
60                 {
61                     swigCMemOwn = false;
62                     NDalicPINVOKE.delete_FlexContainer(swigCPtr);
63                 }
64                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65             }
66
67             base.Dispose(type);
68         }
69
70
71         internal class Property
72         {
73             internal static readonly int CONTENT_DIRECTION = NDalicPINVOKE.FlexContainer_Property_CONTENT_DIRECTION_get();
74             internal static readonly int FLEX_DIRECTION = NDalicPINVOKE.FlexContainer_Property_FLEX_DIRECTION_get();
75             internal static readonly int FLEX_WRAP = NDalicPINVOKE.FlexContainer_Property_FLEX_WRAP_get();
76             internal static readonly int JUSTIFY_CONTENT = NDalicPINVOKE.FlexContainer_Property_JUSTIFY_CONTENT_get();
77             internal static readonly int ALIGN_ITEMS = NDalicPINVOKE.FlexContainer_Property_ALIGN_ITEMS_get();
78             internal static readonly int ALIGN_CONTENT = NDalicPINVOKE.FlexContainer_Property_ALIGN_CONTENT_get();
79
80         }
81
82         /// <summary>
83         /// Enumeration for the instance of child properties belonging to the FlexContainer class.
84         /// </summary>
85         public class ChildProperty
86         {
87             internal static readonly int FLEX = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_get();
88             internal static readonly int ALIGN_SELF = NDalicPINVOKE.FlexContainer_ChildProperty_ALIGN_SELF_get();
89             internal static readonly int FLEX_MARGIN = NDalicPINVOKE.FlexContainer_ChildProperty_FLEX_MARGIN_get();
90         }
91
92         /// <summary>
93         /// Creates a FlexContainer handle.
94         /// Calling member functions with an uninitialized handle is not allowed.
95         /// </summary>
96         public FlexContainer() : this(NDalicPINVOKE.FlexContainer_New(), true)
97         {
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99
100         }
101
102         /// <summary>
103         /// Enumeration for the direction of the main axis in the flex container. This determines
104         /// the direction that flex items are laid out in the flex container.
105         /// </summary>
106         public enum FlexDirectionType
107         {
108             Column,
109             ColumnReverse,
110             Row,
111             RowReverse
112         }
113
114         /// <summary>
115         /// Enumeration for the primary direction in which content is ordered in the flex container
116         /// and on which sides the ?�start??and ?�end??are.
117         /// </summary>
118         public enum ContentDirectionType
119         {
120             Inherit,
121             LTR,
122             RTL
123         }
124
125         /// <summary>
126         /// Enumeration for the alignment of the flex items when the items do not use all available
127         /// space on the main-axis.
128         /// </summary>
129         public enum Justification
130         {
131             JustifyFlexStart,
132             JustifyCenter,
133             JustifyFlexEnd,
134             JustifySpaceBetween,
135             JustifySpaceAround
136         }
137
138         /// <summary>
139         /// Enumeration for the alignment of the flex items or lines when the items or lines do not
140         /// use all the available space on the cross-axis.
141         /// </summary>
142         public enum Alignment
143         {
144             AlignAuto,
145             AlignFlexStart,
146             AlignCenter,
147             AlignFlexEnd,
148             AlignStretch
149         }
150
151         /// <summary>
152         /// Enumeration for the wrap type of the flex container when there is no enough room for
153         /// all the items on one flex line.
154         /// </summary>
155         public enum WrapType
156         {
157             NoWrap,
158             Wrap
159         }
160
161         /// <summary>
162         /// The primary direction in which content is ordered
163         /// </summary>
164         public ContentDirectionType ContentDirection
165         {
166             get
167             {
168                 int temp = 0;
169                 GetProperty(FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
170                 return (ContentDirectionType)temp;
171             }
172             set
173             {
174                 SetProperty(FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
175             }
176         }
177
178         /// <summary>
179         /// The direction of the main-axis which determines the direction that flex items are laid out
180         /// </summary>
181         public FlexDirectionType FlexDirection
182         {
183             get
184             {
185                 int temp = 0;
186                 GetProperty(FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
187                 return (FlexDirectionType)temp;
188             }
189             set
190             {
191                 SetProperty(FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
192             }
193         }
194
195         /// <summary>
196         /// Whether the flex items should wrap or not if there is no enough room for them on one flex line
197         /// </summary>
198         public WrapType FlexWrap
199         {
200             get
201             {
202                 int temp = 0;
203                 GetProperty(FlexContainer.Property.FLEX_WRAP).Get(out temp);
204                 return (WrapType)temp;
205             }
206             set
207             {
208                 SetProperty(FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)value));
209             }
210         }
211
212         /// <summary>
213         /// The alignment of flex items when the items do not use all available space on the main-axis
214         /// </summary>
215         public Justification JustifyContent
216         {
217             get
218             {
219                 int temp = 0;
220                 GetProperty(FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
221                 return (Justification)temp;
222             }
223             set
224             {
225                 SetProperty(FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)value));
226             }
227         }
228
229         /// <summary>
230         /// The alignment of flex items when the items do not use all available space on the cross-axis
231         /// </summary>
232         public Alignment AlignItems
233         {
234             get
235             {
236                 int temp = 0;
237                 GetProperty(FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
238                 return (Alignment)temp;
239             }
240             set
241             {
242                 SetProperty(FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)value));
243             }
244         }
245
246         /// <summary>
247         /// Similar to "alignItems", but it aligns flex lines, so only works when there are multiple lines
248         /// </summary>
249         public Alignment AlignContent
250         {
251             get
252             {
253                 int temp = 0;
254                 GetProperty(FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
255                 return (Alignment)temp;
256             }
257             set
258             {
259                 SetProperty(FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)value));
260             }
261         }
262
263     }
264
265 }