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;
135 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
138 /// Creates a FlexContainer handle.
139 /// Calling member functions with an uninitialized handle is not allowed.
141 /// <since_tizen> 3 </since_tizen>
142 public FlexContainer() : this(Interop.FlexContainer.FlexContainer_New(), true)
144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.FlexContainer.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
149 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
153 /// Enumeration for the direction of the main axis in the flex container. This determines
154 /// the direction that flex items are laid out in the flex container.
156 /// <since_tizen> 3 </since_tizen>
157 public enum FlexDirectionType
160 /// The flexible items are displayed vertically as a column.
162 /// <since_tizen> 3 </since_tizen>
165 /// The flexible items are displayed vertically as a column, but in reverse order.
167 /// <since_tizen> 3 </since_tizen>
170 /// The flexible items are displayed horizontally as a row.
172 /// <since_tizen> 3 </since_tizen>
175 /// The flexible items are displayed horizontally as a row.
177 /// <since_tizen> 3 </since_tizen>
182 /// Enumeration for the primary direction in which content is ordered in the flex container
183 /// and on which sides the ?�start??and ?�end??are.
185 /// <since_tizen> 3 </since_tizen>
186 public enum ContentDirectionType
189 /// Inherits the same direction from the parent.
191 /// <since_tizen> 3 </since_tizen>
194 /// From left to right.
196 /// <since_tizen> 3 </since_tizen>
199 /// From right to left.
201 /// <since_tizen> 3 </since_tizen>
206 /// Enumeration for the alignment of the flex items when the items do not use all available
207 /// space on the main axis.
209 /// <since_tizen> 3 </since_tizen>
210 public enum Justification
213 /// Items are positioned at the beginning of the container.
215 /// <since_tizen> 3 </since_tizen>
218 /// Items are positioned at the center of the container.
220 /// <since_tizen> 3 </since_tizen>
223 /// Items are positioned at the end of the container.
225 /// <since_tizen> 3 </since_tizen>
228 /// Items are positioned with equal space between the lines.
230 /// <since_tizen> 3 </since_tizen>
233 /// Items are positioned with equal space before, between, and after the lines.
235 /// <since_tizen> 3 </since_tizen>
240 /// Enumeration for the alignment of the flex items or lines when the items or lines do not
241 /// use all the available space on the cross axis.
243 /// <since_tizen> 3 </since_tizen>
244 public enum Alignment
247 /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
249 /// <since_tizen> 3 </since_tizen>
252 /// At the beginning of the container.
254 /// <since_tizen> 3 </since_tizen>
257 /// At the center of the container.
259 /// <since_tizen> 3 </since_tizen>
262 /// At the end of the container.
264 /// <since_tizen> 3 </since_tizen>
267 /// Stretch to fit the container.
269 /// <since_tizen> 3 </since_tizen>
274 /// Enumeration for the wrap type of the flex container when there is no enough room for
275 /// all the items on one flex line.
277 /// <since_tizen> 3 </since_tizen>
281 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
283 /// <since_tizen> 3 </since_tizen>
286 /// Flex items laid out in multiple lines if needed.
288 /// <since_tizen> 3 </since_tizen>
293 /// The primary direction in which content is ordered.
295 /// <since_tizen> 3 </since_tizen>
296 public ContentDirectionType ContentDirection
300 return (ContentDirectionType)GetValue(ContentDirectionProperty);
304 SetValue(ContentDirectionProperty, value);
305 NotifyPropertyChanged();
310 /// The direction of the main axis which determines the direction that flex items are laid out.
312 /// <since_tizen> 3 </since_tizen>
313 public FlexDirectionType FlexDirection
317 return (FlexDirectionType)GetValue(FlexDirectionProperty);
321 SetValue(FlexDirectionProperty, value);
322 NotifyPropertyChanged();
327 /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
329 /// <since_tizen> 3 </since_tizen>
330 public WrapType FlexWrap
334 return (WrapType)GetValue(FlexWrapProperty);
338 SetValue(FlexWrapProperty, value);
339 NotifyPropertyChanged();
344 /// The alignment of flex items when the items do not use all available space on the main axis.
346 /// <since_tizen> 3 </since_tizen>
347 public Justification JustifyContent
351 return (Justification)GetValue(JustifyContentProperty);
355 SetValue(JustifyContentProperty, value);
356 NotifyPropertyChanged();
361 /// The alignment of flex items when the items do not use all available space on the cross axis.
363 /// <since_tizen> 3 </since_tizen>
364 public Alignment AlignItems
368 return (Alignment)GetValue(AlignItemsProperty);
372 SetValue(AlignItemsProperty, value);
373 NotifyPropertyChanged();
378 /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
380 /// <since_tizen> 3 </since_tizen>
381 public Alignment AlignContent
385 return (Alignment)GetValue(AlignContentProperty);
389 SetValue(AlignContentProperty, value);
390 NotifyPropertyChanged();
394 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexContainer obj)
396 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
400 /// To make the FlexContainer instance be disposed.
402 /// <since_tizen> 3 </since_tizen>
403 protected override void Dispose(DisposeTypes type)
410 //Release your own unmanaged resources here.
411 //You should not access any managed member here except static instance.
412 //because the execution order of Finalizes is non-deterministic.
414 if (swigCPtr.Handle != global::System.IntPtr.Zero)
419 Interop.FlexContainer.delete_FlexContainer(swigCPtr);
421 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
428 /// Enumeration for the instance of child properties belonging to the FlexContainer class.
430 /// <since_tizen> 3 </since_tizen>
431 [Obsolete("Deprecated in API6, Will be removed in API9, " +
432 "Please use View.Flex, View.AlignSelf, View.FlexMargin instead!")]
433 [EditorBrowsable(EditorBrowsableState.Never)]
434 public class ChildProperty
436 internal static readonly int FLEX = Interop.FlexContainer.FlexContainer_ChildProperty_FLEX_get();
437 internal static readonly int ALIGN_SELF = Interop.FlexContainer.FlexContainer_ChildProperty_ALIGN_SELF_get();
438 internal static readonly int FLEX_MARGIN = Interop.FlexContainer.FlexContainer_ChildProperty_FLEX_MARGIN_get();
441 internal new class Property
443 internal static readonly int CONTENT_DIRECTION = Interop.FlexContainer.FlexContainer_Property_CONTENT_DIRECTION_get();
444 internal static readonly int FLEX_DIRECTION = Interop.FlexContainer.FlexContainer_Property_FLEX_DIRECTION_get();
445 internal static readonly int FLEX_WRAP = Interop.FlexContainer.FlexContainer_Property_FLEX_WRAP_get();
446 internal static readonly int JUSTIFY_CONTENT = Interop.FlexContainer.FlexContainer_Property_JUSTIFY_CONTENT_get();
447 internal static readonly int ALIGN_ITEMS = Interop.FlexContainer.FlexContainer_Property_ALIGN_ITEMS_get();
448 internal static readonly int ALIGN_CONTENT = Interop.FlexContainer.FlexContainer_Property_ALIGN_CONTENT_get();