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 System.Diagnostics.CodeAnalysis;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
25 /// FlexContainer implements a subset of the flexbox spec (defined by W3C):https://www.w3.org/TR/css3-flexbox/<br />
26 /// 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 />
27 /// 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 />
28 /// FlexContainer can expand items to fill available free space, or shrink them to prevent overflow.<br />
30 /// <since_tizen> 3 </since_tizen>
31 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
32 public class FlexContainer : View
34 /// <summary> Property of ContentDirection </summary>
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public static readonly BindableProperty ContentDirectionProperty = BindableProperty.Create(nameof(ContentDirection), typeof(ContentDirectionType), typeof(FlexContainer), ContentDirectionType.Inherit, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
38 var flexContainer = (FlexContainer)bindable;
41 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.ContentDirection, new Tizen.NUI.PropertyValue((int)newValue));
44 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
46 var flexContainer = (FlexContainer)bindable;
48 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.ContentDirection).Get(out temp);
49 return (ContentDirectionType)temp;
51 /// <summary> Property of FlexDirection </summary>
52 [EditorBrowsable(EditorBrowsableState.Never)]
53 public static readonly BindableProperty FlexDirectionProperty = BindableProperty.Create(nameof(FlexDirection), typeof(FlexDirectionType), typeof(FlexContainer), FlexDirectionType.Column, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
55 var flexContainer = (FlexContainer)bindable;
58 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexDirection, new Tizen.NUI.PropertyValue((int)newValue));
61 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
63 var flexContainer = (FlexContainer)bindable;
65 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexDirection).Get(out temp);
66 return (FlexDirectionType)temp;
68 /// <summary> Property of FlexWrap </summary>
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public static readonly BindableProperty FlexWrapProperty = BindableProperty.Create(nameof(FlexWrap), typeof(WrapType), typeof(FlexContainer), WrapType.NoWrap, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
72 var flexContainer = (FlexContainer)bindable;
75 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexWrap, new Tizen.NUI.PropertyValue((int)newValue));
78 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
80 var flexContainer = (FlexContainer)bindable;
82 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.FlexWrap).Get(out temp);
83 return (WrapType)temp;
85 /// <summary> Property of JustifyContent </summary>
86 [EditorBrowsable(EditorBrowsableState.Never)]
87 public static readonly BindableProperty JustifyContentProperty = BindableProperty.Create(nameof(JustifyContent), typeof(Justification), typeof(FlexContainer), Justification.JustifyFlexStart, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
89 var flexContainer = (FlexContainer)bindable;
92 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.JustifyContent, new Tizen.NUI.PropertyValue((int)newValue));
95 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
97 var flexContainer = (FlexContainer)bindable;
99 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.JustifyContent).Get(out temp);
100 return (Justification)temp;
102 /// <summary> Property of AlignItems </summary>
103 [EditorBrowsable(EditorBrowsableState.Never)]
104 public static readonly BindableProperty AlignItemsProperty = BindableProperty.Create(nameof(AlignItems), typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
106 var flexContainer = (FlexContainer)bindable;
107 if (newValue != null)
109 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignItems, new Tizen.NUI.PropertyValue((int)newValue));
112 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
114 var flexContainer = (FlexContainer)bindable;
116 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignItems).Get(out temp);
117 return (Alignment)temp;
119 /// <summary> Property of AlignContent </summary>
120 [EditorBrowsable(EditorBrowsableState.Never)]
121 public static readonly BindableProperty AlignContentProperty = BindableProperty.Create(nameof(AlignContent), typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
123 var flexContainer = (FlexContainer)bindable;
124 if (newValue != null)
126 Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignContent, new Tizen.NUI.PropertyValue((int)newValue));
129 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
131 var flexContainer = (FlexContainer)bindable;
133 Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)flexContainer.SwigCPtr, FlexContainer.Property.AlignContent).Get(out temp);
134 return (Alignment)temp;
139 /// Creates a FlexContainer handle.
140 /// Calling member functions with an uninitialized handle is not allowed.
142 /// <since_tizen> 3 </since_tizen>
143 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
144 public FlexContainer() : this(Interop.FlexContainer.New(), true)
146 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
154 /// Enumeration for the direction of the main axis in the flex container. This determines
155 /// the direction that flex items are laid out in the flex container.
157 /// <since_tizen> 3 </since_tizen>
158 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
159 public enum FlexDirectionType
162 /// The flexible items are displayed vertically as a column.
164 /// <since_tizen> 3 </since_tizen>
165 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
168 /// The flexible items are displayed vertically as a column, but in reverse order.
170 /// <since_tizen> 3 </since_tizen>
171 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
174 /// The flexible items are displayed horizontally as a row.
176 /// <since_tizen> 3 </since_tizen>
177 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
180 /// The flexible items are displayed horizontally as a row.
182 /// <since_tizen> 3 </since_tizen>
183 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
188 /// Enumeration for the primary direction in which content is ordered in the flex container
189 /// and on which sides the ?�start??and ?�end??are.
191 /// <since_tizen> 3 </since_tizen>
192 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
193 public enum ContentDirectionType
196 /// Inherits the same direction from the parent.
198 /// <since_tizen> 3 </since_tizen>
199 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
202 /// From left to right.
204 /// <since_tizen> 3 </since_tizen>
205 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
208 /// From right to left.
210 /// <since_tizen> 3 </since_tizen>
211 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
216 /// Enumeration for the alignment of the flex items when the items do not use all available
217 /// space on the main axis.
219 /// <since_tizen> 3 </since_tizen>
220 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
221 public enum Justification
224 /// Items are positioned at the beginning of the container.
226 /// <since_tizen> 3 </since_tizen>
227 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
230 /// Items are positioned at the center of the container.
232 /// <since_tizen> 3 </since_tizen>
233 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
236 /// Items are positioned at the end of the container.
238 /// <since_tizen> 3 </since_tizen>
239 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
242 /// Items are positioned with equal space between the lines.
244 /// <since_tizen> 3 </since_tizen>
245 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
248 /// Items are positioned with equal space before, between, and after the lines.
250 /// <since_tizen> 3 </since_tizen>
251 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
256 /// Enumeration for the alignment of the flex items or lines when the items or lines do not
257 /// use all the available space on the cross axis.
259 /// <since_tizen> 3 </since_tizen>
260 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
261 public enum Alignment
264 /// Inherits the same alignment from the parent (only valid for "alignSelf" property).
266 /// <since_tizen> 3 </since_tizen>
267 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
270 /// At the beginning of the container.
272 /// <since_tizen> 3 </since_tizen>
273 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
276 /// At the center of the container.
278 /// <since_tizen> 3 </since_tizen>
279 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
282 /// At the end of the container.
284 /// <since_tizen> 3 </since_tizen>
285 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
288 /// Stretch to fit the container.
290 /// <since_tizen> 3 </since_tizen>
291 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
296 /// Enumeration for the wrap type of the flex container when there is no enough room for
297 /// all the items on one flex line.
299 /// <since_tizen> 3 </since_tizen>
300 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
304 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis).
306 /// <since_tizen> 3 </since_tizen>
307 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
310 /// Flex items laid out in multiple lines if needed.
312 /// <since_tizen> 3 </since_tizen>
313 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
318 /// The primary direction in which content is ordered.
320 /// <since_tizen> 3 </since_tizen>
321 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
322 public ContentDirectionType ContentDirection
326 return (ContentDirectionType)GetValue(ContentDirectionProperty);
330 SetValue(ContentDirectionProperty, value);
331 NotifyPropertyChanged();
336 /// The direction of the main axis which determines the direction that flex items are laid out.
338 /// <since_tizen> 3 </since_tizen>
339 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
340 public FlexDirectionType FlexDirection
344 return (FlexDirectionType)GetValue(FlexDirectionProperty);
348 SetValue(FlexDirectionProperty, value);
349 NotifyPropertyChanged();
354 /// Whether the flex items should wrap or not if there is no enough room for them on one flex line.
356 /// <since_tizen> 3 </since_tizen>
357 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
358 public WrapType FlexWrap
362 return (WrapType)GetValue(FlexWrapProperty);
366 SetValue(FlexWrapProperty, value);
367 NotifyPropertyChanged();
372 /// The alignment of flex items when the items do not use all available space on the main axis.
374 /// <since_tizen> 3 </since_tizen>
375 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
376 public Justification JustifyContent
380 return (Justification)GetValue(JustifyContentProperty);
384 SetValue(JustifyContentProperty, value);
385 NotifyPropertyChanged();
390 /// The alignment of flex items when the items do not use all available space on the cross axis.
392 /// <since_tizen> 3 </since_tizen>
393 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
394 public Alignment AlignItems
398 return (Alignment)GetValue(AlignItemsProperty);
402 SetValue(AlignItemsProperty, value);
403 NotifyPropertyChanged();
408 /// Similar to "alignItems", but it aligns flex lines; so only works when there are multiple lines.
410 /// <since_tizen> 3 </since_tizen>
411 [Obsolete("This has been deprecated in API8 and will be removed in API10. Use FlexLayout instead.")]
412 public Alignment AlignContent
416 return (Alignment)GetValue(AlignContentProperty);
420 SetValue(AlignContentProperty, value);
421 NotifyPropertyChanged();
426 [EditorBrowsable(EditorBrowsableState.Never)]
427 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
429 Interop.FlexContainer.DeleteFlexContainer(swigCPtr);
433 /// Enumeration for the instance of child properties belonging to the FlexContainer class.
435 internal class ChildProperty
437 internal static readonly int FLEX = Interop.FlexContainer.ChildPropertyFlexGet();
438 internal static readonly int AlignSelf = Interop.FlexContainer.ChildPropertyAlignSelfGet();
439 internal static readonly int FlexMargin = Interop.FlexContainer.ChildPropertyFlexMarginGet();
442 internal new class Property
444 internal static readonly int ContentDirection = Interop.FlexContainer.ContentDirectionGet();
445 internal static readonly int FlexDirection = Interop.FlexContainer.FlexDirectionGet();
446 internal static readonly int FlexWrap = Interop.FlexContainer.FlexWrapGet();
447 internal static readonly int JustifyContent = Interop.FlexContainer.JustifyContentGet();
448 internal static readonly int AlignItems = Interop.FlexContainer.AlignItemsGet();
449 internal static readonly int AlignContent = Interop.FlexContainer.AlignContentGet();