1 /** Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 using System.ComponentModel;
21 /// [Draft] This class implements a flex layout.
22 /// The flex layout implementation is based on open source Facebook Yoga layout engine.
23 /// For more information about the flex layout API and how to use it please refer to https://yogalayout.com/docs/
24 /// We implement the subset of the API in the class below.
26 internal class FlexLayout : LayoutGroupWrapper
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal FlexLayout(global::System.IntPtr cPtr, bool cMemoryOwn) : base(LayoutPINVOKE.FlexLayout_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexLayout obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 protected virtual void Dispose(DisposeTypes type)
47 if (type == DisposeTypes.Explicit)
50 //Release your own managed resources here.
51 //You should release all of your own disposable objects here.
55 //Release your own unmanaged resources here.
56 //You should not access any managed member here except static instance.
57 //because the execution order of Finalizes is non-deterministic.
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 LayoutPINVOKE.delete_FlexLayout(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 /// [Draft] Creates a FlexLayout object.
73 public FlexLayout() : this(LayoutPINVOKE.FlexLayout_New(), true)
75 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78 internal static FlexLayout DownCast(BaseHandle handle)
80 FlexLayout ret = new FlexLayout(LayoutPINVOKE.FlexLayout_DownCast(BaseHandle.getCPtr(handle)), true);
81 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 internal FlexLayout(FlexLayout other) : this(LayoutPINVOKE.new_FlexLayout__SWIG_1(FlexLayout.getCPtr(other)), true)
87 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 internal FlexLayout Assign(FlexLayout other)
92 FlexLayout ret = new FlexLayout(LayoutPINVOKE.FlexLayout_Assign(swigCPtr, FlexLayout.getCPtr(other)), false);
93 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 internal void SetFlexDirection(FlexLayout.FlexDirection flexDirection)
99 LayoutPINVOKE.FlexLayout_SetFlexDirection(swigCPtr, (int)flexDirection);
100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103 internal FlexLayout.FlexDirection GetFlexDirection()
105 FlexLayout.FlexDirection ret = (FlexLayout.FlexDirection)LayoutPINVOKE.FlexLayout_GetFlexDirection(swigCPtr);
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 internal void SetFlexJustification(FlexLayout.FlexJustification flexJustification)
112 LayoutPINVOKE.FlexLayout_SetFlexJustification(swigCPtr, (int)flexJustification);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 internal FlexLayout.FlexJustification GetFlexJustification()
118 FlexLayout.FlexJustification ret = (FlexLayout.FlexJustification)LayoutPINVOKE.FlexLayout_GetFlexJustification(swigCPtr);
119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 internal void SetFlexWrap(FlexLayout.FlexWrapType flexWrap)
125 LayoutPINVOKE.FlexLayout_SetFlexWrap(swigCPtr, (int)flexWrap);
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 internal FlexLayout.FlexWrapType GetFlexWrap()
131 FlexLayout.FlexWrapType ret = (FlexLayout.FlexWrapType)LayoutPINVOKE.FlexLayout_GetFlexWrap(swigCPtr);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 internal void SetFlexAlignment(FlexLayout.AlignmentType flexAlignment)
138 LayoutPINVOKE.FlexLayout_SetFlexAlignment(swigCPtr, (int)flexAlignment);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 internal FlexLayout.AlignmentType GetFlexAlignment()
144 FlexLayout.AlignmentType ret = (FlexLayout.AlignmentType)LayoutPINVOKE.FlexLayout_GetFlexAlignment(swigCPtr);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 internal void SetFlexItemsAlignment(FlexLayout.AlignmentType flexAlignment)
151 LayoutPINVOKE.FlexLayout_SetFlexItemsAlignment(swigCPtr, (int)flexAlignment);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 internal FlexLayout.AlignmentType GetFlexItemsAlignment()
157 FlexLayout.AlignmentType ret = (FlexLayout.AlignmentType)LayoutPINVOKE.FlexLayout_GetFlexItemsAlignment(swigCPtr);
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 internal enum PropertyRange
164 CHILD_PROPERTY_START_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX,
165 CHILD_PROPERTY_END_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000
168 internal class ChildProperty
170 internal static readonly int FLEX = LayoutPINVOKE.FlexLayout_ChildProperty_FLEX_get();
171 internal static readonly int ALIGN_SELF = LayoutPINVOKE.FlexLayout_ChildProperty_ALIGN_SELF_get();
175 /// [Draft] Get/Set the flex direction in the layout.
176 /// The direction of the main-axis which determines the direction that flex items are laid out.
178 public FlexDirection Direction
182 return GetFlexDirection();
186 SetFlexDirection(value);
191 /// [Draft] Get/Set the justification in the layout.
193 public FlexJustification Justification
197 return GetFlexJustification();
201 SetFlexJustification(value);
206 /// [Draft] Get/Set the wrap in the layout.
208 public FlexWrapType WrapType
212 return GetFlexWrap();
221 /// [Draft] Get/Set the alignment of the layout content.
223 public AlignmentType Alignment
227 return GetFlexAlignment();
231 SetFlexAlignment(value);
236 /// [Draft] Get/Set the alignment of the layout items.
238 public AlignmentType ItemsAlignment
242 return GetFlexItemsAlignment();
246 SetFlexItemsAlignment(value);
251 /// [Draft] Enumeration for the direction of the main axis in the flex container.
252 /// This determines the direction that flex items are laid out in the flex container.
254 public enum FlexDirection
257 /// The flexible items are displayed vertically as a column
261 /// The flexible items are displayed vertically as a column, but in reverse order
265 /// The flexible items are displayed horizontally as a row
269 /// The flexible items are displayed horizontally as a row, but in reverse order
275 /// [Draft] Enumeration for the alignment of the flex items when the items do not use all available space on the main-axis.
277 public enum FlexJustification
280 /// Items are positioned at the beginning of the container
284 /// Items are positioned at the center of the container
288 /// Items are positioned at the end of the container
292 /// Items are positioned with equal space between the lines
296 /// Items are positioned with equal space before, between, and after the lines
302 /// [Draft] Enumeration for the wrap type of the flex container when there is no enough room for all the items on one flex line.
304 public enum FlexWrapType
307 /// Flex items laid out in single line (shrunk to fit the flex container along the main axis)
311 /// Flex items laid out in multiple lines if needed
317 /// [Draft] Enumeration for the alignment of the flex items or lines when the items or lines do not use all the available space on the cross-axis.
319 public enum AlignmentType
322 /// Inherits the same alignment from the parent (only valid for "alignSelf" property)
326 /// At the beginning of the container
330 /// At the center of the container
334 /// At the end of the container
338 /// Stretch to fit the container