2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using Tizen.NUI.Binding;
21 namespace Tizen.NUI.BaseComponents
24 /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br />
25 /// 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 />
26 /// 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 />
27 /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public class FlexContainer : View
32 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public static readonly BindableProperty ContentDirectionProperty = BindableProperty.Create("ContentDirection", typeof(ContentDirectionType), typeof(FlexContainer), ContentDirectionType.Inherit, propertyChanged: (bindable, oldValue, newValue) =>
36 var flexContainer = (FlexContainer)bindable;
39 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)newValue));
42 defaultValueCreator: (bindable) =>
44 var flexContainer = (FlexContainer)bindable;
46 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
47 return (ContentDirectionType)temp;
49 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50 [EditorBrowsable(EditorBrowsableState.Never)]
51 public static readonly BindableProperty FlexDirectionProperty = BindableProperty.Create("FlexDirection", typeof(FlexDirectionType), typeof(FlexContainer), FlexDirectionType.Column, propertyChanged: (bindable, oldValue, newValue) =>
53 var flexContainer = (FlexContainer)bindable;
56 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)newValue));
59 defaultValueCreator: (bindable) =>
61 var flexContainer = (FlexContainer)bindable;
63 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
64 return (FlexDirectionType)temp;
66 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public static readonly BindableProperty FlexWrapProperty = BindableProperty.Create("FlexWrap", typeof(WrapType), typeof(FlexContainer), WrapType.NoWrap, propertyChanged: (bindable, oldValue, newValue) =>
70 var flexContainer = (FlexContainer)bindable;
73 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)newValue));
76 defaultValueCreator: (bindable) =>
78 var flexContainer = (FlexContainer)bindable;
80 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_WRAP).Get(out temp);
81 return (WrapType)temp;
83 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
84 [EditorBrowsable(EditorBrowsableState.Never)]
85 public static readonly BindableProperty JustifyContentProperty = BindableProperty.Create("JustifyContent", typeof(Justification), typeof(FlexContainer), Justification.JustifyFlexStart, propertyChanged: (bindable, oldValue, newValue) =>
87 var flexContainer = (FlexContainer)bindable;
90 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)newValue));
93 defaultValueCreator: (bindable) =>
95 var flexContainer = (FlexContainer)bindable;
97 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
98 return (Justification)temp;
100 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
101 [EditorBrowsable(EditorBrowsableState.Never)]
102 public static readonly BindableProperty AlignItemsProperty = BindableProperty.Create("AlignItems", typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (bindable, oldValue, newValue) =>
104 var flexContainer = (FlexContainer)bindable;
105 if (newValue != null)
107 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)newValue));
110 defaultValueCreator: (bindable) =>
112 var flexContainer = (FlexContainer)bindable;
114 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
115 return (Alignment)temp;
117 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 public static readonly BindableProperty AlignContentProperty = BindableProperty.Create("AlignContent", typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (bindable, oldValue, newValue) =>
121 var flexContainer = (FlexContainer)bindable;
122 if (newValue != null)
124 Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)newValue));
127 defaultValueCreator: (bindable) =>
129 var flexContainer = (FlexContainer)bindable;
131 Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
132 return (Alignment)temp;
137 /// Creates a FlexContainer handle.
138 /// Calling member functions with an uninitialized handle is not allowed.
140 /// <since_tizen> 3 </since_tizen>
141 public FlexContainer() : this(Interop.FlexContainer.FlexContainer_New(), true)
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.FlexContainer.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
151 /// Enumeration for the direction of the main axis in the flex container. This determines
152 /// the direction that flex items are laid out in the flex container.
154 /// <since_tizen> 3 </since_tizen>
155 public enum FlexDirectionType
158 /// The flexible items are displayed vertically as a column.
160 /// <since_tizen> 3 </since_tizen>
163 /// The flexible items are displayed vertically as a column, but in reverse order.
165 /// <since_tizen> 3 </since_tizen>
168 /// The flexible items are displayed horizontally as a row.
170 /// <since_tizen> 3 </since_tizen>
173 /// The flexible items are displayed horizontally as a row.
175 /// <since_tizen> 3 </since_tizen>
180 /// Enumeration for the primary direction in which content is ordered in the flex container
181 /// and on which sides the ?�start??and ?�end??are.
183 /// <since_tizen> 3 </since_tizen>
184 public enum ContentDirectionType
187 /// Inherits the same direction from the parent.
189 /// <since_tizen> 3 </since_tizen>
192 /// From left to right.
194 /// <since_tizen> 3 </since_tizen>
197 /// From right to left.
199 /// <since_tizen> 3 </since_tizen>
204 /// Enumeration for the alignment of the flex items when the items do not use all available
205 /// space on the main axis.
207 /// <since_tizen> 3 </since_tizen>
208 public enum Justification
211 /// Items are positioned at the beginning of the container.
213 /// <since_tizen> 3 </since_tizen>
216 /// Items are positioned at the center of the container.
218 /// <since_tizen> 3 </since_tizen>
221 /// Items are positioned at the end of the container.
223 /// <since_tizen> 3 </since_tizen>
226 /// Items are positioned with equal space between the lines.
228 /// <since_tizen> 3 </since_tizen>
231 /// Items are positioned with equal space before, between, and after the lines.
233 /// <since_tizen> 3 </since_tizen>
238 /// Enumeration for the alignment of the flex items or lines when the items or lines do not
239 /// use all the available space on the cross axis.
241 /// <since_tizen> 3 </since_tizen>
242 public enum Alignment
245 /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
247 /// <since_tizen> 3 </since_tizen>
250 /// At the beginning of the container.
252 /// <since_tizen> 3 </since_tizen>
255 /// At the center of the container.
257 /// <since_tizen> 3 </since_tizen>
260 /// At the end of the container.
262 /// <since_tizen> 3 </since_tizen>
265 /// Stretch to fit the container.
267 /// <since_tizen> 3 </since_tizen>
272 /// Enumeration for the wrap type of the flex container when there is no enough room for
273 /// all the items on one flex line.
275 /// <since_tizen> 3 </since_tizen>
279 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
281 /// <since_tizen> 3 </since_tizen>
284 /// Flex items laid out in multiple lines if needed.
286 /// <since_tizen> 3 </since_tizen>
291 /// The primary direction in which content is ordered.
293 /// <since_tizen> 3 </since_tizen>
294 public ContentDirectionType ContentDirection
298 return (ContentDirectionType)GetValue(ContentDirectionProperty);
302 SetValue(ContentDirectionProperty, value);
303 NotifyPropertyChanged();
308 /// The direction of the main axis which determines the direction that flex items are laid out.
310 /// <since_tizen> 3 </since_tizen>
311 public FlexDirectionType FlexDirection
315 return (FlexDirectionType)GetValue(FlexDirectionProperty);
319 SetValue(FlexDirectionProperty, value);
320 NotifyPropertyChanged();
325 /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
327 /// <since_tizen> 3 </since_tizen>
328 public WrapType FlexWrap
332 return (WrapType)GetValue(FlexWrapProperty);
336 SetValue(FlexWrapProperty, value);
337 NotifyPropertyChanged();
342 /// The alignment of flex items when the items do not use all available space on the main axis.
344 /// <since_tizen> 3 </since_tizen>
345 public Justification JustifyContent
349 return (Justification)GetValue(JustifyContentProperty);
353 SetValue(JustifyContentProperty, value);
354 NotifyPropertyChanged();
359 /// The alignment of flex items when the items do not use all available space on the cross axis.
361 /// <since_tizen> 3 </since_tizen>
362 public Alignment AlignItems
366 return (Alignment)GetValue(AlignItemsProperty);
370 SetValue(AlignItemsProperty, value);
371 NotifyPropertyChanged();
376 /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
378 /// <since_tizen> 3 </since_tizen>
379 public Alignment AlignContent
383 return (Alignment)GetValue(AlignContentProperty);
387 SetValue(AlignContentProperty, value);
388 NotifyPropertyChanged();
392 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexContainer obj)
394 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
397 /// This will not be public opened.
398 [EditorBrowsable(EditorBrowsableState.Never)]
399 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
401 Interop.FlexContainer.delete_FlexContainer(swigCPtr);
405 /// Enumeration for the instance of child properties belonging to the FlexContainer class.
407 /// <since_tizen> 3 </since_tizen>
408 [Obsolete("Deprecated in API6, Will be removed in API9, " +
409 "Please use View.Flex, View.AlignSelf, View.FlexMargin instead!")]
410 [EditorBrowsable(EditorBrowsableState.Never)]
411 public class ChildProperty
413 internal static readonly int FLEX = Interop.FlexContainer.FlexContainer_ChildProperty_FLEX_get();
414 internal static readonly int ALIGN_SELF = Interop.FlexContainer.FlexContainer_ChildProperty_ALIGN_SELF_get();
415 internal static readonly int FLEX_MARGIN = Interop.FlexContainer.FlexContainer_ChildProperty_FLEX_MARGIN_get();
418 internal new class Property
420 internal static readonly int CONTENT_DIRECTION = Interop.FlexContainer.FlexContainer_Property_CONTENT_DIRECTION_get();
421 internal static readonly int FLEX_DIRECTION = Interop.FlexContainer.FlexContainer_Property_FLEX_DIRECTION_get();
422 internal static readonly int FLEX_WRAP = Interop.FlexContainer.FlexContainer_Property_FLEX_WRAP_get();
423 internal static readonly int JUSTIFY_CONTENT = Interop.FlexContainer.FlexContainer_Property_JUSTIFY_CONTENT_get();
424 internal static readonly int ALIGN_ITEMS = Interop.FlexContainer.FlexContainer_Property_ALIGN_ITEMS_get();
425 internal static readonly int ALIGN_CONTENT = Interop.FlexContainer.FlexContainer_Property_ALIGN_CONTENT_get();