-/* Copyright (c) 2018 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*
*/
-using System.ComponentModel;
+using System;
+using Tizen.NUI.BaseComponents;
namespace Tizen.NUI
{
/// [Draft] This class implements a absolute layout, allowing explicit positioning of children.
/// Positions are from the top left of the layout and can be set using the Actor::Property::POSITION and alike.
/// </summary>
- internal class AbsoluteLayout : LayoutGroupWrapper
+ internal class AbsoluteLayout : LayoutGroup
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal AbsoluteLayout(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.AbsoluteLayout.AbsoluteLayout_SWIGUpcast(cPtr), cMemoryOwn)
+ /// <summary>
+ /// Struct to store Measured states of height and width.
+ /// </summary>
+ private struct HeightAndWidthState
{
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ public MeasuredSize.StateType widthState;
+ public MeasuredSize.StateType heightState;
+
+ public HeightAndWidthState( MeasuredSize.StateType width, MeasuredSize.StateType height)
+ {
+ widthState = width;
+ heightState = height;
+ }
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(AbsoluteLayout obj)
+ /// <summary>
+ /// [Draft] Constructor
+ /// </summary>
+ public AbsoluteLayout()
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
- protected override void Dispose(DisposeTypes type)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- if (disposed)
- {
- return;
- }
+ Log.Info("NUI", "Measuring[" + _children.Count + "] child(ren)\n");
+ float totalHeight = 0.0f;
+ float totalWidth = 0.0f;
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
+ HeightAndWidthState childState = new HeightAndWidthState(MeasuredSize.StateType.MeasuredSizeOK,
+ MeasuredSize.StateType.MeasuredSizeOK);
- }
+ float minPositionX = 0.0f;
+ float minPositionY = 0.0f;
+ float maxPositionX = 0.0f;
+ float maxPositionY = 0.0f;
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ // measure children
+ foreach( LayoutItem childLayout in _children )
{
- if (swigCMemOwn)
+ if (childLayout != null)
{
- swigCMemOwn = false;
- Interop.AbsoluteLayout.delete_AbsoluteLayout(swigCPtr);
+ // Get size of child
+ MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+ float childWidth = childLayout.MeasuredWidth.Size.AsDecimal();
+ float childHeight = childLayout.MeasuredHeight.Size.AsDecimal();
+
+ // Determine the width and height needed by the children using their given position and size.
+ // Children could overlap so find the left most and right most child.
+ Position2D childPosition = childLayout.Owner.Position2D;
+ float childLeft = childPosition.X;
+ float childTop = childPosition.Y;
+
+ minPositionX = Math.Min( minPositionX, childLeft );
+ maxPositionX = Math.Max( maxPositionX, childLeft + childWidth );
+ // Children could overlap so find the highest and lowest child.
+ minPositionY = Math.Min( minPositionY, childTop );
+ maxPositionY = Math.Max( maxPositionY, childTop + childHeight );
+
+ // Store current width and height needed to contain all children.
+ totalWidth = maxPositionX - minPositionX;
+ totalHeight = maxPositionY - minPositionY;
+ Log.Info( "NUI" , "AbsoluteLayout::OnMeasure child width(" + childWidth + ") height(" + childHeight + ")\n" );
+
+ if (childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.widthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+ if (childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
}
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
- base.Dispose(type);
- }
- /// <summary>
- /// [Draft] Creates a AbsoluteLayout object.
- /// </summary>
- public AbsoluteLayout() : this(Interop.AbsoluteLayout.AbsoluteLayout_New(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ Log.Info( "NUI" , "AbsoluteLayout::OnMeasure total width(" + totalWidth + ") total height(" + totalHeight + ")\n" );
- /// <summary>
- /// [Draft] Downcasts a handle to a AbsoluteLayout handle.
- /// If handle points to a AbsoluteLayout, the downcast produces a valid handle.
- /// If not, the returned handle is left uninitialized.
- /// </summary>
- /// <param name="handle">handle to an object</param>
- /// <returns>Handle to a AbsoluteLayout or an uninitialized handle</returns>
- internal static AbsoluteLayout DownCast(BaseHandle handle)
- {
- AbsoluteLayout ret = new AbsoluteLayout(Interop.AbsoluteLayout.AbsoluteLayout_DownCast(BaseHandle.getCPtr(handle)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ MeasuredSize widthSizeAndState = ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
+ MeasuredSize heightSizeAndState = ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
+ totalWidth = widthSizeAndState.Size.AsDecimal();
+ totalHeight = heightSizeAndState.Size.AsDecimal();
- /// <summary>
- /// [Draft] Copy constructor
- /// </summary>
- /// <param name="other"></param>
- internal AbsoluteLayout(AbsoluteLayout other) : this(Interop.AbsoluteLayout.new_AbsoluteLayout__SWIG_1(AbsoluteLayout.getCPtr(other)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ // Ensure layout respects it's given minimum size
+ totalWidth = Math.Max( totalWidth, SuggestedMinimumWidth.AsDecimal() );
+ totalHeight = Math.Max( totalHeight, SuggestedMinimumHeight.AsDecimal() );
- internal AbsoluteLayout Assign(AbsoluteLayout other)
- {
- AbsoluteLayout ret = new AbsoluteLayout(Interop.AbsoluteLayout.AbsoluteLayout_Assign(swigCPtr, AbsoluteLayout.getCPtr(other)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ widthSizeAndState.State = childState.widthState;
+ heightSizeAndState.State = childState.heightState;
+
+ SetMeasuredDimensions( ResolveSizeAndState( new LayoutLength(totalWidth), widthMeasureSpec, childState.widthState ),
+ ResolveSizeAndState( new LayoutLength(totalHeight), heightMeasureSpec, childState.heightState ) );
}
- internal enum PropertyRange
+ protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- CHILD_PROPERTY_START_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX,
- CHILD_PROPERTY_END_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000
- }
+ // Absolute layout positions it's children at their Actor positions.
+ // Children could overlap or spill outside the parent, as is the nature of absolute positions.
+ foreach( LayoutItem childLayout in _children )
+ {
+ if( childLayout != null )
+ {
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+
+ Position2D childPosition = childLayout.Owner.Position2D;
+ LayoutLength childLeft = new LayoutLength(childPosition.X);
+ LayoutLength childTop = new LayoutLength(childPosition.Y);
+
+ Log.Info("NUI", "Child View:" + childLayout.Owner.Name
+ + " position(" + childLeft.AsRoundedValue() + ", "
+ + childTop.AsRoundedValue() + ") width:"
+ + childWidth.AsRoundedValue() + " height:"
+ + childHeight.AsRoundedValue() + "\n");
+
+ childLayout.Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
+ }
+ }
+ }
}
-}
+} // namespace
+++ /dev/null
-/* Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System.ComponentModel;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// [Draft] This class implements a flex layout.
- /// The flex layout implementation is based on open source Facebook Yoga layout engine.
- /// For more information about the flex layout API and how to use it please refer to https://yogalayout.com/docs/
- /// We implement the subset of the API in the class below.
- /// </summary>
- internal class FlexLayout : LayoutGroupWrapper
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal FlexLayout(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.FlexLayout.FlexLayout_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FlexLayout obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.FlexLayout.delete_FlexLayout(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- base.Dispose(type);
- }
-
- /// <summary>
- /// [Draft] Creates a FlexLayout object.
- /// </summary>
- public FlexLayout() : this(Interop.FlexLayout.FlexLayout_New(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal static FlexLayout DownCast(BaseHandle handle)
- {
- FlexLayout ret = new FlexLayout(Interop.FlexLayout.FlexLayout_DownCast(BaseHandle.getCPtr(handle)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal FlexLayout(FlexLayout other) : this(Interop.FlexLayout.new_FlexLayout__SWIG_1(FlexLayout.getCPtr(other)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout Assign(FlexLayout other)
- {
- FlexLayout ret = new FlexLayout(Interop.FlexLayout.FlexLayout_Assign(swigCPtr, FlexLayout.getCPtr(other)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetFlexDirection(FlexLayout.FlexDirection flexDirection)
- {
- Interop.FlexLayout.FlexLayout_SetFlexDirection(swigCPtr, (int)flexDirection);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout.FlexDirection GetFlexDirection()
- {
- FlexLayout.FlexDirection ret = (FlexLayout.FlexDirection)Interop.FlexLayout.FlexLayout_GetFlexDirection(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetFlexJustification(FlexLayout.FlexJustification flexJustification)
- {
- Interop.FlexLayout.FlexLayout_SetFlexJustification(swigCPtr, (int)flexJustification);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout.FlexJustification GetFlexJustification()
- {
- FlexLayout.FlexJustification ret = (FlexLayout.FlexJustification)Interop.FlexLayout.FlexLayout_GetFlexJustification(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetFlexWrap(FlexLayout.FlexWrapType flexWrap)
- {
- Interop.FlexLayout.FlexLayout_SetFlexWrap(swigCPtr, (int)flexWrap);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout.FlexWrapType GetFlexWrap()
- {
- FlexLayout.FlexWrapType ret = (FlexLayout.FlexWrapType)Interop.FlexLayout.FlexLayout_GetFlexWrap(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetFlexAlignment(FlexLayout.AlignmentType flexAlignment)
- {
- Interop.FlexLayout.FlexLayout_SetFlexAlignment(swigCPtr, (int)flexAlignment);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout.AlignmentType GetFlexAlignment()
- {
- FlexLayout.AlignmentType ret = (FlexLayout.AlignmentType)Interop.FlexLayout.FlexLayout_GetFlexAlignment(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetFlexItemsAlignment(FlexLayout.AlignmentType flexAlignment)
- {
- Interop.FlexLayout.FlexLayout_SetFlexItemsAlignment(swigCPtr, (int)flexAlignment);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal FlexLayout.AlignmentType GetFlexItemsAlignment()
- {
- FlexLayout.AlignmentType ret = (FlexLayout.AlignmentType)Interop.FlexLayout.FlexLayout_GetFlexItemsAlignment(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal enum PropertyRange
- {
- CHILD_PROPERTY_START_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX,
- CHILD_PROPERTY_END_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000
- }
-
- internal new class ChildProperty
- {
- internal static readonly int FLEX = Interop.FlexLayout.FlexLayout_ChildProperty_FLEX_get();
- internal static readonly int ALIGN_SELF = Interop.FlexLayout.FlexLayout_ChildProperty_ALIGN_SELF_get();
- }
-
- /// <summary>
- /// [Draft] Get/Set the flex direction in the layout.
- /// The direction of the main-axis which determines the direction that flex items are laid out.
- /// </summary>
- public FlexDirection Direction
- {
- get
- {
- return GetFlexDirection();
- }
- set
- {
- SetFlexDirection(value);
- }
- }
-
- /// <summary>
- /// [Draft] Get/Set the justification in the layout.
- /// </summary>
- public FlexJustification Justification
- {
- get
- {
- return GetFlexJustification();
- }
- set
- {
- SetFlexJustification(value);
- }
- }
-
- /// <summary>
- /// [Draft] Get/Set the wrap in the layout.
- /// </summary>
- public FlexWrapType WrapType
- {
- get
- {
- return GetFlexWrap();
- }
- set
- {
- SetFlexWrap(value);
- }
- }
-
- /// <summary>
- /// [Draft] Get/Set the alignment of the layout content.
- /// </summary>
- public AlignmentType Alignment
- {
- get
- {
- return GetFlexAlignment();
- }
- set
- {
- SetFlexAlignment(value);
- }
- }
-
- /// <summary>
- /// [Draft] Get/Set the alignment of the layout items.
- /// </summary>
- public AlignmentType ItemsAlignment
- {
- get
- {
- return GetFlexItemsAlignment();
- }
- set
- {
- SetFlexItemsAlignment(value);
- }
- }
-
- /// <summary>
- /// [Draft] Enumeration for the direction of the main axis in the flex container.
- /// This determines the direction that flex items are laid out in the flex container.
- /// </summary>
- public enum FlexDirection
- {
- /// <summary>
- /// The flexible items are displayed vertically as a column
- /// </summary>
- Column,
- /// <summary>
- /// The flexible items are displayed vertically as a column, but in reverse order
- /// </summary>
- ColumnReverse,
- /// <summary>
- /// The flexible items are displayed horizontally as a row
- /// </summary>
- Row,
- /// <summary>
- /// The flexible items are displayed horizontally as a row, but in reverse order
- /// </summary>
- RowReverse
- }
-
- /// <summary>
- /// [Draft] Enumeration for the alignment of the flex items when the items do not use all available space on the main-axis.
- /// </summary>
- public enum FlexJustification
- {
- /// <summary>
- /// Items are positioned at the beginning of the container
- /// </summary>
- FlexStart,
- /// <summary>
- /// Items are positioned at the center of the container
- /// </summary>
- Center,
- /// <summary>
- /// Items are positioned at the end of the container
- /// </summary>
- FlexEnd,
- /// <summary>
- /// Items are positioned with equal space between the lines
- /// </summary>
- SpaceBetween,
- /// <summary>
- /// Items are positioned with equal space before, between, and after the lines
- /// </summary>
- SpaceAround
- }
-
- /// <summary>
- /// [Draft] Enumeration for the wrap type of the flex container when there is no enough room for all the items on one flex line.
- /// </summary>
- public enum FlexWrapType
- {
- /// <summary>
- /// Flex items laid out in single line (shrunk to fit the flex container along the main axis)
- /// </summary>
- NoWrap,
- /// <summary>
- /// Flex items laid out in multiple lines if needed
- /// </summary>
- Wrap
- }
-
- /// <summary>
- /// [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.
- /// </summary>
- public enum AlignmentType
- {
- /// <summary>
- /// Inherits the same alignment from the parent (only valid for "alignSelf" property)
- /// </summary>
- Auto,
- /// <summary>
- /// At the beginning of the container
- /// </summary>
- FlexStart,
- /// <summary>
- /// At the center of the container
- /// </summary>
- Center,
- /// <summary>
- /// At the end of the container
- /// </summary>
- FlexEnd,
- /// <summary>
- /// Stretch to fit the container
- /// </summary>
- Stretch
- }
- }
-}
-/* Copyright (c) 2018 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
.*
.* Licensed under the Apache License, Version 2.0 (the "License");
.* you may not use this file except in compliance with the License.
.*
.*/
+using System;
using System.ComponentModel;
+using System.Collections.Generic;
+using Tizen.NUI.BaseComponents;
namespace Tizen.NUI
{
/// <summary>
/// [Draft] This class implements a grid layout
/// </summary>
- internal class GridLayout : LayoutGroupWrapper
+ internal class GridLayout : LayoutGroup
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ const int AUTO_FIT = -1;
+ private int _columns = 1;
+ private int _rows = 1;
+ private int _totalWidth;
+ private int _totalHeight;
+ private int _requestedColumnWidth = 1;
+ private int _numberOfRequestedColumns;
+ private GridLocations _locations;
/// <summary>
- /// [draft] Internal contstructor/>
- /// </summary>
- /// <param name="cPtr"> object to get handle to.</param>
- /// <param name="cMemoryOwn"> flag to indicate if memory is owned.</param>
- internal GridLayout(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.GridLayout.GridLayout_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- /// <summary>
- /// [draft] Get C pointer for the GridLayout/>
+ /// [draft] GridLayout Constructor/>
/// </summary>
- /// <param name="obj"> object to get handle to.</param>
- /// <returns>Handle to the managed C class.</returns>
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GridLayout obj)
+ /// <returns> New Grid object.</returns>
+ public GridLayout()
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ _locations = new GridLocations();
}
- /// <summary>
- /// [draft] Dispose/>
- /// </summary>
- /// <param name="type"> Type of disposal.</param>
- protected override void Dispose(DisposeTypes type)
+ // <summary>
+ // [Draft] Get/Set the number of columns in the grid
+ // </summary>
+ public int Columns
{
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
+ get
{
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
+ return GetColumns();
}
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ set
{
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.GridLayout.delete_GridLayout(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ SetColumns(value);
}
- base.Dispose(type);
}
- /// <summary>
- /// [draft] GridLayout Constructor/>
- /// </summary>
- /// <returns> New Grid object.</returns>
- public GridLayout() : this(Interop.GridLayout.GridLayout_New(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
/// <summary>
- /// [draft] Downcast/>
+ /// [draft ] Sets the number of columns the GridLayout should have. />
/// </summary>
- /// <param name="handle">Handle to the given object that maybe be a GridLayout.</param>
- /// <returns>Grid object if Downcase possible.</returns>
- public static GridLayout DownCast(BaseHandle handle)
+ /// <param name="columns">The number of columns.</param>
+ internal void SetColumns(int columns)
{
- GridLayout ret = new GridLayout(Interop.GridLayout.GridLayout_DownCast(BaseHandle.getCPtr(handle)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ _numberOfRequestedColumns = columns;
+ if( columns != _columns)
+ {
+ _columns = Math.Max(1, _columns);
+ _columns = columns;
+ RequestLayout();
+ }
}
/// <summary>
- /// [draft] Copy of a Gridlayout to another GridLayout />
+ /// [draft ] Gets the number of columns in the Grid />
/// </summary>
- /// <param name="other">Copy the given Grid object to another Grid object.</param>
- /// <returns>The newly created Grid object.</returns>
- internal GridLayout(GridLayout other) : this(Interop.GridLayout.new_GridLayout_SWIG_1(GridLayout.getCPtr(other)), true)
+ /// <returns>The number of columns in the Grid.</returns>
+ internal int GetColumns()
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return _columns;
}
- /// <summary>
- /// [draft] Assignment of a Gridlayout to another GridLayout />
- /// </summary>
- /// <param name="other">Assign the given Grid object to another Grid object.</param>
- /// <returns>The newly assigned Grid object.</returns>
- internal GridLayout Assign(GridLayout other)
+ void DetermineNumberOfColumns( int availableSpace )
{
- GridLayout ret = new GridLayout(Interop.GridLayout.GridLayout_Assign(swigCPtr, GridLayout.getCPtr(other)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ if( _numberOfRequestedColumns == AUTO_FIT )
+ {
+ if( availableSpace > 0 )
+ {
+ // Can only calculate number of columns if a column width has been set
+ _columns = ( _requestedColumnWidth > 0 ) ? ( availableSpace / _requestedColumnWidth ) : 1;
+ }
+ }
}
- /// <summary>
- /// [draft ] Sets the number of columns the GridLayout should have. />
- /// </summary>
- /// <param name="columns">The nunber of columns.</param>
- internal void SetColumns(int columns)
+ protected override void OnMeasure( MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec )
{
- Interop.GridLayout.GridLayout_SetColumns(swigCPtr, columns);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ var gridWidthMode = widthMeasureSpec.Mode;
+ var gridHeightMode = heightMeasureSpec.Mode;
+ int widthSize = (int)widthMeasureSpec.Size.AsRoundedValue();
+ int heightSize = (int)heightMeasureSpec.Size.AsRoundedValue();
- /// <summary>
- /// [draft ] Gets the number of columns in the Grid />
- /// </summary>
- /// <returns>The number of coulumns in the Grid.</returns>
- internal int GetColumns()
- {
- int ret = (int)Interop.GridLayout.GridLayout_GetColumns(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ int availableContentWidth;
+ int availableContentHeight;
+
+ int desiredChildHeight;
+ int desiredChildWidth;
+
+ Extents gridLayoutPadding = Owner.Padding;
+
+ var childCount = _children.Count;
+
+ // WIDTH SPECIFICATIONS
+
+ // measure first child and use it's dimensions for layout measurement
+
+ if (childCount > 0)
+ {
+ LayoutItem childLayoutItem = _children[0];
+ View childOwner = childLayoutItem.Owner;
+
+ MeasureChild( childLayoutItem, widthMeasureSpec, heightMeasureSpec );
+ desiredChildHeight = (int)childLayoutItem.MeasuredHeight.Size.AsRoundedValue();
+ desiredChildWidth = (int)childLayoutItem.MeasuredWidth.Size.AsRoundedValue();
+
+ // If child has a margin then add it to desired size
+ Extents childMargin = childOwner.Margin;
+ desiredChildHeight += childMargin.Top + childMargin.Bottom;
+ desiredChildWidth += childMargin.Start + childMargin.End;
+
+ _totalWidth = desiredChildWidth * _columns;
+ Log.Info("NUI", "Grid::OnMeasure TotalDesiredWidth(" + _totalWidth + ") \n" );
+
+ // Include padding for max and min checks
+ _totalWidth += gridLayoutPadding.Start + gridLayoutPadding.End;
+
+ // Ensure width does not exceed specified at most width or less than mininum width
+ _totalWidth = Math.Max( _totalWidth, (int)SuggestedMinimumWidth.AsRoundedValue() );
+
+ // widthMode EXACTLY so grid must be the given width
+ if( gridWidthMode == MeasureSpecification.ModeType.Exactly || gridWidthMode == MeasureSpecification.ModeType.AtMost )
+ {
+ // In the case of AT_MOST, widthSize is the max limit.
+ _totalWidth = Math.Min( _totalWidth, widthSize );
+ }
+
+ availableContentWidth = _totalWidth - gridLayoutPadding.Start - gridLayoutPadding.End;
+ widthSize = _totalWidth;
+
+ Log.Info("NUI", "Grid::OnMeasure availableContentWidth:" + availableContentWidth + " TotalWidth(" + _totalWidth + ") \n" );
+ // HEIGHT SPECIFICATIONS
+
+ // heightMode EXACTLY so grid must be the given height
+ if( gridHeightMode == MeasureSpecification.ModeType.Exactly || gridHeightMode == MeasureSpecification.ModeType.AtMost )
+ {
+ if( childCount > 0 )
+ {
+ _totalHeight = gridLayoutPadding.Top + gridLayoutPadding.Bottom;
+
+ for( int i = 0; i < childCount; i += _columns )
+ {
+ _totalHeight += desiredChildHeight;
+ }
+ Log.Info( "NUI", "Grid::OnMeasure TotalDesiredHeight(" + _totalHeight + ") \n" );
+
+ // Ensure ourHeight does not exceed specified at most height
+ _totalHeight = Math.Min( _totalHeight, heightSize );
+ _totalHeight = Math.Max( _totalHeight, (int)SuggestedMinimumHeight.AsRoundedValue() );
+
+ heightSize = _totalHeight;
+ } // Child exists
+
+ // In the case of AT_MOST, availableContentHeight is the max limit.
+ availableContentHeight = heightSize - gridLayoutPadding.Top - gridLayoutPadding.Bottom;
+ }
+ else
+ {
+ // Grid expands to fit content
+
+ // If number of columns AUTO_FIT then set to 1 column.
+ _columns = ( _columns > 0 ) ? _columns : 1;
+ // Calculate numbers of rows, round down result as later check for remainder.
+ _rows = childCount / _columns;
+ // If number of cells not cleanly dividable by columns, add another row to house remainder cells.
+ _rows += ( childCount % _columns > 0 ) ? 1 : 0;
+
+ availableContentHeight = desiredChildHeight * _rows;
+ }
+
+ // If number of columns not defined
+ DetermineNumberOfColumns( availableContentWidth );
+
+ // Locations define the start, end,top and bottom of each cell.
+ _locations.CalculateLocations(_columns, availableContentWidth, availableContentHeight, childCount);
+
+ } // Children exists
+
+ SetMeasuredDimensions( ResolveSizeAndState( new LayoutLength(widthSize), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK ),
+ ResolveSizeAndState( new LayoutLength(heightSize), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK ) );
}
- // <summary>
- // [Draft] Get/Set the number of columns in the grid
- // </summary>
- public int Columns
+ protected override void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
{
- get
+ List<GridLocations.Cell> locations = _locations.GetLocations();
+
+ Extents gridLayoutPadding = Owner.Padding;
+ Extents childMargins = new Extents();
+
+ // Margin for all children dependant on if set on first child
+ if( _children.Count > 0 )
{
- return GetColumns();
+ childMargins = _children[0]?.Owner?.Margin;
}
- set
+
+ int index = 0;
+ foreach( LayoutItem childLayout in _children )
{
- SetColumns(value);
+ // for each child
+ if( childLayout != null )
+ {
+ // Get start and end position of child x1,x2
+ int x1 = locations[ index ].Start;
+ int x2 = locations[ index ].End;
+
+ // Get top and bottom position of child y1,y2
+ int y1 = locations[ index ].Top;
+ int y2 = locations[ index ].Bottom;
+
+ Log.Info("NUI", "CellSize(" + (x2-x1) + "," + (y2-y1) +
+ ") CellPos(" + x1 + "," + y1 + "," + x2 + "," + y2 +")\n");
+
+ // Offset children by the grids padding if present
+ x1 += gridLayoutPadding.Start;
+ x2 += gridLayoutPadding.Start;
+ y1 += gridLayoutPadding.Top;
+ y2 += gridLayoutPadding.Top;
+
+ // Offset children by the margin of the first child ( if required ).
+ x1 += childMargins.Start;
+ x2 -= childMargins.End;
+ y1 += childMargins.Top;
+ y2 -= childMargins.Bottom;
+
+ childLayout.Layout( new LayoutLength(x1), new LayoutLength(y1),
+ new LayoutLength(x2), new LayoutLength(y2) );
+ index++;
+ }
}
}
}
-
}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// [Draft] This internal class houses the algorithm for computing the locations and size of cells.
+ /// </summary>
+ internal class GridLocations
+ {
+ /// <summary>
+ /// A struct holding the 4 points which make up a cell.
+ /// </summary>
+ public struct Cell
+ {
+ public int Start;
+ public int End;
+ public int Top;
+ public int Bottom;
+
+ /// <summary>
+ /// Initialize a cell with the given points.
+ /// </summary>
+ /// <param name="start">The start x coordinate.</param>
+ /// <param name="end">The end x coordinate.</param>
+ /// <param name="top">The top y coordinate.</param>
+ /// <param name="bottom">The bottom y coordinate.</param>
+
+ public Cell( int start, int end, int top, int bottom)
+ {
+ Start = start;
+ End = end;
+ Top = top;
+ Bottom = bottom;
+ }
+ };
+
+ private List<Cell> _locationsVector;
+
+ /// <summary>
+ /// [Draft]Constructor
+ /// </summary>
+ public GridLocations()
+ {
+ _locationsVector = new List<Cell>();
+ }
+
+ /// <summary>
+ /// Get locations vector with position of each cell and cell size.
+ /// </summary>
+ public List<Cell> GetLocations()
+ {
+ return _locationsVector;
+ }
+
+ /// <summary>
+ /// [Draft] Uses the given parameters to calculate the x,y coordinates of each cell and cell size.
+ /// </summary>
+ public void CalculateLocations( int numberOfColumns, int availableWidth,
+ int availableHeight, int numberOfCells)
+ {
+ numberOfColumns = Math.Max( numberOfColumns, 1 );
+ _locationsVector.Clear();
+
+ // Calculate width and height of columns and rows.
+
+ // Calculate numbers of rows, round down result as later check for remainder.
+ int remainder = 0;
+ int numberOfRows = Math.DivRem(numberOfCells,numberOfColumns, out remainder);
+ // If number of cells not cleanly dividable by columns, add another row to house remainder cells.
+ numberOfRows += (remainder > 0) ? 1:0;
+
+ // Rounding on column widths performed here,
+ // if visually noticeable then can divide the space explicitly between columns.
+ int columnWidth = availableWidth / numberOfColumns;
+
+ int rowHeight = availableHeight;
+
+ if( numberOfRows > 0 )
+ {
+ // Column height supplied so use this unless exceeds available height.
+ rowHeight = (availableHeight / numberOfRows);
+ }
+
+ Log.Info("NUI", "ColumnWidth[" + columnWidth + "] RowHeight[" +rowHeight + "] NumberOfRows["
+ + numberOfRows + "] NumberOfColumns[" + numberOfColumns +"]\n");
+
+ int y1 = 0;
+ int y2 = y1 + rowHeight;
+
+ // Calculate start, end, top and bottom coordinate of each cell.
+
+ // Iterate rows
+ for( var i = 0u; i < numberOfRows; i++ )
+ {
+ int x1 = 0;
+ int x2 = x1 + columnWidth;
+
+ // Iterate columns
+ for( var j = 0; j < numberOfColumns; j++ )
+ {
+ Cell cell = new Cell( x1, x2, y1, y2 );
+ _locationsVector.Add( cell );
+ // Calculate starting x and ending x position of each column
+ x1 = x2;
+ x2 = x2 + columnWidth;
+ }
+
+ // Calculate top y and bottom y position of each row.
+ y1 = y2;
+ y2 = y2 + rowHeight;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// [Draft]
+ /// Interface that defines a layout Parent. Enables a layout child to access methods on its parent, e.g. Remove (during unparenting)
+ /// </summary>
+ internal interface ILayoutParent
+ {
+
+ /// <summary>
+ /// Add this child to the parent.
+ /// </summary>
+ /// <param name="layoutItem">The layout child to add.</param>
+ void Add(LayoutItem layoutItem);
+
+ /// <summary>
+ /// Remove this child from the parent
+ /// </summary>
+ /// <param name="layoutItem">The layout child to add.</param>
+ void Remove(LayoutItem layoutItem);
+ }
+}
{
internal static partial class LayoutGroupWrapperImpl
{
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_LayoutGroupWrapperImpl")]
- public static extern global::System.IntPtr new_LayoutGroupWrapperImpl();
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_SWIGUpcast")]
- public static extern global::System.IntPtr LayoutGroupWrapperImpl_SWIGUpcast(global::System.IntPtr jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_Add")]
- public static extern uint LayoutGroupWrapperImpl_Add(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_Remove__SWIG_0")]
- public static extern void LayoutGroupWrapperImpl_Remove__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_Remove__SWIG_1")]
- public static extern void LayoutGroupWrapperImpl_Remove__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_RemoveAll")]
- public static extern void LayoutGroupWrapperImpl_RemoveAll(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GetChildCount")]
- public static extern uint LayoutGroupWrapperImpl_GetChildCount(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GetChildAt")]
- public static extern global::System.IntPtr LayoutGroupWrapperImpl_GetChildAt(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GetChildId")]
- public static extern uint LayoutGroupWrapperImpl_GetChildId(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GetChild")]
- public static extern global::System.IntPtr LayoutGroupWrapperImpl_GetChild(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_OnChildAdd")]
- public static extern void LayoutGroupWrapperImpl_OnChildAdd(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_OnChildAddSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_OnChildAddSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_OnChildRemove")]
- public static extern void LayoutGroupWrapperImpl_OnChildRemove(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_OnChildRemoveSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_OnChildRemoveSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GetChildMeasureSpec")]
- public static extern global::System.IntPtr LayoutGroupWrapperImpl_GetChildMeasureSpec(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_DoInitialize")]
- public static extern void LayoutGroupWrapperImpl_DoInitialize(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_DoInitializeSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_DoInitializeSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_DoRegisterChildProperties")]
- public static extern void LayoutGroupWrapperImpl_DoRegisterChildProperties(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_DoRegisterChildPropertiesSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_DoRegisterChildPropertiesSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GenerateDefaultChildPropertyValues")]
- public static extern void LayoutGroupWrapperImpl_GenerateDefaultChildPropertyValues(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_GenerateDefaultChildPropertyValuesSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_GenerateDefaultChildPropertyValuesSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChildren")]
- public static extern void LayoutGroupWrapperImpl_MeasureChildren(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChildrenSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_MeasureChildrenSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChild")]
- public static extern void LayoutGroupWrapperImpl_MeasureChild(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChildSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_MeasureChildSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChildWithMargins")]
- public static extern void LayoutGroupWrapperImpl_MeasureChildWithMargins(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, global::System.Runtime.InteropServices.HandleRef jarg6);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_MeasureChildWithMarginsSwigExplicitLayoutGroupWrapperImpl")]
- public static extern void LayoutGroupWrapperImpl_MeasureChildWithMarginsSwigExplicitLayoutGroupWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, global::System.Runtime.InteropServices.HandleRef jarg6);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutGroupWrapperImpl_director_connect")]
- public static extern void LayoutGroupWrapperImpl_director_connect(global::System.Runtime.InteropServices.HandleRef jarg1,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_0 delegate0,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_3 delegate3,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_4 delegate4,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_5 delegate5,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_6 delegate6,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_7 delegate7,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_8 delegate8,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_9 delegate9,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_10 delegate10,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_11 delegate11,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_12 delegate12,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_13 delegate13,
- Tizen.NUI.LayoutGroupWrapperImpl.SwigDelegateLayoutGroupWrapperImpl_14 delegate14);
-
}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tizen.NUI
-{
- internal static partial class Interop
- {
- internal static partial class LayoutItemWrapperImpl
- {
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_SWIGUpcast")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_SWIGUpcast(global::System.IntPtr jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_LayoutItemWrapperImpl")]
- public static extern global::System.IntPtr new_LayoutItemWrapperImpl();
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_New")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_New(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_Initialize")]
- public static extern void LayoutItemWrapperImpl_Initialize(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, string jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapper_GetImplementation")]
- public static extern global::System.IntPtr LayoutItemWrapper_GetImplementation(global::System.IntPtr jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetOwner")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetOwner(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_Unparent")]
- public static extern void LayoutItemWrapperImpl_Unparent(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_SetAnimateLayout")]
- public static extern void LayoutItemWrapperImpl_SetAnimateLayout(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_IsLayoutAnimated")]
- public static extern bool LayoutItemWrapperImpl_IsLayoutAnimated(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_Measure")]
- public static extern void LayoutItemWrapperImpl_Measure(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_Layout")]
- public static extern void LayoutItemWrapperImpl_Layout(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, global::System.Runtime.InteropServices.HandleRef jarg5);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetDefaultSize")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetDefaultSize(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetParent")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetParent(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetParentSwigExplicitLayoutItemWrapperImpl")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetParentSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_RequestLayout")]
- public static extern void LayoutItemWrapperImpl_RequestLayout(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_IsLayoutRequested")]
- public static extern bool LayoutItemWrapperImpl_IsLayoutRequested(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMeasuredWidth")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMeasuredWidth(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMeasuredHeight")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMeasuredHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMeasuredWidthAndState")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMeasuredWidthAndState(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMeasuredHeightAndState")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMeasuredHeightAndState(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetSuggestedMinimumWidth")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetSuggestedMinimumWidth(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetSuggestedMinimumHeight")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetSuggestedMinimumHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_SetMinimumWidth")]
- public static extern void LayoutItemWrapperImpl_SetMinimumWidth(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_SetMinimumHeight")]
- public static extern void LayoutItemWrapperImpl_SetMinimumHeight(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMinimumWidth")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMinimumWidth(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetMinimumHeight")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetMinimumHeight(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_GetPadding")]
- public static extern global::System.IntPtr LayoutItemWrapperImpl_GetPadding(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_SetMeasuredDimensions")]
- public static extern void LayoutItemWrapperImpl_SetMeasuredDimensions(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnUnparent")]
- public static extern void LayoutItemWrapperImpl_OnUnparent(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnUnparentSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnUnparentSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnRegisterChildProperties")]
- public static extern void LayoutItemWrapperImpl_OnRegisterChildProperties(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnRegisterChildPropertiesSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnRegisterChildPropertiesSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, string jarg2);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnMeasure")]
- public static extern void LayoutItemWrapperImpl_OnMeasure(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnMeasureSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnMeasureSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnLayout")]
- public static extern void LayoutItemWrapperImpl_OnLayout(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, global::System.Runtime.InteropServices.HandleRef jarg6);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnLayoutSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnLayoutSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, global::System.Runtime.InteropServices.HandleRef jarg5, global::System.Runtime.InteropServices.HandleRef jarg6);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnSizeChanged")]
- public static extern void LayoutItemWrapperImpl_OnSizeChanged(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnSizeChangedSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnSizeChangedSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnInitialize")]
- public static extern void LayoutItemWrapperImpl_OnInitialize(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_OnInitializeSwigExplicitLayoutItemWrapperImpl")]
- public static extern void LayoutItemWrapperImpl_OnInitializeSwigExplicitLayoutItemWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
-
-
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_LayoutItemWrapperImpl_director_connect")]
- public static extern void LayoutItemWrapperImpl_director_connect(global::System.Runtime.InteropServices.HandleRef jarg1, Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_0 delegate0,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_1 delegate1,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_2 delegate2,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_3 delegate3,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_4 delegate4,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_5 delegate5,
- Tizen.NUI.LayoutItemWrapperImpl.SwigDelegateLayoutItemWrapperImpl_6 delegate6);
-
- }
- }
-}
//A Flat to check if it is already disposed.
protected bool disposed = false;
-
+ private Window _window;
/// <summary>
/// Constructs a LayoutController which controls the measuring and layouting.<br />
+ /// <param name="window">Window attach this LayoutController to.</param>
/// </summary>
-
- public LayoutController()
+ public LayoutController(Window window)
{
global::System.IntPtr cPtr = Interop.LayoutController.LayoutController_New();
-
+ _window = window;
// Wrap cPtr in a managed handle.
unmanagedLayoutController = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
return Interop.LayoutController.LayoutController_GetId(unmanagedLayoutController);
}
+ /// <summary>
+ /// Request relayout of a LayoutItem and it's parent tree.
+ /// </summary>
+ /// <param name="layoutItem">LayoutItem that is required to be laid out again.</param>
+ public void RequestLayout(LayoutItem layoutItem)
+ {
+ // Go up the tree and mark all parents to relayout
+ ILayoutParent layoutParent = layoutItem.GetParent();
+ if (layoutParent != null)
+ {
+ LayoutGroup layoutGroup = layoutParent as LayoutGroup;
+ if(! layoutGroup.LayoutRequested)
+ {
+ layoutGroup.RequestLayout();
+ }
+ }
+ }
+
/// <summary>
/// Destructor which adds LayoutController to the Dispose queue.
/// </summary>
/// <summary>
/// Explict Dispose.
/// </summary>
-
public void Dispose()
{
Dispose(DisposeTypes.Explicit);
disposed = true;
}
+ // Traverse through children from the provided root.
+ // If a child has no layout but is a pure View then assign a default layout and continue traversal.
+ // If child has no layout and not a pure View then assign a LayoutItem that terminates the layouting (leaf),
+ private void AutomaticallyAssignLayouts(View rootNode)
+ {
+ for (uint i = 0; i < rootNode.ChildCount; i++)
+ {
+ View view = rootNode.GetChildAt(i);
+ if (rootNode.Layout == null )
+ {
+ if (rootNode.GetType() == typeof(View))
+ {
+ Log.Info("NUI", "Creating LayoutGroup for " + rootNode.Name + "\n");
+ rootNode.Layout = new LayoutGroup();
+ AutomaticallyAssignLayouts(rootNode);
+ }
+ else
+ {
+ Log.Info("NUI", "Creating LayoutItem for " + rootNode.Name + "\n");
+ rootNode.Layout = new LayoutItem();
+ }
+ }
+ }
+ }
+
+ // Traverse the tree looking for a root node that is a layout.
+ // Once found, it's children can be assigned Layouts and the Measure process started.
+ private void FindRootLayouts(View rootNode)
+ {
+ if (rootNode.Layout != null)
+ {
+ Log.Info("NUI", "Found root:" + rootNode.Name + "\n");
+ // rootNode has a layout, ensure all children have default layouts or layout items.
+ AutomaticallyAssignLayouts(rootNode);
+ // rootNode has a layout, start measuring and layouting from here.
+ MeasureAndLayout(rootNode);
+ }
+ else
+ {
+ // Search children of supplied node for a layout.
+ for (uint i = 0; i < rootNode.ChildCount; i++)
+ {
+ View view = rootNode.GetChildAt(i);
+ FindRootLayouts(view);
+ }
+ }
+ }
+
+ // Starts of the actual measuring and layouting from the given root node.
+ // Can be called from multiple starting roots but in series.
+ void MeasureAndLayout(View root)
+ {
+ if (root !=null)
+ {
+ // Get parent MeasureSpecification, this could be the Window or View with an exact size.
+ Container parentNode = root.GetParent();
+ Size2D rootSize;
+ Position2D rootPosition = root.Position2D;
+ View parentView = parentNode as View;
+ if (parentView)
+ {
+ // Get parent View's Size. If using Legacy size negotiation then should have been set already.
+ rootSize = new Size2D(parentView.Size2D.Width, parentView.Size2D.Height);
+ }
+ else
+ {
+ // Parent not a View so assume it's a Layer which is the size of the window.
+ rootSize = new Size2D(_window.Size.Width, _window.Size.Height);
+ }
+
+ Log.Info("NUI", "Root parent size(" + rootSize.Width + "," + rootSize.Height + ")\n");
+
+ // Determine measure specification for root.
+ // The root layout policy could be an exact size, be match parent or wrap children.
+ // If wrap children then at most it can be the root parent size.
+ // If match parent then should be root parent size.
+ // If exact then should be that size limited by the root parent size.
+
+ LayoutLength width = new LayoutLength(rootSize.Width);
+ LayoutLength height = new LayoutLength(rootSize.Height);
+ MeasureSpecification.ModeType widthMode = MeasureSpecification.ModeType.AtMost;
+ MeasureSpecification.ModeType heightMode = MeasureSpecification.ModeType.AtMost;
+
+ if (root.WidthSpecification >= 0 )
+ {
+ // exact size provided so match width exactly
+ width = new LayoutLength(root.WidthSpecification);
+ widthMode = MeasureSpecification.ModeType.Exactly;
+ }
+ else if (root.WidthSpecification == LayoutParamPolicies.MatchParent)
+ {
+ widthMode = MeasureSpecification.ModeType.Exactly;
+ }
+
+ if (root.HeightSpecification >= 0 )
+ {
+ // exact size provided so match height exactly
+ height = new LayoutLength(root.HeightSpecification);
+ heightMode = MeasureSpecification.ModeType.Exactly;
+ }
+ else if (root.HeightSpecification == LayoutParamPolicies.MatchParent)
+ {
+ heightMode = MeasureSpecification.ModeType.Exactly;
+ }
+
+ MeasureSpecification parentWidthSpecification =
+ new MeasureSpecification( width, widthMode);
+
+ MeasureSpecification parentHeightSpecification =
+ new MeasureSpecification( height, heightMode);
+
+ // Start at root with it's parent's widthSpecification and heightSpecification
+ MeasureHierarchy(root, parentWidthSpecification, parentHeightSpecification);
+
+ // Start at root which was just measured.
+ PerformLayout( root, new LayoutLength(rootPosition.X),
+ new LayoutLength(rootPosition.Y),
+ new LayoutLength(rootPosition.X) + root.Layout.MeasuredWidth.Size,
+ new LayoutLength(rootPosition.Y) + root.Layout.MeasuredHeight.Size );
+ }
+ }
+
/// <summary>
/// Entry point into the C# Layouting that starts the Processing
/// </summary>
private void Process(int id)
{
- NUILog.Debug("layoutController Process id:" + id );
+ Log.Info("NUI", "LayoutController Process id:" + id + "\n");
+
+ Layer defaultLayer = _window.GetDefaultLayer();
+ for (uint i = 0; i < defaultLayer.ChildCount; i++)
+ {
+ View view = defaultLayer.GetChildAt(i);
+ FindRootLayouts(view);
+ }
}
+ /// <summary>
+ /// Starts measuring the tree, starting from the root layout.
+ /// </summary>
+ private void MeasureHierarchy(View root, MeasureSpecification widthSpec, MeasureSpecification heightSpec)
+ {
+ // Does this View have a layout?
+ // Yes - measure the layout. It will call this method again for each of it's children.
+ // No - reached leaf or no layouts set
+ //
+ // If in a leaf View with no layout, it's natural size is bubbled back up.
+
+ if (root.Layout != null)
+ {
+ root.Layout.Measure(widthSpec, heightSpec);
+ }
+ }
+
+ /// <summary>
+ /// Performs the layouting positioning
+ /// </summary>
+ private void PerformLayout(View root, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
+ {
+ if(root.Layout != null)
+ {
+ root.Layout.Layout(left, top, right, bottom);
+ }
+ }
} // class LayoutController
} // namespace Tizen.NUI
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System.Collections.Generic;
+
+namespace Tizen.NUI
+{
+
+ /// <summary>
+ /// [Draft] Class to hold layout position data
+ /// </summary>
+ internal struct LayoutPositionData
+ {
+ /// <summary>
+ /// [Draft] Initialized constructor
+ /// </summary>
+ /// <param name="left">Left position.</param>
+ /// <param name="top">Top position.</param>
+ /// <param name="right">Right position.</param>
+ /// <param name="bottom">Bottom position.</param>
+ /// <param name="animated">If an animation is required to the given positions.</param>
+ public LayoutPositionData( float left, float top, float right, float bottom, bool animated )
+ {
+ _left = left;
+ _top = top;
+ _right = right;
+ _bottom = bottom;
+ _animated = animated;
+ }
+
+ private float _left;
+ private float _top;
+ private float _right;
+ private float _bottom;
+ private bool _animated;
+ };
+
+ /// <summary>
+ /// [Draft] Class to hold Layout data for each entity being laid out.
+ /// </summary>
+ internal class LayoutData
+ {
+ /// <summary>
+ /// [Draft] Constructor
+ /// </summary>
+ public LayoutData()
+ {
+ LayoutPositionDataList = new List<LayoutPositionData>();
+ }
+
+ private List<LayoutPositionData> layoutPositionDataList;
+
+ internal List<LayoutPositionData> LayoutPositionDataList { get => layoutPositionDataList; set => layoutPositionDataList = value; }
+ } // LayoutData
+
+} // namespace Tizen.NUI
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*
*/
-
+using System;
+using System.Collections.Generic;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
+using System.Linq;
namespace Tizen.NUI
{
/// <summary>
/// [Draft] LayoutGroup class providing container functionality.
/// </summary>
- internal class LayoutGroup : LayoutGroupWrapper
+ internal class LayoutGroup : LayoutItem, ILayoutParent
{
- public LayoutGroup() : base(new LayoutGroupWrapperImpl())
+ protected List<LayoutItem> _children{ get;} // Children of this LayoutGroup
+
+ /// <summary>
+ /// [Draft] Constructor
+ /// </summary>
+ public LayoutGroup()
{
- // Initialize delegates of LayoutItem
- LayoutItemInitialize(layoutGroupWrapperImpl);
+ _children = new List<LayoutItem>();
+ }
- layoutGroupWrapperImpl.OnMeasure = new LayoutGroupWrapperImpl.OnMeasureDelegate(OnMeasure);
- layoutGroupWrapperImpl.OnLayout = new LayoutGroupWrapperImpl.OnLayoutDelegate(OnLayout);
- layoutGroupWrapperImpl.OnSizeChanged = new LayoutGroupWrapperImpl.OnSizeChangedDelegate(OnSizeChanged);
- layoutGroupWrapperImpl.OnChildAdd = new LayoutGroupWrapperImpl.OnChildAddDelegate(OnChildAdd);
- layoutGroupWrapperImpl.OnChildRemove = new LayoutGroupWrapperImpl.OnChildRemoveDelegate(OnChildRemove);
- layoutGroupWrapperImpl.DoInitialize = new LayoutGroupWrapperImpl.DoInitializeDelegate(DoInitialize);
- layoutGroupWrapperImpl.DoRegisterChildProperties = new LayoutGroupWrapperImpl.DoRegisterChildPropertiesDelegate(DoRegisterChildProperties);
- layoutGroupWrapperImpl.MeasureChildren = new LayoutGroupWrapperImpl.MeasureChildrenDelegate(MeasureChildren);
- layoutGroupWrapperImpl.MeasureChild = new LayoutGroupWrapperImpl.MeasureChildDelegate(MeasureChild);
- layoutGroupWrapperImpl.MeasureChildWithMargins = new LayoutGroupWrapperImpl.MeasureChildWithMarginsDelegate(MeasureChildWithMargins);
+ /// <summary>
+ /// [Draft] Constructor setting the owner of this LayoutGroup.
+ /// </summary>
+ /// <param name="owner">Owning View of this layout, currently a View but may be extending for Windows/Layers.</param>
+ public LayoutGroup(View owner) : base(owner)
+ {
+ _children = new List<LayoutItem>();
+ }
+
+ /// <summary>
+ /// From ILayoutParent.<br />
+ /// </summary>
+ public virtual void Add(LayoutItem childLayout)
+ {
+ Log.Info("NUI","Add Layout:" + childLayout.Owner.Name + " to Layout:" + Owner.Name + "\n");
+ _children.Add(childLayout);
+ childLayout.SetParent(this);
+ OnChildAdd(childLayout);
+ RequestLayout();
}
/// <summary>
/// </summary>
public void RemoveAll()
{
- layoutGroupWrapperImpl.RemoveAll();
+ Log.Info("NUI","Removing:" + _children.Count + "\n");
+ foreach( LayoutItem childLayout in _children )
+ {
+ childLayout.Owner = null;
+ }
+ _children.Clear();
+ // todo ensure child LayoutItems are still not parented to this group.
+ RequestLayout();
}
/// <summary>
- /// Get the child layout id of the given child.<br />
+ /// From ILayoutParent
/// </summary>
- /// <param name="child">The given Layout child.</param>
- internal uint GetChildId(LayoutItemWrapperImpl child)
+ public virtual void Remove(LayoutItem layoutItem)
{
- return layoutGroupWrapperImpl.GetChildId(child);
+ foreach( LayoutItem childLayout in _children.ToList() )
+ {
+ if( childLayout == layoutItem )
+ {
+ childLayout.SetParent(null);
+ _children.Remove(childLayout);
+ }
+ }
+ RequestLayout();
+ }
+
+ private void AddChildToLayoutGroup(View child)
+ {
+ Log.Info("NUI", "Adding child View:" + child.Name + " to Layout:" + Owner?.Name + "\n");
+
+ // Only give children a layout if their parent is an explicit container or a pure View.
+ // Pure View meaning not derived from a View, e.g a Legacy container.
+ // layoutSet flag is true when the View became a layout using the set Layout API opposed to automatically due to it's parent.
+ // First time the set Layout API is used by any View the Window no longer has layoutingDisabled.
+
+ // If child already has a Layout then don't change it.
+ if (! View.layoutingDisabled && (null == child.Layout))
+ {
+ // Only wrap View with a Layout if a child a pure View or Layout explicitly set on this Layout
+ if ((true == Owner.layoutSet || GetType() == typeof(View)))
+ {
+ Log.Info("NUI", "Parent[" + Owner.Name + "] Layout set[" + Owner.layoutSet.ToString() + "] Pure View[" + (!Owner.layoutSet).ToString() + "]\n");
+ // If child of this layout is a pure View then assign it a LayoutGroup
+ // If the child is derived from a View then it may be a legacy or existing container hence will do layouting itself.
+ if (child.GetType() == typeof(View))
+ {
+ Log.Info("NUI", "Creating LayoutGroup for " + child.Name + "]\n");
+ child.Layout = new LayoutGroup();
+ }
+ else
+ {
+ // Adding child as a leaf, layouting will not propagate past this child.
+ // Legacy containers will be a LayoutItems too and layout their children how they wish.
+ Log.Info("NUI", "Creating LayoutItem for " + child.Name + "\n");
+ child.Layout = new LayoutItem();
+ }
+ }
+ }
+ else
+ {
+ // Add child layout to this LayoutGroup (Setting parent in the process)
+ if(child.Layout != null)
+ {
+ Add(child.Layout);
+ }
+ }
+ }
+
+ /// <summary>
+ /// If the child has a layout then it is removed from the parent layout.
+ /// </summary>
+ /// <param name="child">Child to remove.true</param>
+ private void RemoveChildFromLayoutGroup(View child)
+ {
+ Log.Info("NUI", "Removing child View:" + child.Name + " from Layout:" + Owner?.Name + "\n");
+
+ if(child.Layout != null)
+ {
+ Remove(child.Layout);
+ }
+ }
+
+ /// <summary>
+ /// Callback for View.ChildAdded event
+ /// </summary>
+ /// <param name="sender">The object triggering the event.</param>
+ /// <param name="childAddedEvent">Arguments from the event.</param>
+ void OnChildAddedToOwner(object sender, View.ChildAddedEventArgs childAddedEvent)
+ {
+ AddChildToLayoutGroup(childAddedEvent.Added);
+ }
+
+ /// <summary>
+ /// Callback for View.ChildRemoved event
+ /// </summary>
+ /// <param name="sender">The object triggering the event.</param>
+ /// <param name="childRemovedEvent">Arguments from the event.</param>
+ void OnChildRemovedFromOwner(object sender, View.ChildRemovedEventArgs childRemovedEvent)
+ {
+ RemoveChildFromLayoutGroup(childRemovedEvent.Removed);
}
/// <summary>
/// pass to a particular child. This method figures out the right MeasureSpec
/// for one dimension (height or width) of one child view.<br />
/// </summary>
- /// <param name="measureSpec">The requirements for this view.</param>
- /// <param name="padding">The padding of this view for the current dimension and margins, if applicable.</param>
- /// <param name="childDimension"> How big the child wants to be in the current dimension.</param>
+ /// <param name="parentMeasureSpec">The requirements for this view. MeasureSpecification.</param>
+ /// <param name="padding">The padding of this view for the current dimension and margins, if applicable. LayoutLength.</param>
+ /// <param name="childDimension"> How big the child wants to be in the current dimension. LayoutLength.</param>
/// <returns>a MeasureSpec for the child.</returns>
- public static LayoutMeasureSpec GetChildMeasureSpec(LayoutMeasureSpec measureSpec, LayoutLength padding, LayoutLength childDimension)
+ public static MeasureSpecification GetChildMeasureSpecification(MeasureSpecification parentMeasureSpec, LayoutLength padding, LayoutLength childDimension)
{
- return LayoutGroupWrapperImpl.GetChildMeasureSpec(measureSpec, padding, childDimension);
+ MeasureSpecification.ModeType specMode = parentMeasureSpec.Mode;
+ MeasureSpecification.ModeType resultMode = MeasureSpecification.ModeType.Unspecified;
+ LayoutLength resultSize = new LayoutLength(Math.Max( 0.0f, (parentMeasureSpec.Size.AsDecimal() - padding.AsDecimal() ) )); // reduce available size by the owners padding
+
+ switch( specMode )
+ {
+ // Parent has imposed an exact size on us
+ case MeasureSpecification.ModeType.Exactly:
+ {
+ if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Child wants to be our size. So be it.
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+ else if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.WrapContent)
+ {
+ // Child wants to determine its own size. It can't be
+ // bigger than us.
+ resultMode = MeasureSpecification.ModeType.AtMost;
+ }
+ else
+ {
+ resultSize = childDimension;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+
+ break;
+ }
+
+ // Parent has imposed a maximum size on us
+ case MeasureSpecification.ModeType.AtMost:
+ {
+ if (childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Child wants to be our size, but our size is not fixed.
+ // Constrain child to not be bigger than us.
+ resultMode = MeasureSpecification.ModeType.AtMost;
+ }
+ else if (childDimension.AsRoundedValue() == LayoutParamPolicies.WrapContent)
+ {
+ // Child wants to determine its own size. It can't be
+ // bigger than us.
+ resultMode = MeasureSpecification.ModeType.AtMost;
+ }
+ else
+ {
+ // Child wants a specific size... so be it
+ resultSize = childDimension + padding;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+
+ break;
+ }
+
+ // Parent asked to see how big we want to be
+ case MeasureSpecification.ModeType.Unspecified:
+ {
+
+ if ((childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent))
+ {
+ // Child wants to be our size... find out how big it should be
+ resultMode = MeasureSpecification.ModeType.Unspecified;
+ }
+ else if (childDimension.AsRoundedValue() == (LayoutParamPolicies.WrapContent))
+ {
+ // Child wants to determine its own size.... find out how big
+ // it should be
+ resultMode = MeasureSpecification.ModeType.Unspecified;
+ }
+ else
+ {
+ // Child wants a specific size... let him have it
+ resultSize = childDimension + padding;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+ break;
+ }
+ } // switch
+
+ Log.Info("NUI", "MeasureSpecification resultSize:" + resultSize.AsRoundedValue()
+ + " resultMode:" + resultMode + "\n");
+ return new MeasureSpecification( resultSize, resultMode );
}
/// <summary>
/// </summary>
/// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param>
/// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param>
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Log.Info("NUI", "OnMeasure\n");
- LayoutLength childWidth = new LayoutLength( 0 );
- LayoutLength childHeight = new LayoutLength( 0 );
-
- LayoutLength measuredWidth = childWidth;
- LayoutLength measuredHeight = childHeight;
+ LayoutLength measuredWidth = new LayoutLength(0.0f);
+ LayoutLength measuredHeight = new LayoutLength(0.0f);
- for( uint i = 0; i < ChildCount; ++i )
+ // Layout takes size of largest child width and largest child height dimensions
+ foreach( LayoutItem childLayout in _children )
{
- var childLayout = GetChildAt( i );
-
- if( childLayout )
+ if( childLayout != null )
{
MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
- childWidth = childLayout.MeasuredWidth;
- childHeight = childLayout.MeasuredHeight;
- // Layout takes size of largest width and height dimension of children
- measuredWidth.Value = System.Math.Max( measuredWidth.Value, childWidth.Value );
- measuredHeight.Value = System.Math.Max( measuredHeight.Value, childHeight.Value );
+ LayoutLength childWidth = new LayoutLength(childLayout.MeasuredWidth.Size);
+ LayoutLength childHeight = new LayoutLength( childLayout.MeasuredHeight.Size);
+ Extents childMargin = childLayout.Owner.Margin;
+ measuredWidth = new LayoutLength(Math.Max( measuredWidth.AsDecimal(), childWidth.AsDecimal() + childMargin.Start + childMargin.End));
+ measuredHeight = new LayoutLength(Math.Max( measuredHeight.AsDecimal(), childHeight.AsDecimal() + childMargin.Top + childMargin.Bottom));
}
}
- if( 0 == ChildCount )
+ if( 0 == _children.Count )
{
// Must be a leaf as has no children
measuredWidth = GetDefaultSize( SuggestedMinimumWidth, widthMeasureSpec );
measuredHeight = GetDefaultSize( SuggestedMinimumHeight, heightMeasureSpec );
}
- SetMeasuredDimensions( new MeasuredSize( measuredWidth ),
- new MeasuredSize( measuredHeight ) );
+ SetMeasuredDimensions( new MeasuredSize( measuredWidth, MeasuredSize.StateType.MeasuredSizeOK ),
+ new MeasuredSize( measuredHeight, MeasuredSize.StateType.MeasuredSizeOK ) );
}
/// <summary>
protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
Log.Info("NUI", "OnLayout\n");
- for( uint i = 0; i < ChildCount; ++i )
+ foreach( LayoutItem childLayout in _children )
{
- var childLayout = GetChildAt( i );
- if( childLayout )
+ if( childLayout !=null )
{
- View childOwner = childLayout.GetOwner();
-
// Use position if explicitly set to child otherwise will be top left.
- var childLeft = new LayoutLength( childOwner.Position2D.X );
- var childTop = new LayoutLength( childOwner.Position2D.Y );
+ var childLeft = new LayoutLength( childLayout.Owner.Position2D.X );
+ var childTop = new LayoutLength( childLayout.Owner.Position2D.Y );
- View owner = GetOwner();
+ View owner = Owner;
if ( owner )
{
// Margin and Padding only supported when child anchor point is TOP_LEFT.
if ( owner.PivotPoint == PivotPoint.TopLeft || ( owner.PositionUsesPivotPoint == false ) )
{
- childLeft = childLeft + owner.Padding.Start + childOwner.Margin.Start;
- childTop = childTop + owner.Padding.Top + childOwner.Margin.Top;
+ childLeft = childLeft + owner.Padding.Start + childLayout.Owner.Margin.Start;
+ childTop = childTop + owner.Padding.Top + childLayout.Owner.Margin.Top;
}
}
- childLayout.Layout( childLeft, childTop, childLeft + childLayout.MeasuredWidth, childTop + childLayout.MeasuredHeight );
+ childLayout.Layout( childLeft, childTop, childLeft + childLayout.MeasuredWidth.Size, childTop + childLayout.MeasuredHeight.Size );
}
}
}
/// <summary>
- /// Virtual method to inform derived classes when the layout size changed.<br />
+ /// Overridden method called when the layout size changes.<br />
/// </summary>
/// <param name="newSize">The new size of the layout.</param>
/// <param name="oldSize">The old size of the layout.</param>
protected override void OnSizeChanged(LayoutSize newSize, LayoutSize oldSize)
{
- //Do nothing
+ // Do nothing
}
/// <summary>
- /// Callback when child is added to container.<br />
- /// Derived classes can use this to set their own child properties on the child layout's owner.<br />
+ /// Overridden method called when the layout is attached to an owner.<br />
/// </summary>
- /// <param name="child">The Layout child.</param>
- internal virtual void OnChildAdd(LayoutItemWrapperImpl child)
+ protected override void OnAttachedToOwner()
{
- }
+ Log.Info("NUI", "Attaching to Owner:" + Owner.Name + "\n");
+ // Layout takes ownership of it's owner's children.
+ foreach (View view in Owner.Children)
+ {
+ AddChildToLayoutGroup(view);
+ }
- /// <summary>
- /// Callback when child is removed from container.<br />
- /// </summary>
- /// <param name="child">The Layout child.</param>
- internal virtual void OnChildRemove(LayoutItemWrapperImpl child)
- {
+ // Layout attached to owner so connect to ChildAdded and ChildRemoved signals.
+ Owner.ChildAdded += OnChildAddedToOwner;
+ Owner.ChildRemoved += OnChildRemovedFromOwner;
}
+ // Virtual Methods that can be overridden by derived classes.
+
/// <summary>
- /// Second stage initialization method for deriving classes to override.<br />
+ /// Callback when child is added to container.<br />
+ /// Derived classes can use this to set their own child properties on the child layout's owner.<br />
/// </summary>
- protected virtual void DoInitialize()
+ /// <param name="child">The Layout child.</param>
+ protected virtual void OnChildAdd(LayoutItem child)
{
}
/// <summary>
- /// Method for derived classes to implement in order to register child property types with the container.<br />
+ /// Callback when child is removed from container.<br />
/// </summary>
- /// <param name="containerType">The fully qualified typename of the container.</param>
- protected virtual void DoRegisterChildProperties(string containerType)
+ /// <param name="child">The Layout child.</param>
+ protected virtual void OnChildRemove(LayoutItem child)
{
}
/// </summary>
/// <param name="widthMeasureSpec">The width requirements for this view.</param>
/// <param name="heightMeasureSpec">The height requirements for this view.</param>
- protected virtual void MeasureChildren(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected virtual void MeasureChildren(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- layoutGroupWrapperImpl.MeasureChildrenNative(widthMeasureSpec, heightMeasureSpec);
+ foreach( LayoutItem childLayout in _children )
+ {
+ MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+ }
}
/// <summary>
/// <param name="child">The child to measure.</param>
/// <param name="parentWidthMeasureSpec">The width requirements for this view.</param>
/// <param name="parentHeightMeasureSpec">The height requirements for this view.</param>
- protected virtual void MeasureChild(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutMeasureSpec parentHeightMeasureSpec)
+ protected virtual void MeasureChild(LayoutItem child, MeasureSpecification parentWidthMeasureSpec, MeasureSpecification parentHeightMeasureSpec)
{
- layoutGroupWrapperImpl.MeasureChildNative(child, parentWidthMeasureSpec, parentHeightMeasureSpec);
+ View childOwner = child.Owner;
+ Log.Info("NUI", "LayoutGroup MeasureChild:" + childOwner.Name
+ + " child widthSpecification policy:" + childOwner.WidthSpecification
+ + " child heightSpecification policy:" + childOwner.HeightSpecification + "\n");
+
+ Extents padding = childOwner.Padding; // Padding of this layout's owner, not of the child being measured.
+
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification( parentWidthMeasureSpec,
+ new LayoutLength(padding.Start + padding.End ),
+ new LayoutLength(childOwner.WidthSpecification) );
+
+ MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification( parentHeightMeasureSpec,
+ new LayoutLength(padding.Top + padding.Bottom),
+ new LayoutLength(childOwner.HeightSpecification) );
+
+ child.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
}
/// <summary>
/// Ask one of the children of this view to measure itself, taking into
/// account both the MeasureSpec requirements for this view and its padding.<br />
/// and margins. The child must have MarginLayoutParams The heavy lifting is
- /// done in GetChildMeasureSpec.<br />
+ /// done in GetChildMeasureSpecification.<br />
/// </summary>
/// <param name="child">The child to measure.</param>
/// <param name="parentWidthMeasureSpec">The width requirements for this view.</param>
/// <param name="widthUsed">Extra space that has been used up by the parent horizontally (possibly by other children of the parent).</param>
/// <param name="parentHeightMeasureSpec">The height requirements for this view.</param>
/// <param name="heightUsed">Extra space that has been used up by the parent vertically (possibly by other children of the parent).</param>
- protected virtual void MeasureChildWithMargins(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed)
+ protected virtual void MeasureChildWithMargins(LayoutItem child, MeasureSpecification parentWidthMeasureSpec, LayoutLength widthUsed, MeasureSpecification parentHeightMeasureSpec, LayoutLength heightUsed)
{
- layoutGroupWrapperImpl.MeasureChildWithMarginsNative(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
+ View childOwner = child.Owner;
+ int desiredWidth = childOwner.WidthSpecification;
+ int desiredHeight = childOwner.HeightSpecification;
+
+ Extents padding = childOwner.Padding; // Padding of this layout's owner, not of the child being measured.
+
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification( parentWidthMeasureSpec,
+ new LayoutLength( padding.Start + padding.End ) +
+ widthUsed, new LayoutLength(desiredWidth) );
+
+
+ MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification( parentHeightMeasureSpec,
+ new LayoutLength( padding.Top + padding.Bottom )+
+ heightUsed, new LayoutLength(desiredHeight) );
+
+ child.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
}
}
}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- internal class LayoutGroupWrapper : LayoutItem
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- internal LayoutGroupWrapperImpl layoutGroupWrapperImpl;
-
- internal LayoutGroupWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LayoutGroupWrapper.LayoutGroupWrapper_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutGroupWrapper obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.LayoutGroupWrapper.delete_LayoutGroupWrapper(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- base.Dispose(type);
- }
-
- public new class ChildProperty
- {
- public static readonly int MARGIN_SPECIFICATION = Interop.LayoutGroupWrapper.LayoutGroupWrapper_ChildProperty_MARGIN_SPECIFICATION_get();
- }
-
- public LayoutGroupWrapper() : this(Interop.LayoutGroupWrapper.new_LayoutGroupWrapper__SWIG_0(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public LayoutGroupWrapper(LayoutGroupWrapper copy) : this(Interop.LayoutGroupWrapper.new_LayoutGroupWrapper__SWIG_1(LayoutGroupWrapper.getCPtr(copy)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public uint Add(LayoutItemWrapper childLayout)
- {
- uint ret = Interop.LayoutGroupWrapper.LayoutGroupWrapper_Add(swigCPtr, LayoutItemWrapper.getCPtr(childLayout));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- LayoutChildren.Add(childLayout);
- return ret;
- }
-
- public void Remove(uint childId)
- {
- Interop.LayoutGroupWrapper.LayoutGroupWrapper_Remove__SWIG_0(swigCPtr, childId);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public void Remove(LayoutItemWrapper childLayout)
- {
- Interop.LayoutGroupWrapper.LayoutGroupWrapper_Remove__SWIG_1(swigCPtr, LayoutItemWrapper.getCPtr(childLayout));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- LayoutChildren.Remove(childLayout);
- }
-
- public LayoutItem GetChildAt(uint index)
- {
- if(index >= 0 && index < LayoutChildren.Count)
- {
- LayoutItem layoutItem = LayoutChildren[Convert.ToInt32(index)] as LayoutItem;
- return layoutItem;
- }
- return null;
- }
-
- private uint GetChildCount()
- {
- return Convert.ToUInt32(LayoutChildren.Count);
- }
-
- public uint ChildCount
- {
- get
- {
- return GetChildCount();
- }
- }
-
- public LayoutItemWrapper GetChild(uint childId)
- {
- LayoutItemWrapper ret = new LayoutItemWrapper(Interop.LayoutGroupWrapper.LayoutGroupWrapper_GetChild(swigCPtr, childId), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutGroupWrapper(LayoutGroupWrapperImpl implementation) : this(Interop.LayoutGroupWrapper.new_LayoutGroupWrapper__SWIG_2(LayoutGroupWrapperImpl.getCPtr(implementation)), true)
- {
- layoutGroupWrapperImpl = implementation;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public static readonly uint UNKNOWN_ID = Interop.LayoutGroupWrapper.LayoutGroupWrapper_UNKNOWN_ID_get();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System;
-using Tizen.NUI.BaseComponents;
-using System.Runtime.InteropServices;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// Internal Layout class that all layout containers should derive from.
- /// Mirrors the native class LayoutGroup.
- /// </summary>
- internal class LayoutGroupWrapperImpl : LayoutItemWrapperImpl
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- public new delegate void OnMeasureDelegate(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec);
- public new delegate void OnLayoutDelegate(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom);
- public new delegate void OnSizeChangedDelegate(LayoutSize newSize, LayoutSize oldSize);
- public delegate void OnChildAddDelegate(LayoutItemWrapperImpl child);
- public delegate void OnChildRemoveDelegate(LayoutItemWrapperImpl child);
- public delegate void DoInitializeDelegate();
- public delegate void DoRegisterChildPropertiesDelegate(string containerType);
- public delegate void MeasureChildrenDelegate(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec);
- public delegate void MeasureChildDelegate(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutMeasureSpec parentHeightMeasureSpec);
- public delegate void MeasureChildWithMarginsDelegate(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed);
-
- public new OnMeasureDelegate OnMeasure;
- public new OnLayoutDelegate OnLayout;
- public new OnSizeChangedDelegate OnSizeChanged;
- public OnChildAddDelegate OnChildAdd;
- public OnChildRemoveDelegate OnChildRemove;
- public DoInitializeDelegate DoInitialize;
- public DoRegisterChildPropertiesDelegate DoRegisterChildProperties;
- public MeasureChildrenDelegate MeasureChildren;
- public MeasureChildDelegate MeasureChild;
- public MeasureChildWithMarginsDelegate MeasureChildWithMargins;
-
- internal LayoutGroupWrapperImpl(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutGroupWrapperImpl obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- public LayoutGroupWrapperImpl() : this(Interop.LayoutGroupWrapperImpl.new_LayoutGroupWrapperImpl(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- SwigDirectorConnect();
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- base.Dispose(type);
- }
-
- internal uint Add(LayoutItemWrapperImpl layoutChild)
- {
- uint ret = Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_Add(swigCPtr, LayoutItemWrapperImpl.getCPtr(layoutChild));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void Remove(uint childId)
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_Remove__SWIG_0(swigCPtr, childId);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void Remove(LayoutItemWrapperImpl child)
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_Remove__SWIG_1(swigCPtr, LayoutItemWrapperImpl.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void RemoveAll()
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_RemoveAll(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal uint GetChildCount()
- {
- uint ret = Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_GetChildCount(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutItem GetChildAt(uint childIndex)
- {
- IntPtr cPtr = Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_GetChildAt(swigCPtr, childIndex);
- HandleRef CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-
- global::System.IntPtr refObjectPtr = Interop.LayoutItemPtr.LayoutItemPtr_Get(CPtrHandleRef);
- LayoutItem ret = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as LayoutItem;
-
- Interop.LayoutItemPtr.delete_LayoutItemPtr(CPtrHandleRef);
- CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal uint GetChildId(LayoutItemWrapperImpl child)
- {
- uint ret = Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_GetChildId(swigCPtr, LayoutItemWrapperImpl.getCPtr(child));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutItem GetChild(uint childId)
- {
- IntPtr cPtr = Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_GetChild(swigCPtr, childId);
- HandleRef CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
-
- global::System.IntPtr refObjectPtr = Interop.LayoutItemPtr.LayoutItemPtr_Get(CPtrHandleRef);
- LayoutItem ret = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as LayoutItem;
-
- Interop.LayoutItemPtr.delete_LayoutItemPtr(CPtrHandleRef);
- CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal static LayoutMeasureSpec GetChildMeasureSpec(LayoutMeasureSpec measureSpec, LayoutLength padding, LayoutLength childDimension)
- {
- LayoutMeasureSpec ret = new LayoutMeasureSpec(Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_GetChildMeasureSpec(LayoutMeasureSpec.getCPtr(measureSpec), LayoutLength.getCPtr(padding), LayoutLength.getCPtr(childDimension)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal virtual void MeasureChildrenNative(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_MeasureChildrenSwigExplicitLayoutGroupWrapperImpl(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void MeasureChildNative(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutMeasureSpec parentHeightMeasureSpec)
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_MeasureChildSwigExplicitLayoutGroupWrapperImpl(swigCPtr, LayoutItem.getCPtr(child), LayoutMeasureSpec.getCPtr(parentWidthMeasureSpec), LayoutMeasureSpec.getCPtr(parentHeightMeasureSpec));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void MeasureChildWithMarginsNative(LayoutItem child, LayoutMeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, LayoutMeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed)
- {
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_MeasureChildWithMarginsSwigExplicitLayoutGroupWrapperImpl(swigCPtr, LayoutItem.getCPtr(child), LayoutMeasureSpec.getCPtr(parentWidthMeasureSpec), LayoutLength.getCPtr(widthUsed), LayoutMeasureSpec.getCPtr(parentHeightMeasureSpec), LayoutLength.getCPtr(heightUsed));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- private new void SwigDirectorConnect()
- {
- base.SwigDirectorConnect();
-
- //swigDelegate0 = new SwigDelegateLayoutGroupWrapperImpl_0(SwigDirectorGetParent);
- swigDelegate0 = null;
- swigDelegate3 = new SwigDelegateLayoutGroupWrapperImpl_3(SwigDirectorOnMeasure);
- swigDelegate4 = new SwigDelegateLayoutGroupWrapperImpl_4(SwigDirectorOnLayout);
- swigDelegate5 = new SwigDelegateLayoutGroupWrapperImpl_5(SwigDirectorOnSizeChanged);
- swigDelegate6 = null;
- swigDelegate7 = new SwigDelegateLayoutGroupWrapperImpl_7(SwigDirectorOnChildAdd);
- swigDelegate8 = new SwigDelegateLayoutGroupWrapperImpl_8(SwigDirectorOnChildRemove);
- swigDelegate9 = new SwigDelegateLayoutGroupWrapperImpl_9(SwigDirectorDoInitialize);
- swigDelegate10 = new SwigDelegateLayoutGroupWrapperImpl_10(SwigDirectorDoRegisterChildProperties);
- swigDelegate11 = null;
- swigDelegate12 = new SwigDelegateLayoutGroupWrapperImpl_12(SwigDirectorMeasureChildren);
- swigDelegate13 = new SwigDelegateLayoutGroupWrapperImpl_13(SwigDirectorMeasureChild);
- swigDelegate14 = new SwigDelegateLayoutGroupWrapperImpl_14(SwigDirectorMeasureChildWithMargins);
-
- Interop.LayoutGroupWrapperImpl.LayoutGroupWrapperImpl_director_connect(swigCPtr, swigDelegate0, swigDelegate3, swigDelegate4, swigDelegate5, swigDelegate6, swigDelegate7, swigDelegate8, swigDelegate9, swigDelegate10, swigDelegate11, swigDelegate12, swigDelegate13, swigDelegate14);
- }
-
- /*private global::System.IntPtr SwigDirectorGetParent()
- {
- return LayoutParent.getCPtr(GetParent()).Handle;
- }*/
-
- private void SwigDirectorOnMeasure(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec)
- {
- OnMeasure(new LayoutMeasureSpec(widthMeasureSpec, true), new LayoutMeasureSpec(heightMeasureSpec, true));
- }
-
- private void SwigDirectorOnLayout(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom)
- {
- OnLayout(changed, new LayoutLength(left, true), new LayoutLength(top, true), new LayoutLength(right, true), new LayoutLength(bottom, true));
- }
-
- private void SwigDirectorOnSizeChanged(global::System.IntPtr newSize, global::System.IntPtr oldSize)
- {
- OnSizeChanged(new LayoutSize(newSize, true), new LayoutSize(oldSize, true));
- }
-
- private void SwigDirectorOnChildAdd(global::System.IntPtr child)
- {
- OnChildAdd(new LayoutItemWrapperImpl(child, false));
- }
-
- private void SwigDirectorOnChildRemove(global::System.IntPtr child)
- {
- OnChildRemove(new LayoutItemWrapperImpl(child, false));
- }
-
- private void SwigDirectorDoInitialize()
- {
- DoInitialize();
- }
-
- private void SwigDirectorDoRegisterChildProperties(string containerType)
- {
- DoRegisterChildProperties(containerType);
- }
-
- private void SwigDirectorMeasureChildren(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec)
- {
- MeasureChildren(new LayoutMeasureSpec(widthMeasureSpec, true), new LayoutMeasureSpec(heightMeasureSpec, true));
- }
-
- private void SwigDirectorMeasureChild(global::System.IntPtr child, global::System.IntPtr parentWidthMeasureSpec, global::System.IntPtr parentHeightMeasureSpec)
- {
- HandleRef CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(this, child);
-
- global::System.IntPtr refObjectPtr = Interop.LayoutItemPtr.LayoutItemPtr_Get(CPtrHandleRef);
- LayoutItem layoutItem = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as LayoutItem;
-
- MeasureChild(layoutItem, new LayoutMeasureSpec(parentWidthMeasureSpec, true), new LayoutMeasureSpec(parentHeightMeasureSpec, true));
-
- Interop.LayoutItemPtr.delete_LayoutItemPtr(CPtrHandleRef);
- CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- private void SwigDirectorMeasureChildWithMargins(global::System.IntPtr child, global::System.IntPtr parentWidthMeasureSpec, global::System.IntPtr widthUsed, global::System.IntPtr parentHeightMeasureSpec, global::System.IntPtr heightUsed)
- {
- HandleRef CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(this, child);
-
- global::System.IntPtr refObjectPtr = Interop.LayoutItemPtr.LayoutItemPtr_Get(CPtrHandleRef);
- LayoutItem layoutItem = Registry.GetManagedBaseHandleFromRefObject(refObjectPtr) as LayoutItem;
-
- MeasureChildWithMargins(layoutItem, new LayoutMeasureSpec(parentWidthMeasureSpec, true), new LayoutLength(widthUsed, true), new LayoutMeasureSpec(parentHeightMeasureSpec, true), new LayoutLength(heightUsed, true));
-
- Interop.LayoutItemPtr.delete_LayoutItemPtr(CPtrHandleRef);
- CPtrHandleRef = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- public delegate global::System.IntPtr SwigDelegateLayoutGroupWrapperImpl_0();
- public delegate void SwigDelegateLayoutGroupWrapperImpl_3(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_4(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_5(global::System.IntPtr newSize, global::System.IntPtr oldSize);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_6();
- public delegate void SwigDelegateLayoutGroupWrapperImpl_7(global::System.IntPtr child);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_8(global::System.IntPtr child);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_9();
- public delegate void SwigDelegateLayoutGroupWrapperImpl_10(string containerType);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_11(global::System.IntPtr child);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_12(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_13(global::System.IntPtr child, global::System.IntPtr parentWidthMeasureSpec, global::System.IntPtr parentHeightMeasureSpec);
- public delegate void SwigDelegateLayoutGroupWrapperImpl_14(global::System.IntPtr child, global::System.IntPtr parentWidthMeasureSpec, global::System.IntPtr widthUsed, global::System.IntPtr parentHeightMeasureSpec, global::System.IntPtr heightUsed);
-
- private SwigDelegateLayoutGroupWrapperImpl_0 swigDelegate0;
- private SwigDelegateLayoutGroupWrapperImpl_3 swigDelegate3;
- private SwigDelegateLayoutGroupWrapperImpl_4 swigDelegate4;
- private SwigDelegateLayoutGroupWrapperImpl_5 swigDelegate5;
- private SwigDelegateLayoutGroupWrapperImpl_6 swigDelegate6;
- private SwigDelegateLayoutGroupWrapperImpl_7 swigDelegate7;
- private SwigDelegateLayoutGroupWrapperImpl_8 swigDelegate8;
- private SwigDelegateLayoutGroupWrapperImpl_9 swigDelegate9;
- private SwigDelegateLayoutGroupWrapperImpl_10 swigDelegate10;
- private SwigDelegateLayoutGroupWrapperImpl_11 swigDelegate11;
- private SwigDelegateLayoutGroupWrapperImpl_12 swigDelegate12;
- private SwigDelegateLayoutGroupWrapperImpl_13 swigDelegate13;
- private SwigDelegateLayoutGroupWrapperImpl_14 swigDelegate14;
- }
-} // namespace Tizen.NUI
\ No newline at end of file
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI
{
+
+ [FlagsAttribute]
+ enum LayoutFlags : short
+ {
+ None = 0,
+ ForceLayout = 1,
+ LayoutRequired = 2,
+ MeasuredDimensionSet = 4
+ };
+
/// <summary>
- /// [Draft] Base class for layouts. It is used to layout a control (or visual).
+ /// [Draft] Base class for layouts. It is used to layout a View
/// It can be laid out by a LayoutGroup.
/// </summary>
- internal class LayoutItem : LayoutItemWrapper
+ internal class LayoutItem
{
- //It is called by LayoutGroupWrapper constructor.
- internal LayoutItem(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ private MeasureSpecification OldWidthMeasureSpec; // Store measure specification to compare against later
+ private MeasureSpecification OldHeightMeasureSpec;// Store measure specification to compare against later
+
+ private LayoutFlags Flags = LayoutFlags.None;
+
+ private ILayoutParent Parent;
+
+ private LayoutLength _left;
+ private LayoutLength _right;
+ private LayoutLength _top;
+ private LayoutLength _bottom;
+ private LayoutData _layoutData;
+
+ /// <summary>
+ /// The View that this Layout has been assigned to.
+ /// </summary>
+ public View Owner{get; set;} // Should not keep a View alive.
+
+ /// <summary>
+ /// [Draft] Constructor
+ /// </summary>
+ public LayoutItem()
{
- System.IntPtr wrapperImpe_CPtr = Interop.LayoutItemWrapperImpl.LayoutItemWrapper_GetImplementation(cPtr);
- layoutItemWrapperImpl = new LayoutItemWrapperImpl(wrapperImpe_CPtr, true);
- LayoutItemInitialize(layoutItemWrapperImpl);
}
- public LayoutItem() : base(new LayoutItemWrapperImpl())
+ /// <summary>
+ /// [Draft] Constructor setting the owner of this LayoutItem.
+ /// </summary>
+ /// <param name="owner">Owning View of this layout, currently a View but may be extending for Windows/Layers.</param>
+ public LayoutItem(View owner)
{
- LayoutItemInitialize(layoutItemWrapperImpl);
+ Owner = owner;
+ _layoutData = new LayoutData();
+ _left = new LayoutLength(0);
+ _top = new LayoutLength(0);
+ _right = new LayoutLength(0);
+ _bottom = new LayoutLength(0);
}
- // This should be protected though but made internal because LayoutItemWrapperImpl is internal.
- internal void LayoutItemInitialize(LayoutItemWrapperImpl implementation)
+ /// <summary>
+ /// [Draft] Set parent to this layout.
+ /// </summary>
+ /// <param name="parent">Parent to set on this Layout.</param>
+ public void SetParent( ILayoutParent parent)
{
- layoutItemWrapperImpl = implementation;
- layoutItemWrapperImpl.OnMeasure = new LayoutItemWrapperImpl.OnMeasureDelegate(OnMeasure);
- layoutItemWrapperImpl.OnLayout = new LayoutItemWrapperImpl.OnLayoutDelegate(OnLayout);
- layoutItemWrapperImpl.OnSizeChanged = new LayoutItemWrapperImpl.OnSizeChangedDelegate(OnSizeChanged);
+ Parent = parent as LayoutGroup;
+ Log.Info("NUI", "Setting Parent Layout for:" + Owner?.Name + " to (Parent):" + (parent == null ? "null":parent.ToString() ) + "\n");
}
/// <summary>
/// </summary>
public void Unparent()
{
- layoutItemWrapperImpl.Unparent();
+ // Enable directly derived types to first remove children
+ OnUnparent();
+
+ // Remove myself from parent
+ Parent?.Remove( this );
+
+ // Remove parent reference
+ Parent = null;
+
+ // Lastly, clear layout from owning View.
+ Owner?.ResetLayout();
}
- protected void SetMeasuredDimensions(MeasuredSize measuredWidth, MeasuredSize measuredHeight)
+ /// <summary>
+ /// Get the View owning this LayoutItem
+ /// </summary>
+ internal View GetOwner()
+ {
+ return Owner;
+ }
+
+ /// <summary>
+ /// Initialize the layout and allow derived classes to also perform any operations
+ /// </summary>
+ /// <param name="owner">Owner of this Layout.</param>
+ internal void AttachToOwner(View owner)
{
- layoutItemWrapperImpl.SetMeasuredDimensions(measuredWidth, measuredHeight);
+ // Assign the layout owner.
+ Owner = owner;
+ OnAttachedToOwner();
+ // Add layout to parent layout if a layout container
+ View parent = Owner.GetParent() as View;
+ (parent?.Layout as LayoutGroup)?.Add( this );
}
/// <summary>
/// </summary>
/// <param name="widthMeasureSpec"> Horizontal space requirements as imposed by the parent.</param>
/// <param name="heightMeasureSpec">Vertical space requirements as imposed by the parent.</param>
- internal void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ internal void Measure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- layoutItemWrapperImpl.Measure(widthMeasureSpec, heightMeasureSpec);
+ // Check if relayouting is required.
+ bool specChanged = (widthMeasureSpec.Size != OldWidthMeasureSpec.Size) ||
+ (heightMeasureSpec.Size != OldHeightMeasureSpec.Size) ||
+ (widthMeasureSpec.Mode != OldWidthMeasureSpec.Mode) ||
+ (heightMeasureSpec.Mode != OldHeightMeasureSpec.Mode);
+
+ bool isSpecExactly = (widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly) &&
+ (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly);
+
+ bool matchesSpecSize = (MeasuredWidth.Size == widthMeasureSpec.Size) &&
+ (MeasuredHeight.Size == heightMeasureSpec.Size);
+
+ bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize);
+ needsLayout = needsLayout || ((Flags & LayoutFlags.ForceLayout) == LayoutFlags.ForceLayout);
+
+ Log.Info("NUI", "Measuring:" + Owner.Name + " needsLayout[" + needsLayout.ToString() + "]\n");
+
+ if (needsLayout)
+ {
+ OnMeasure(widthMeasureSpec, heightMeasureSpec);
+ Flags = Flags | LayoutFlags.LayoutRequired;
+ Flags &= ~LayoutFlags.ForceLayout;
+ }
+ OldWidthMeasureSpec = widthMeasureSpec;
+ OldHeightMeasureSpec = heightMeasureSpec;
+
+ Log.Info("NUI", "LayoutItem Measure owner:" + Owner.Name + " width:" + widthMeasureSpec.Size.AsRoundedValue() + " height:" + heightMeasureSpec.Size.AsRoundedValue() + "\n");
}
/// <summary>
/// <param name="bottom">Bottom position, relative to parent.</param>
public void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- Log.Info("NUI", "LayoutItem Layout\n");
- layoutItemWrapperImpl.Layout(left, top, right, bottom);
+ Log.Info("NUI", "LayoutItem Layout owner:" + Owner.Name + "\n");
+
+ bool changed = SetFrame(left, top, right, bottom);
+
+ // Check if Measure needed before Layouting
+ if (changed || ((Flags & LayoutFlags.LayoutRequired) == LayoutFlags.LayoutRequired))
+ {
+ Log.Info("NUI", "LayoutItem Layout Frame changed or Layout forced\n");
+ OnLayout(changed, left, top, right, bottom);
+ // Clear flag
+ Flags &= ~LayoutFlags.LayoutRequired;
+ }
}
/// <summary>
/// Utility to return a default size.<br />
- /// Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the
- /// MeasureSpec.<br />
+ /// Uses the supplied size if the MeasureSpecification imposed no constraints. Will get larger if allowed by the
+ /// MeasureSpecification.<br />
/// </summary>
/// <param name="size"> Default size for this layout.</param>
- /// <param name="measureSpec"> Constraints imposed by the parent.</param>
+ /// <param name="measureSpecification"> Constraints imposed by the parent.</param>
/// <returns>The size this layout should be.</returns>
- public static LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec)
+ public static LayoutLength GetDefaultSize(LayoutLength size, MeasureSpecification measureSpecification)
{
- return LayoutItemWrapperImpl.GetDefaultSize(size, measureSpec);
- }
+ LayoutLength result = size;
+ MeasureSpecification.ModeType specMode = measureSpecification.Mode;
+ LayoutLength specSize = measureSpecification.Size;
- public ILayoutParent GetParent
- {
- get
+ switch (specMode)
{
- return layoutItemWrapperImpl.GetParent();
+ case MeasureSpecification.ModeType.Unspecified:
+ {
+ result = size;
+ break;
+ }
+ case MeasureSpecification.ModeType.AtMost:
+ {
+ // Ensure the default size does not exceed the spec size unless the default size is 0.
+ // Another container could provide a default size of 0.
+
+ // Do not set size to 0, use specSize in this case as could be a legacy container
+ if( ( size.AsDecimal() < specSize.AsDecimal()) && ( size.AsDecimal() > 0) )
+ {
+ result = size;
+ }
+ else
+ {
+ result = specSize;
+ }
+ break;
+ }
+ case MeasureSpecification.ModeType.Exactly:
+ {
+ result = specSize;
+ break;
+ }
}
+
+ Log.Info("NUI", "DefaultSize :" + result.AsRoundedValue() + "\n");
+
+ return result;
+ }
+
+ public ILayoutParent GetParent()
+ {
+ return Parent;
}
/// <summary>
/// </summary>
public void RequestLayout()
{
- layoutItemWrapperImpl.RequestLayout();
+ Log.Info("NUI", "RequestLayout on:" + Owner?.Name + "\n");
+ Flags = Flags | LayoutFlags.ForceLayout;
+ Window.Instance.LayoutController.RequestLayout(this);
}
/// <summary>
{
get
{
- return IsLayoutRequested();
+ return ( Flags & LayoutFlags.ForceLayout) == LayoutFlags.ForceLayout;
}
}
- /// <summary>
- /// Predicate to determine if this layout has been requested to re-layout.<br />
- /// </summary>
- /// <returns>True if a layout request has occured on this layout.</returns>
- private bool IsLayoutRequested()
- {
- return layoutItemWrapperImpl.IsLayoutRequested();
- }
-
/// <summary>
/// Get the measured width (without any measurement flags).<br />
/// This method should be used only during measurement and layout calculations.<br />
/// </summary>
- public LayoutLength MeasuredWidth
- {
- get
- {
- return GetMeasuredWidth();
- }
- }
-
- /// <summary>
- /// Get the measured width (without any measurement flags).<br />
- /// This method should be used only during measurement and layout calculations.<br />
- /// </summary>
- private LayoutLength GetMeasuredWidth()
- {
- return layoutItemWrapperImpl.GetMeasuredWidth();
- }
+ public MeasuredSize MeasuredWidth{ get; set; } = new MeasuredSize( new LayoutLength(-3), MeasuredSize.StateType.MeasuredSizeOK);
/// <summary>
/// Get the measured height (without any measurement flags).<br />
/// This method should be used only during measurement and layout calculations.<br />
/// </summary>
- public LayoutLength MeasuredHeight
- {
- get
- {
- return GetMeasuredHeight();
- }
- }
-
- /// <summary>
- /// Get the measured height (without any measurement flags).<br />
- /// This method should be used only during measurement and layout calculations.<br />
- /// </summary>
- private LayoutLength GetMeasuredHeight()
- {
- return layoutItemWrapperImpl.GetMeasuredHeight();
- }
+ public MeasuredSize MeasuredHeight{ get; set; } = new MeasuredSize( new LayoutLength(-3), MeasuredSize.StateType.MeasuredSizeOK);
/// <summary>
/// Get the measured width and state.<br />
{
get
{
- return GetMeasuredWidthAndState();
+ return MeasuredWidth; // Not bitmasking State unless proven to be required.
}
}
- /// <summary>
- /// Get the measured width and state.<br />
- /// This method should be used only during measurement and layout calculations.<br />
- /// </summary>
- private MeasuredSize GetMeasuredWidthAndState()
- {
- return layoutItemWrapperImpl.GetMeasuredWidthAndState();
- }
/// <summary>
/// Get the measured height and state.<br />
{
get
{
- return GetMeasuredHeightAndState();
+ return MeasuredHeight; // Not bitmasking State unless proven to be required.
}
}
- /// <summary>
- /// Get the measured height and state.<br />
- /// This method should be used only during measurement and layout calculations.<br />
- /// </summary>
- private MeasuredSize GetMeasuredHeightAndState()
- {
- return layoutItemWrapperImpl.GetMeasuredHeightAndState();
- }
-
/// <summary>
/// Returns the suggested minimum width that the layout should use.<br />
/// This returns the maximum of the layout's minimum width and the owner's natural width.<br />
{
get
{
- return GetSuggestedMinimumWidth();
+ int naturalWidth = Owner.NaturalSize2D.Width;
+ Log.Info("NUI", "NaturalWidth for: " + Owner.Name + " :" + naturalWidth +"\n");
+ return new LayoutLength(Math.Max( MinimumWidth.AsDecimal(), naturalWidth ));
}
}
- /// <summary>
- /// Returns the suggested minimum width that the layout should use.<br />
- /// This returns the maximum of the layout's minimum width and the owner's natural width.<br />
- /// </summary>
- /// <returns>The suggested minimum width of the layout.</returns>
- private LayoutLength GetSuggestedMinimumWidth()
- {
- return layoutItemWrapperImpl.GetSuggestedMinimumWidth();
- }
-
/// <summary>
/// Returns the suggested minimum height that the layout should use.<br />
/// This returns the maximum of the layout's minimum height and the owner's natural height.<br />
{
get
{
- return GetSuggestedMinimumHeight();
+ int naturalHeight = Owner.NaturalSize2D.Height;
+ Log.Info("NUI", "NaturalHeight for: " + Owner.Name + " :" + naturalHeight +"\n");
+ return new LayoutLength(Math.Max( MinimumHeight.AsDecimal(), naturalHeight ));
}
}
- /// <summary>
- /// Returns the suggested minimum height that the layout should use.<br />
- /// This returns the maximum of the layout's minimum height and the owner's natural height.<br />
- /// </summary>
- /// <returns>The suggested minimum height of the layout.</returns>
- private LayoutLength GetSuggestedMinimumHeight()
- {
- return layoutItemWrapperImpl.GetSuggestedMinimumHeight();
- }
-
/// <summary>
/// Sets the minimum width of the layout.<br />
/// It is not guaranteed the layout will be able to achieve this minimum width (for example, if its parent
/// layout constrains it with less available width).<br />
/// 1. if the owner's View.LayoutWidthSpecification has exact value, then that value overrides the minimum size.<br />
- /// 2. If the owner's View.LayoutWidthSpecification is set to View.ChildLayoutData.WrapContent, then the view's width is set based on the suggested minimum width. (@see GetSuggestedMinimumWidth()).<br />
- /// 3. If the owner's View.LayoutWidthSpecification is set to View.ChildLayoutData.MatchParent, then the parent width takes precedence over the minimum width.<br />
+ /// 2. If the owner's View.LayoutWidthSpecification is set to View.LayoutParamPolicies.WrapContent, then the view's width is set based on the suggested minimum width. (@see GetSuggestedMinimumWidth()).<br />
+ /// 3. If the owner's View.LayoutWidthSpecification is set to View.LayoutParamPolicies.MatchParent, then the parent width takes precedence over the minimum width.<br />
/// </summary>
- public LayoutLength MinimumWidth
- {
- get
- {
- return GetMinimumWidth();
- }
- set
- {
- SetMinimumWidth(value);
- }
- }
-
- /// <summary>
- /// Sets the minimum width of the layout.<br />
- /// It is not guaranteed the layout will be able to achieve this minimum width (for example, if its parent
- /// layout constrains it with less available width).<br />
- /// </summary>
- /// <param name="minWidth">The minimum width the layout will try to be, in pixels.</param>
- private void SetMinimumWidth(LayoutLength minWidth)
- {
- layoutItemWrapperImpl.SetMinimumWidth(minWidth);
- }
+ public LayoutLength MinimumWidth {get; set;}
/// <summary>
/// Sets the minimum height of the layout.<br />
/// It is not guaranteed the layout will be able to achieve this minimum height (for example, if its parent
/// layout constrains it with less available height).<br />
/// 1. if the owner's View.LayoutHeightSpecification has exact value, then that value overrides the minimum size.<br />
- /// 2. If the owner's View.LayoutHeightSpecification is set to View.ChildLayoutData.WrapContent, then the view's height is set based on the suggested minimum height. (@see GetSuggestedMinimumHeight()).<br />
- /// 3. If the owner's View.LayoutHeightSpecification is set to View.ChildLayoutData.MatchParent, then the parent height takes precedence over the minimum height.<br />
+ /// 2. If the owner's View.LayoutHeightSpecification is set to View.LayoutParamPolicies.WrapContent, then the view's height is set based on the suggested minimum height. (@see GetSuggestedMinimumHeight()).<br />
+ /// 3. If the owner's View.LayoutHeightSpecification is set to View.LayoutParamPolicies.MatchParent, then the parent height takes precedence over the minimum height.<br />
/// </summary>
- public LayoutLength MinimumHeight
- {
- get
- {
- return GetMinimumHeight();
- }
- set
+ public LayoutLength MinimumHeight {get; set;}
+
+ ///<summary>
+ /// Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpecification.
+ ///</summary>
+ /// <param name="size"> How big the layout wants to be.</param>
+ /// <param name="measureSpecification"> Constraints imposed by the parent.</param>
+ /// <param name="childMeasuredState"> Size information bit mask for the layout's children.</param>
+ /// <returns> A measured size, which may indicate that it is too small. </returns>
+ protected MeasuredSize ResolveSizeAndState( LayoutLength size, MeasureSpecification measureSpecification, MeasuredSize.StateType childMeasuredState )
+ {
+ var specMode = measureSpecification.Mode;
+ LayoutLength specSize = measureSpecification.Size;
+ MeasuredSize result = new MeasuredSize( size, childMeasuredState);
+
+ switch( specMode )
{
- SetMinimumHeight(value);
+ case MeasureSpecification.ModeType.AtMost:
+ {
+ if (specSize.AsRoundedValue() < size.AsRoundedValue())
+ {
+ result = new MeasuredSize( specSize, MeasuredSize.StateType.MeasuredSizeTooSmall);
+ }
+ break;
+ }
+
+ case MeasureSpecification.ModeType.Exactly:
+ {
+ result.Size = specSize;
+ break;
+ }
+
+ case MeasureSpecification.ModeType.Unspecified:
+ default:
+ {
+ break;
+ }
}
+ return result;
}
/// <summary>
- /// Sets the minimum height of the layout.<br />
- /// It is not guaranteed the layout will be able to achieve this minimum height (for example, if its parent
- /// layout constrains it with less available height).<br />
- /// </summary>
- /// <param name="minHeight">The minimum height the layout will try to be, in pixels.</param>
- private void SetMinimumHeight(LayoutLength minHeight)
- {
- layoutItemWrapperImpl.SetMinimumHeight(minHeight);
- }
-
- /// <summary>
- /// Returns the minimum width of the layout.<br />
+ /// This method must be called by OnMeasure(MeasureSpec,MeasureSpec) to store the measured width and measured height.
/// </summary>
- /// <returns>the minimum width the layout will try to be, in pixels.</returns>
- private LayoutLength GetMinimumWidth()
+ /// <param name="measuredWidth">The measured width of this layout.</param>
+ /// <param name="measuredHeight">The measured height of this layout.</param>
+ protected void SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
{
- return layoutItemWrapperImpl.GetMinimumWidth();
- }
+ Log.Info("NUI", "For " + Owner.Name + " MeasuredWidth:" + measuredWidth.Size.AsRoundedValue()
+ + " MeasureHeight:" + measuredHeight.Size.AsRoundedValue() + "\n");
- /// <summary>
- /// Returns the minimum height of the layout.<br />
- /// </summary>
- /// <returns>the minimum height the layout will try to be, in pixels.</returns>
- private LayoutLength GetMinimumHeight()
- {
- return layoutItemWrapperImpl.GetMinimumHeight();
+ MeasuredWidth = measuredWidth;
+ MeasuredHeight = measuredHeight;
+ Flags = Flags | LayoutFlags.MeasuredDimensionSet;
}
/// <summary>
/// </summary>
/// <param name="widthMeasureSpec">horizontal space requirements as imposed by the parent.</param>
/// <param name="heightMeasureSpec">vertical space requirements as imposed by the parent.</param>
- protected virtual void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected virtual void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- layoutItemWrapperImpl.OnMeasureNative(widthMeasureSpec, heightMeasureSpec);
+ // GetDefaultSize will limit the MeasureSpec to the suggested minimumWidth and minimumHeight
+ SetMeasuredDimensions( GetDefaultSize( SuggestedMinimumWidth, widthMeasureSpec ),
+ GetDefaultSize( SuggestedMinimumHeight, heightMeasureSpec ) );
}
/// <summary>
protected virtual void OnSizeChanged(LayoutSize newSize, LayoutSize oldSize)
{
}
+
+ /// <summary>
+ /// Virtual method to allow derived classes to remove any children before it is removed from
+ /// its parent.
+ /// </summary>
+ public virtual void OnUnparent()
+ {
+ }
+
+ /// <summary>
+ /// Virtual method called when this Layout is attached to it's owner.
+ /// Allows derived layouts to take ownership of child Views and connect to any Owner signals required.
+ /// </summary>
+ protected virtual void OnAttachedToOwner()
+ {
+ }
+
+ private bool SetFrame(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
+ {
+ bool changed = false;
+
+ if( _left != left || _right != right || _top != top || _bottom != bottom )
+ {
+ changed = true;
+ }
+
+ LayoutLength oldWidth = _right - _left;
+ LayoutLength oldHeight = _bottom - _top;
+ LayoutLength newWidth = right - left;
+ LayoutLength newHeight = bottom - top;
+ bool sizeChanged = ( newWidth != oldWidth ) || ( newHeight != oldHeight );
+
+ _left = left;
+ _top = top;
+ _right = right;
+ _bottom = bottom;
+
+ // Set actual positions of View.
+ Owner.SetX(_left.AsRoundedValue());
+ Owner.SetY(_top.AsRoundedValue());
+ Owner.SetSize((int)newWidth.AsRoundedValue(), (int)newHeight.AsRoundedValue());
+
+ Log.Info("NUI", "Frame set for " + Owner.Name + " to left:" + _left.AsRoundedValue() + " top:"
+ + _top.AsRoundedValue() + " width: " + newWidth.AsRoundedValue() + " height: "
+ + newHeight.AsRoundedValue() + "\n");
+
+ return changed;
+ }
+
}
}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- internal class LayoutItemPtr : global::System.IDisposable
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
-
- internal LayoutItemPtr(global::System.IntPtr cPtr, bool cMemoryOwn)
- {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutItemPtr obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- ~LayoutItemPtr()
- {
- Dispose();
- }
-
- public virtual void Dispose()
- {
- lock(this) {
- if (swigCPtr.Handle != global::System.IntPtr.Zero) {
- if (swigCMemOwn) {
- swigCMemOwn = false;
- Interop.LayoutItemPtr.delete_LayoutItemPtr(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
- }
- }
-
- public LayoutItemPtr() : this(Interop.LayoutItemPtr.new_LayoutItemPtr__SWIG_0(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal LayoutItemPtr(LayoutItemWrapperImpl p) : this(Interop.LayoutItemPtr.new_LayoutItemPtr__SWIG_1(LayoutItemWrapperImpl.getCPtr(p)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public LayoutItemPtr(LayoutItemPtr rhs) : this(Interop.LayoutItemPtr.new_LayoutItemPtr__SWIG_2(LayoutItemPtr.getCPtr(rhs)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal LayoutItemWrapperImpl Get()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemPtr.LayoutItemPtr_Get(swigCPtr);
- LayoutItemWrapperImpl ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutItemWrapperImpl __deref__()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemPtr.LayoutItemPtr___deref__(swigCPtr);
- LayoutItemWrapperImpl ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutItemWrapperImpl __ref__()
- {
- LayoutItemWrapperImpl ret = new LayoutItemWrapperImpl(Interop.LayoutItemPtr.LayoutItemPtr___ref__(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void Reset()
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Reset__SWIG_0(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void Reset(LayoutItemWrapperImpl rhs)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Reset__SWIG_1(swigCPtr, LayoutItemWrapperImpl.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal LayoutItemWrapperImpl Detach()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemPtr.LayoutItemPtr_Detach(swigCPtr);
- LayoutItemWrapperImpl ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- /*public LayoutItemPtr New(Handle owner)
- {
- LayoutItemPtr ret = new LayoutItemPtr(Interop.LayoutItemPtr.LayoutItemPtr_New(swigCPtr, Handle.getCPtr(owner)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void Initialize(Handle owner, string containerType)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Initialize(swigCPtr, Handle.getCPtr(owner), containerType);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }*/
-
- public void Unparent()
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Unparent(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public void SetAnimateLayout(bool animateLayout)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_SetAnimateLayout(swigCPtr, animateLayout);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public bool IsLayoutAnimated()
- {
- bool ret = Interop.LayoutItemPtr.LayoutItemPtr_IsLayoutAnimated(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Measure(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Layout(swigCPtr, LayoutLength.getCPtr(left), LayoutLength.getCPtr(top), LayoutLength.getCPtr(right), LayoutLength.getCPtr(bottom));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetDefaultSize(swigCPtr, LayoutLength.getCPtr(size), LayoutMeasureSpec.getCPtr(measureSpec)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- /*public LayoutParent GetParent()
- {
- global::System.IntPtr cPtr = (SwigDerivedClassHasMethod("GetParent", swigMethodTypes0) ? Interop.LayoutItemPtr.LayoutItemPtr_GetParentSwigExplicitLayoutItemWrapperImpl(swigCPtr) : Interop.LayoutItemPtr.LayoutItemPtr_GetParent(swigCPtr));
- LayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutParent(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }*/
-
- public void RequestLayout()
- {
- Interop.LayoutItemPtr.LayoutItemPtr_RequestLayout(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public bool IsLayoutRequested()
- {
- bool ret = Interop.LayoutItemPtr.LayoutItemPtr_IsLayoutRequested(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength GetMeasuredWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetMeasuredWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength GetMeasuredHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetMeasuredHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public MeasuredSize GetMeasuredWidthAndState()
- {
- MeasuredSize ret = new MeasuredSize(Interop.LayoutItemPtr.LayoutItemPtr_GetMeasuredWidthAndState(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public MeasuredSize GetMeasuredHeightAndState()
- {
- MeasuredSize ret = new MeasuredSize(Interop.LayoutItemPtr.LayoutItemPtr_GetMeasuredHeightAndState(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength GetSuggestedMinimumWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetSuggestedMinimumWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength GetSuggestedMinimumHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetSuggestedMinimumHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void SetMinimumWidth(LayoutLength minWidth)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_SetMinimumWidth(swigCPtr, LayoutLength.getCPtr(minWidth));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public void SetMinimumHeight(LayoutLength minHeight)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_SetMinimumHeight(swigCPtr, LayoutLength.getCPtr(minHeight));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public LayoutLength GetMinimumWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetMinimumWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength GetMinimumHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemPtr.LayoutItemPtr_GetMinimumHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public Extents GetPadding()
- {
- Extents ret = new Extents(Interop.LayoutItemPtr.LayoutItemPtr_GetPadding(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void SetMeasuredDimensions(MeasuredSize measuredWidth, MeasuredSize measuredHeight)
- {
- Interop.LayoutItemPtr.LayoutItemPtr_SetMeasuredDimensions(swigCPtr, MeasuredSize.getCPtr(measuredWidth), MeasuredSize.getCPtr(measuredHeight));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public bool DoAction(string actionName, PropertyMap attributes)
- {
- bool ret = Interop.LayoutItemPtr.LayoutItemPtr_DoAction(swigCPtr, actionName, PropertyMap.getCPtr(attributes));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public string GetTypeName()
- {
- string ret = Interop.LayoutItemPtr.LayoutItemPtr_GetTypeName(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public bool GetTypeInfo(TypeInfo info)
- {
- bool ret = Interop.LayoutItemPtr.LayoutItemPtr_GetTypeInfo(swigCPtr, TypeInfo.getCPtr(info));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public void Reference()
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Reference(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public void Unreference()
- {
- Interop.LayoutItemPtr.LayoutItemPtr_Unreference(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public int ReferenceCount()
- {
- int ret = Interop.LayoutItemPtr.LayoutItemPtr_ReferenceCount(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System.Collections.Generic;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- internal class LayoutItemWrapper : BaseHandle
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- internal LayoutItemWrapperImpl layoutItemWrapperImpl;
-
- internal LayoutItemWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LayoutItemWrapper.LayoutItemWrapper_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutItemWrapper obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.LayoutItemWrapper.delete_LayoutItemWrapper(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
-
- base.Dispose(type);
- }
-
- private List<LayoutItemWrapper> _childLayouts = new List<LayoutItemWrapper>();
- internal List<LayoutItemWrapper> LayoutChildren
- {
- get
- {
- return _childLayouts;
- }
- }
-
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class ChildProperty
- {
- public static readonly int WIDTH_SPECIFICATION = Interop.LayoutItemWrapper.LayoutItemWrapper_ChildProperty_WIDTH_SPECIFICATION_get();
- public static readonly int HEIGHT_SPECIFICATION = Interop.LayoutItemWrapper.LayoutItemWrapper_ChildProperty_HEIGHT_SPECIFICATION_get();
-
- }
-
- /*public LayoutItemWrapper (Handle handle) : this (LayoutPINVOKE.LayoutItemWrapper_New(Handle.getCPtr(handle)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }*/
-
- public View GetOwner()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemWrapper.LayoutItemWrapper_GetOwner(swigCPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private void SetAnimateLayout(bool animateLayout)
- {
- Interop.LayoutItemWrapper.LayoutItemWrapper_SetAnimateLayout(swigCPtr, animateLayout);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- private bool IsLayoutAnimated()
- {
- bool ret = Interop.LayoutItemWrapper.LayoutItemWrapper_IsLayoutAnimated(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public bool LayoutAnimate
- {
- get
- {
- return IsLayoutAnimated();
- }
- set
- {
- SetAnimateLayout(value);
- }
- }
-
- internal LayoutItemWrapper(LayoutItemWrapperImpl implementation) : this(Interop.LayoutItemWrapper.new_LayoutItemWrapper__SWIG_2(LayoutItemWrapperImpl.getCPtr(implementation)), true)
- {
- layoutItemWrapperImpl = implementation;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
- }
-
- internal interface ILayoutParent
- {
- ILayoutParent GetParent();
- /*{
- global::System.IntPtr cPtr = LayoutPINVOKE.LayoutParent_GetParent(swigCPtr);
- LayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutParent(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }*/
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- internal class LayoutItemWrapperImpl : BaseObject, ILayoutParent
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- public delegate void OnMeasureDelegate(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec);
- public delegate void OnLayoutDelegate(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom);
- public delegate void OnSizeChangedDelegate(LayoutSize newSize, LayoutSize oldSize);
-
- public OnMeasureDelegate OnMeasure;
- public OnLayoutDelegate OnLayout;
- public OnSizeChangedDelegate OnSizeChanged;
-
- internal LayoutItemWrapperImpl(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_SWIGUpcast(cPtr), cMemoryOwn)
- {
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutItemWrapperImpl obj)
- {
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- base.Dispose(type);
- }
-
- public LayoutItemWrapperImpl() : this(Interop.LayoutItemWrapperImpl.new_LayoutItemWrapperImpl(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- SwigDirectorConnect();
- }
-
- /* public LayoutItemWrapperImpl (Handle owner) : this (NDalicPINVOKE.LayoutItemWrapperImpl_New(Handle.getCPtr(owner)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }*/
-
- public void Initialize(View owner, string containerType)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_Initialize(swigCPtr, View.getCPtr(owner), containerType);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public View GetOwner()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetOwner(swigCPtr);
- View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void Unparent()
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_Unparent(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void SetAnimateLayout(bool animateLayout)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_SetAnimateLayout(swigCPtr, animateLayout);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal bool IsLayoutAnimated()
- {
- bool ret = Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_IsLayoutAnimated(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_Measure(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_Layout(swigCPtr, LayoutLength.getCPtr(left), LayoutLength.getCPtr(top), LayoutLength.getCPtr(right), LayoutLength.getCPtr(bottom));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal static LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetDefaultSize(LayoutLength.getCPtr(size), LayoutMeasureSpec.getCPtr(measureSpec)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public ILayoutParent GetParent()
- {
- global::System.IntPtr cPtr = Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetParent(swigCPtr);
- //ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new ILayoutParent(cPtr, false);
- ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void RequestLayout()
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_RequestLayout(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal bool IsLayoutRequested()
- {
- bool ret = Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_IsLayoutRequested(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutLength GetMeasuredWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMeasuredWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutLength GetMeasuredHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMeasuredHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal MeasuredSize GetMeasuredWidthAndState()
- {
- MeasuredSize ret = new MeasuredSize(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMeasuredWidthAndState(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal MeasuredSize GetMeasuredHeightAndState()
- {
- MeasuredSize ret = new MeasuredSize(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMeasuredHeightAndState(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutLength GetSuggestedMinimumWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetSuggestedMinimumWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutLength GetSuggestedMinimumHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetSuggestedMinimumHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetMinimumWidth(LayoutLength minWidth)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_SetMinimumWidth(swigCPtr, LayoutLength.getCPtr(minWidth));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void SetMinimumHeight(LayoutLength minHeight)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_SetMinimumHeight(swigCPtr, LayoutLength.getCPtr(minHeight));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal LayoutLength GetMinimumWidth()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMinimumWidth(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal LayoutLength GetMinimumHeight()
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetMinimumHeight(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public Extents GetPadding()
- {
- Extents ret = new Extents(Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_GetPadding(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal void SetMeasuredDimensions(MeasuredSize measuredWidth, MeasuredSize measuredHeight)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_SetMeasuredDimensions(swigCPtr, MeasuredSize.getCPtr(measuredWidth), MeasuredSize.getCPtr(measuredHeight));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void OnMeasureNative(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_OnMeasureSwigExplicitLayoutItemWrapperImpl(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void OnLayoutNative(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_OnLayout(swigCPtr, changed, LayoutLength.getCPtr(left), LayoutLength.getCPtr(top), LayoutLength.getCPtr(right), LayoutLength.getCPtr(bottom));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- internal void OnSizeChangedNative(LayoutSize newSize, LayoutSize oldSize)
- {
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_OnSizeChanged(swigCPtr, LayoutSize.getCPtr(newSize), LayoutSize.getCPtr(oldSize));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- protected void SwigDirectorConnect()
- {
- //swigDelegate0 = new SwigDelegateLayoutItemWrapperImpl_0(SwigDirectorGetParent);
- swigDelegate0 = null;
- swigDelegate1 = null;
- swigDelegate2 = null;
- swigDelegate3 = new SwigDelegateLayoutItemWrapperImpl_3(SwigDirectorOnMeasure);
- swigDelegate4 = new SwigDelegateLayoutItemWrapperImpl_4(SwigDirectorOnLayout);
- swigDelegate5 = new SwigDelegateLayoutItemWrapperImpl_5(SwigDirectorOnSizeChanged);
- swigDelegate6 = null;
-
- Interop.LayoutItemWrapperImpl.LayoutItemWrapperImpl_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4, swigDelegate5, swigDelegate6);
- }
-
- private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)
- {
- global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
- bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(LayoutItemWrapperImpl));
- return hasDerivedMethod;
- }
-
- /*private global::System.IntPtr SwigDirectorGetParent()
- {
- return ILayoutParent.getCPtr(GetParent()).Handle;
- }*/
-
- private void SwigDirectorOnMeasure(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec)
- {
- OnMeasure(new LayoutMeasureSpec(widthMeasureSpec, true), new LayoutMeasureSpec(heightMeasureSpec, true));
- }
-
- private void SwigDirectorOnLayout(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom)
- {
- OnLayout(changed, new LayoutLength(left, true), new LayoutLength(top, true), new LayoutLength(right, true), new LayoutLength(bottom, true));
- }
-
- private void SwigDirectorOnSizeChanged(global::System.IntPtr newSize, global::System.IntPtr oldSize)
- {
- OnSizeChanged(new LayoutSize(newSize, true), new LayoutSize(oldSize, true));
- }
-
- public delegate global::System.IntPtr SwigDelegateLayoutItemWrapperImpl_0();
- public delegate void SwigDelegateLayoutItemWrapperImpl_1();
- public delegate void SwigDelegateLayoutItemWrapperImpl_2(string containerType);
- public delegate void SwigDelegateLayoutItemWrapperImpl_3(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec);
- public delegate void SwigDelegateLayoutItemWrapperImpl_4(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom);
- public delegate void SwigDelegateLayoutItemWrapperImpl_5(global::System.IntPtr newSize, global::System.IntPtr oldSize);
- public delegate void SwigDelegateLayoutItemWrapperImpl_6();
-
- private SwigDelegateLayoutItemWrapperImpl_0 swigDelegate0;
- private SwigDelegateLayoutItemWrapperImpl_1 swigDelegate1;
- private SwigDelegateLayoutItemWrapperImpl_2 swigDelegate2;
- private SwigDelegateLayoutItemWrapperImpl_3 swigDelegate3;
- private SwigDelegateLayoutItemWrapperImpl_4 swigDelegate4;
- private SwigDelegateLayoutItemWrapperImpl_5 swigDelegate5;
- private SwigDelegateLayoutItemWrapperImpl_6 swigDelegate6;
- }
-} // namespace Tizen.NUI
\ No newline at end of file
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
/// <summary>
/// [Draft] A type that represents a layout length. Currently, this implies pixels, but could be extended to handle device dependant sizes, etc.
/// </summary>
- internal class LayoutLength : global::System.IDisposable
+ internal struct LayoutLength
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
+ private float _value;
- internal LayoutLength(global::System.IntPtr cPtr, bool cMemoryOwn)
+ /// <summary>
+ /// [Draft] Constructor from an int
+ /// </summary>
+ /// <param name="value">Int to initialize with.</param>
+ public LayoutLength(int value)
+ {
+ _value = value;
+ }
+
+ /// <summary>
+ /// [Draft] Constructor from a float
+ /// </summary>
+ /// <param name="value">Float to initialize with.</param>
+ public LayoutLength(float value)
+ {
+ _value = value;
+ }
+
+ /// <summary>
+ /// [Draft] Constructor from a LayoutLength
+ /// </summary>
+ /// <param name="layoutLength">LayoutLength object to initialize with.</param>
+ public LayoutLength(LayoutLength layoutLength)
+ {
+ _value = layoutLength._value;
+ }
+
+ /// <summary>
+ /// [Draft] Return value as rounded value (whole number), best used as final output
+ /// </summary>
+ /// <returns>The layout length value as a rounded whole number.</returns>
+ public float AsRoundedValue()
{
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ return (float)Math.Round((decimal)_value, MidpointRounding.AwayFromZero);
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutLength obj)
+ /// <summary>
+ /// [Draft] Return value as the raw decimal value, best used for calculations
+ /// </summary>
+ /// <returns>The layout length value as the raw decimal value.</returns>
+ public float AsDecimal()
{
- return (obj.Equals(null)) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ return _value;
}
- ~LayoutLength()
+ /// <summary>
+ /// [Draft] The == operator.
+ /// </summary>
+ /// <param name="arg1">The first value.</param>
+ /// <param name="arg2">The second value</param>
+ /// <returns>true if LayoutLengths are equal</returns>
+ public static bool operator ==(LayoutLength arg1, LayoutLength arg2)
{
- Dispose();
+ return arg1.Equals(arg2);
}
- public virtual void Dispose()
+ /// <summary>
+ /// [Draft] The != operator.
+ /// </summary>
+ /// <param name="arg1">The first value.</param>
+ /// <param name="arg2">The second value</param>
+ /// <returns>true if LayoutLengths are not equal</returns>
+ public static bool operator !=(LayoutLength arg1, LayoutLength arg2)
+ {
+ return !arg1.Equals(arg2);
+ }
+
+ /// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if equal LayoutLength, else false.</returns>
+ public override bool Equals(object obj)
{
- lock (this)
+ if (obj is LayoutLength)
{
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.LayoutLength.delete_LayoutLength(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
+ return this.Equals((LayoutLength)obj);
}
+ return false;
}
- public LayoutLength(int value) : this(Interop.LayoutLength.new_LayoutLength__SWIG_0(value), true)
+ /// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="layoutLength">The LayoutLength to compare with the current LayoutLength.</param>
+ /// <returns>true if equal LayoutLengths, else false.</returns>
+ public bool Equals(LayoutLength layoutLength)
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return (Math.Abs(_value - layoutLength._value ) <= float.Epsilon);
}
- public LayoutLength(LayoutLength layoutLength) : this(Interop.LayoutLength.new_LayoutLength__SWIG_1(LayoutLength.getCPtr(layoutLength)), true)
+ /// <summary>
+ /// A hash code for the current object.
+ /// </summary>
+ public override int GetHashCode()
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return (int)Math.Ceiling(_value);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the addition.</returns>
public static LayoutLength operator +(LayoutLength arg1, LayoutLength arg2)
{
- return arg1.Add(arg2);
+ return new LayoutLength( arg1._value + arg2._value );
}
/// <summary>
/// <returns>The LayoutLength containing the result of the addition.</returns>
public static LayoutLength operator +(LayoutLength arg1, int arg2)
{
- return arg1.Add(arg2);
+ return new LayoutLength(arg1._value + (float)arg2);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the subtraction.</returns>
public static LayoutLength operator -(LayoutLength arg1, LayoutLength arg2)
{
- return arg1.Subtract(arg2);
+ return new LayoutLength(arg1._value - arg2._value);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the subtraction.</returns>
public static LayoutLength operator -(LayoutLength arg1, int arg2)
{
- return arg1.Subtract(arg2);
+ return new LayoutLength(arg1._value - (float)arg2);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the multiplication.</returns>
public static LayoutLength operator *(LayoutLength arg1, LayoutLength arg2)
{
- return arg1.Multiply(arg2);
+ return new LayoutLength(arg1._value * arg2._value);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the scaling.</returns>
public static LayoutLength operator *(LayoutLength arg1, int arg2)
{
- return arg1.Multiply(arg2);
+ return new LayoutLength(arg1._value * arg2);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the division.</returns>
public static LayoutLength operator /(LayoutLength arg1, LayoutLength arg2)
{
- return arg1.Divide(arg2);
+ return new LayoutLength(arg1._value / arg2._value);
}
/// <summary>
/// <returns>The LayoutLength containing the result of the scaling.</returns>
public static LayoutLength operator /(LayoutLength arg1, int arg2)
{
- return arg1.Divide(arg2);
- }
-
- public static bool operator ==(LayoutLength r1, LayoutLength r2)
- {
- return r1.EqualTo(r2);
- }
-
- public static bool operator !=(LayoutLength r1, LayoutLength r2)
- {
- return !r1.EqualTo(r2);
- }
-
- /// <summary>
- /// Determines whether the specified object is equal to the current object.
- /// </summary>
- /// <param name="obj">The object to compare with the current object.</param>
- /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
- public override bool Equals(System.Object obj)
- {
- LayoutLength layoutLength = obj as LayoutLength;
- bool equal = false;
- if (Value == layoutLength?.Value)
- {
- equal = true;
- }
- return equal;
- }
-
- /// <summary>
- /// Gets the the hash code of this LayoutLength.
- /// </summary>
- /// <returns>The Hash Code.</returns>
- /// <since_tizen> 5 </since_tizen>
- public override int GetHashCode()
- {
- return swigCPtr.Handle.GetHashCode();
- }
-
- private bool EqualTo(LayoutLength rhs)
- {
- bool ret = Interop.LayoutLength.LayoutLength_EqualTo__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool EqualTo(int rhs)
- {
- bool ret = Interop.LayoutLength.LayoutLength_EqualTo__SWIG_1(swigCPtr, rhs);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool NotEqualTo(LayoutLength rhs)
- {
- bool ret = Interop.LayoutLength.LayoutLength_NotEqualTo(swigCPtr, LayoutLength.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool LessThan(LayoutLength rhs)
- {
- bool ret = Interop.LayoutLength.LayoutLength_LessThan__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool GreaterThan(LayoutLength rhs)
- {
- bool ret = Interop.LayoutLength.LayoutLength_GreaterThan__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Add(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Add__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Add(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Add__SWIG_1(swigCPtr, rhs), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Subtract(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Subtract__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Subtract(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Subtract__SWIG_1(swigCPtr, rhs), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength AddAssign(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_AddAssign__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength AddAssign(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_AddAssign__SWIG_1(swigCPtr, rhs), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength SubtractAssign(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_SubtractAssign__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength SubtractAssign(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_SubtractAssign__SWIG_1(swigCPtr, rhs), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Divide(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Divide__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Divide(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Divide__SWIG_1(swigCPtr, rhs), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Multiply(LayoutLength rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Multiply__SWIG_0(swigCPtr, LayoutLength.getCPtr(rhs)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Multiply(int rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Multiply__SWIG_1(swigCPtr, rhs), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutLength Multiply(float rhs)
- {
- LayoutLength ret = new LayoutLength(Interop.LayoutLength.LayoutLength_Multiply__SWIG_2(swigCPtr, rhs), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public int Value
- {
- set
- {
- Interop.LayoutLength.LayoutLength_mValue_set(swigCPtr, value);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
- get
- {
- int ret = Interop.LayoutLength.LayoutLength_mValue_get(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ return new LayoutLength(arg1._value / (float)arg2);
}
}
}
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// [Draft] A type that represents a layout length. Currently, this implies pixels, but could be extended to handle device dependant sizes, etc.
- /// </summary>
- internal class LayoutLengthEx : IEquatable<LayoutLengthEx>
- {
- private readonly float _value;
-
- /// <summary>
- /// [Draft] Constructor from an int
- /// </summary>
- /// <param name="value">Int to initialize with.</param>
- public LayoutLengthEx(int value)
- {
- _value = value;
- }
-
- /// <summary>
- /// [Draft] Constructor from a float
- /// </summary>
- /// <param name="value">Float to initialize with.</param>
- public LayoutLengthEx(float value)
- {
- _value = value;
- }
-
- /// <summary>
- /// [Draft] Constructor from a LayoutLength
- /// </summary>
- /// <param name="layoutLength">LayoutLength object to initialize with.</param>
- public LayoutLengthEx(LayoutLengthEx layoutLength)
- {
- _value = layoutLength._value;
- }
-
- /// <summary>
- /// [Draft] Return value as rounded value (whole number), best used as final output
- /// </summary>
- /// <returns>The layout length value as a rounded whole number.</returns>
- public float AsRoundedValue()
- {
- return (float)Math.Round((decimal)_value, MidpointRounding.AwayFromZero);
- }
-
- /// <summary>
- /// [Draft] Return value as the raw decimal value, best used for calculations
- /// </summary>
- /// <returns>The layout length value as the raw decimal value.</returns>
- public float AsDecimal()
- {
- return _value;
- }
-
- /// <summary>
- /// [Draft] The == operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value</param>
- /// <returns>true if LayoutLengths are equal</returns>
- public static bool operator ==(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return arg1.Equals(arg2);
- }
-
- /// <summary>
- /// [Draft] The != operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value</param>
- /// <returns>true if LayoutLengths are not equal</returns>
- public static bool operator !=(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return !arg1.Equals(arg2);
- }
-
- /// <summary>
- /// Determines whether the specified object is equal to the current object.
- /// </summary>
- /// <param name="obj">The object to compare with the current object.</param>
- /// <returns>true if equal LayoutLength, else false.</returns>
- public override bool Equals(object obj)
- {
- LayoutLengthEx layoutLengthEx = obj as LayoutLengthEx;
- if (layoutLengthEx != null)
- {
- return Equals(layoutLengthEx);
- }
- return false;
- }
-
- /// <summary>
- /// Determines whether the specified object is equal to the current object.
- /// </summary>
- /// <param name="layoutLength">The LayoutLength to compare with the current LayoutLength.</param>
- /// <returns>true if equal LayoutLengths, else false.</returns>
- public bool Equals(LayoutLengthEx layoutLength)
- {
- return (Math.Abs(_value - layoutLength._value ) <= float.Epsilon);
- }
-
- /// <summary>
- /// A hash code for the current object.
- /// </summary>
- public override int GetHashCode()
- {
- return _value.GetHashCode();
- }
-
- /// <summary>
- /// The addition operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the addition.</returns>
- public static LayoutLengthEx operator +(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return new LayoutLengthEx( arg1._value + arg2._value );
- }
-
- /// <summary>
- /// The addition operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the addition.</returns>
- public static LayoutLengthEx operator +(LayoutLengthEx arg1, int arg2)
- {
- return new LayoutLengthEx(arg1._value + (float)arg2);
- }
-
- /// <summary>
- /// The subtraction operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the subtraction.</returns>
- public static LayoutLengthEx operator -(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return new LayoutLengthEx(arg1._value - arg2._value);
- }
-
- /// <summary>
- /// The subtraction operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the subtraction.</returns>
- public static LayoutLengthEx operator -(LayoutLengthEx arg1, int arg2)
- {
- return new LayoutLengthEx(arg1._value - (float)arg2);
- }
-
- /// <summary>
- /// The multiplication operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the multiplication.</returns>
- public static LayoutLengthEx operator *(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return new LayoutLengthEx(arg1._value * arg2._value);
- }
-
- /// <summary>
- /// Th multiplication operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The int value to scale the LayoutLength.</param>
- /// <returns>The LayoutLength containing the result of the scaling.</returns>
- public static LayoutLengthEx operator *(LayoutLengthEx arg1, int arg2)
- {
- return new LayoutLengthEx(arg1._value * arg2);
- }
-
- /// <summary>
- /// The division operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The second value.</param>
- /// <returns>The LayoutLength containing the result of the division.</returns>
- public static LayoutLengthEx operator /(LayoutLengthEx arg1, LayoutLengthEx arg2)
- {
- return new LayoutLengthEx(arg1._value / arg2._value);
- }
-
- /// <summary>
- /// Th division operator.
- /// </summary>
- /// <param name="arg1">The first value.</param>
- /// <param name="arg2">The int value to scale the vector by.</param>
- /// <returns>The LayoutLength containing the result of the scaling.</returns>
- public static LayoutLengthEx operator /(LayoutLengthEx arg1, int arg2)
- {
- return new LayoutLengthEx(arg1._value / (float)arg2);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// [Draft] A MeasureSpec is used during the Measure pass by a LayoutGroup to inform it's children how to be measured.
- /// For instance, it may measure a child with an exact width and an unspecified height in order to determine height for width.
- /// </summary>
- internal class LayoutMeasureSpec : global::System.IDisposable
- {
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
-
- internal LayoutMeasureSpec(global::System.IntPtr cPtr, bool cMemoryOwn)
- {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutMeasureSpec obj)
- {
- return (obj.Equals(null)) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- ~LayoutMeasureSpec()
- {
- Dispose();
- }
-
- public virtual void Dispose()
- {
- lock (this)
- {
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.MeasureSpec.delete_MeasureSpec(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- }
- }
-
- public LayoutMeasureSpec(LayoutLength measureSpec, LayoutMeasureSpec.ModeType mode) : this(Interop.MeasureSpec.new_MeasureSpec__SWIG_0(LayoutLength.getCPtr(measureSpec), (int)mode), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public LayoutMeasureSpec(int measureSpec) : this(Interop.MeasureSpec.new_MeasureSpec__SWIG_1(measureSpec), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public static bool operator ==(LayoutMeasureSpec r1, LayoutMeasureSpec r2)
- {
- return r1.EqualTo(r2);
- }
-
- public static bool operator !=(LayoutMeasureSpec r1, LayoutMeasureSpec r2)
- {
- return !r1.EqualTo(r2);
- }
-
- /// <summary>
- /// Determines whether the specified object is equal to the current object.
- /// </summary>
- /// <param name="obj">The object to compare with the current object.</param>
- /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
- public override bool Equals(object obj)
- {
- LayoutMeasureSpec layoutMeasureSpec = obj as LayoutMeasureSpec;
- bool equal = false;
- if (Size == layoutMeasureSpec?.Size && Mode == layoutMeasureSpec?.Mode)
- {
- equal = true;
- }
- return equal;
- }
-
- /// <summary>
- /// Gets the the hash code of this LayoutMeasureSpec.
- /// </summary>
- /// <returns>The Hash Code.</returns>
- /// <since_tizen> 5 </since_tizen>
- public override int GetHashCode()
- {
- return swigCPtr.Handle.GetHashCode();
- }
-
- private bool EqualTo(LayoutMeasureSpec value)
- {
- bool ret = Interop.MeasureSpec.MeasureSpec_EqualTo(swigCPtr, LayoutMeasureSpec.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool NotEqualTo(LayoutMeasureSpec value)
- {
- bool ret = Interop.MeasureSpec.MeasureSpec_NotEqualTo(swigCPtr, LayoutMeasureSpec.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private LayoutMeasureSpec.ModeType GetMode()
- {
- LayoutMeasureSpec.ModeType ret = (LayoutMeasureSpec.ModeType)Interop.MeasureSpec.MeasureSpec_GetMode(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private int GetSize()
- {
- int ret = Interop.MeasureSpec.MeasureSpec_GetSize(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- /// <summary>
- /// [Draft] Adjust the measure size by the given delta. Used only for EXACT and AT_MOST modes.
- /// if the adjusted size is negative, it is zeroed.
- /// </summary>
- /// <param name="measureSpec">the measure spec to adjust</param>
- /// <param name="delta">A positive or negative value to adjust the measure spec by.</param>
- /// <returns>A new measure spec with the adjusted values.</returns>
- public static LayoutMeasureSpec Adjust(LayoutMeasureSpec measureSpec, int delta)
- {
- LayoutMeasureSpec ret = new LayoutMeasureSpec(Interop.MeasureSpec.MeasureSpec_Adjust(LayoutMeasureSpec.getCPtr(measureSpec), delta), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public int Size
- {
- set
- {
- Interop.MeasureSpec.MeasureSpec_mSize_set(swigCPtr, value);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
- get
- {
- int ret = Interop.MeasureSpec.MeasureSpec_mSize_get(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- }
-
- public LayoutMeasureSpec.ModeType Mode
- {
- set
- {
- Interop.MeasureSpec.MeasureSpec_mMode_set(swigCPtr, (int)value);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
- get
- {
- LayoutMeasureSpec.ModeType ret = (LayoutMeasureSpec.ModeType)Interop.MeasureSpec.MeasureSpec_mMode_get(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- }
-
- public enum ModeType
- {
- /// <summary>
- /// This is used by a parent to determine the desired dimension of a child layout.
- /// </summary>
- Unspecified,
- /// <summary>
- /// This is used by a parent to impose an exact size on the child.
- /// The child must use this size, and guarantee that all of its descendants will fit within this size.
- /// </summary>
- Exactly,
- /// <summary>
- /// This is used by the parent to impose a maximum size on the child.
- /// The child must guarantee that it and all of it's descendants will fit within this size.
- /// </summary>
- AtMost
- }
- }
-}
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace Tizen.NUI
{
/// <summary>
- /// [Draft] This class represents a layout size (width and height)
+ /// [Draft] This class represents a layout size (width and height), non mutable.
/// </summary>
- internal class LayoutSize : global::System.IDisposable
+ internal struct LayoutSize
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
-
- internal LayoutSize(global::System.IntPtr cPtr, bool cMemoryOwn)
- {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutSize obj)
+ /// <summary>
+ /// [Draft] Constructor from width and height
+ /// </summary>
+ /// <param name="width">Int to initialize with.</param>
+ /// <param name="height">Int to initialize with.</param>
+ public LayoutSize(int width, int height)
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ Width = width;
+ Height = height;
}
- ~LayoutSize()
+ /// <summary>
+ /// Computes a hash code for this LayoutSize for use in hash based collections.
+ /// </summary>
+ /// <returns>A non unique hash code .</returns>
+ public override int GetHashCode()
{
- Dispose();
+ return Width ^ Height;
}
- public virtual void Dispose()
+ /// <summary>
+ /// Whether the values of two LayoutSize objects are equals
+ /// </summary>
+ /// <param name="obj">Object to be compared against.</param>
+ /// <returns>true if obj is equal to this LayoutSize.</returns>
+ public override bool Equals(object obj)
{
- lock(this)
+ if (obj is LayoutSize)
{
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.LayoutSize.delete_LayoutSize(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- global::System.GC.SuppressFinalize(this);
+ LayoutSize layoutSize = (LayoutSize)obj;
+ return ((layoutSize.Width == Width) && (layoutSize.Height == Height));
}
+ return false;
}
- public LayoutSize() : this(Interop.LayoutSize.new_LayoutSize__SWIG_0(), true)
+ /// <summary>
+ /// Compares whether the two LayoutSize instances are equal.
+ /// </summary>
+ /// <param name="lhs">A LayoutSize instance.</param>
+ /// <param name="rhs">A LayoutSize instance.</param>
+ /// <returns>true if the two LayoutSize instances have equal values.</returns>
+ public static bool operator ==(LayoutSize lhs, LayoutSize rhs)
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ((lhs.Width == rhs.Width) && (lhs.Height == rhs.Height));
}
- public LayoutSize(int x, int y) : this(Interop.LayoutSize.new_LayoutSize__SWIG_1(x, y), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
- internal void SetWidth(LayoutLength value)
+ /// <summary>
+ /// Compares whether the two LayoutSize instances are same or not.
+ /// </summary>
+ /// <param name="lhs">A LayoutSize instance.</param>
+ /// <param name="rhs">A LayoutSize instance.</param>
+ /// <returns>true if the two LayoutSize instances have do not have equal values.</returns>
+ public static bool operator !=(LayoutSize lhs, LayoutSize rhs)
{
- Interop.LayoutSize.LayoutSize_SetWidth__SWIG_1(swigCPtr, LayoutLength.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ((lhs.Width != rhs.Width) || (lhs.Height != rhs.Height));
}
- internal void SetHeight(LayoutLength value)
- {
- Interop.LayoutSize.LayoutSize_SetHeight__SWIG_1(swigCPtr, LayoutLength.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ /// <summary>
+ /// [Draft] Get the width value of this layout
+ /// </summary>
+ public int Width{ get; private set; }
- private bool EqualTo(LayoutSize rhs)
- {
- bool ret = Interop.LayoutSize.LayoutSize_EqualTo(swigCPtr, LayoutSize.getCPtr(rhs));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ /// <summary>
+ /// [Draft] Get the height value of this layout
+ /// </summary>
+ public int Height{ get; private set; }
- public bool IsEqualTo(LayoutSize target)
- {
- if (this.Width == target.Width && this.Height == target.Height)
- {
- return true;
- }
- return false;
- }
-
-
- // This causes crash!
- // compile warning message :
- //'LayoutSize' defines operator == or operator != but does not override Object.Equals(object o)
- //'LayoutSize' defines operator == or operator != but does not override Object.GetHashCode()
- //public static bool operator ==(LayoutSize r1, LayoutSize r2)
- //{
- // return r1.EqualTo(r2);
- //}
- //public static bool operator !=(LayoutSize r1, LayoutSize r2)
- //{
- // return !r1.EqualTo(r2);
- //}
-
-
- public int Width
- {
- //This should be blocked! Otherwise, user can set multiple-cascading property setting like "LinearLayout.CellPadding.Width = 100;". This will not be working!
- //set
- //{
- // LayoutPINVOKE.LayoutSize_width_set(swigCPtr, value);
- // if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- //}
- get
- {
- int ret = Interop.LayoutSize.LayoutSize_width_get(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- }
-
- public int Height
- {
- //This should be blocked! Otherwise, user can set multiple-cascading property setting like "LinearLayout.CellPadding.Height = 100;". This will not be working!
- //set
- //{
- // LayoutPINVOKE.LayoutSize_height_set(swigCPtr, value);
- // if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- //}
- get
- {
- int ret = Interop.LayoutSize.LayoutSize_height_get(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- }
}
}
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// [Draft] This class represents a layout size (width and height), non mutable.
- /// </summary>
- internal class LayoutSizeEx : IEquatable<LayoutSizeEx>
- {
- /// <summary>
- /// [Draft] Constructor from width and height
- /// </summary>
- /// <param name="width">Int to initialize with.</param>
- /// <param name="height">Int to initialize with.</param>
- public LayoutSizeEx(int width, int height)
- {
- Width = width;
- Height = height;
- }
-
- /// <summary>
- /// Computes a hash code for this LayoutSize for use in hash based collections.
- /// </summary>
- /// <returns>A non unique hash code .</returns>
- public override int GetHashCode()
- {
- return Width ^ Height;
- }
-
- /// <summary>
- /// Determines whether the specified object is equal to the current object.
- /// </summary>
- /// <param name="obj">The object to compare with the current object.</param>
- /// <returns>true if equal LayoutSize, else false.</returns>
- public override bool Equals(object obj)
- {
- LayoutSizeEx layoutSizeEx = (LayoutSizeEx)obj;
- if (layoutSizeEx != null)
- {
- return this.Equals(layoutSizeEx);
- }
- return false;
- }
-
- /// <summary>
- /// Whether the values of two LayoutSize objects are equals
- /// </summary>
- /// <param name="obj">Object to be compared against.</param>
- /// <returns>true if obj is equal to this LayoutSize.</returns>
- public bool Equals(LayoutSizeEx obj)
- {
- LayoutSizeEx layoutSize = obj;
- return ((layoutSize.Width == Width) && (layoutSize.Height == Height));
- }
-
- /// <summary>
- /// [Draft] Get the width value of this layout
- /// </summary>
- public int Width{ get; private set; }
-
- /// <summary>
- /// [Draft] Get the height value of this layout
- /// </summary>
- public int Height{ get; private set; }
-
- }
-}
-/* Copyright (c) 2018 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*
*/
-using System.ComponentModel;
+
+using System;
+using Tizen.NUI.BaseComponents;
+using System.Collections.Generic;
namespace Tizen.NUI
{
/// <summary>
/// [Draft] This class implements a linear box layout, automatically handling right to left or left to right direction change.
/// </summary>
- internal class LinearLayout : LayoutGroupWrapper
+ internal class LinearLayout : LayoutGroup
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- internal LinearLayout(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.LinearLayout.LinearLayout_SWIGUpcast(cPtr), cMemoryOwn)
+ /// <summary>
+ /// [Draft] Enumeration for the direction in which the content is laid out
+ /// </summary>
+ public enum Orientation
{
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ /// <summary>
+ /// Horizontal (row)
+ /// </summary>
+ Horizontal,
+ /// <summary>
+ /// Vertical (column)
+ /// </summary>
+ Vertical
}
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LinearLayout obj)
+ /// <summary>
+ /// [Draft] Enumeration for the alignment of the linear layout items
+ /// </summary>
+ public enum Alignment
{
- return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ /// <summary>
+ /// At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation)
+ /// </summary>
+ Begin = 0x1,
+ /// <summary>
+ /// At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation)
+ /// </summary>
+ End = 0x2,
+ /// <summary>
+ /// At the horizontal center of the container
+ /// </summary>
+ CenterHorizontal = 0x4,
+ /// <summary>
+ /// At the top edge of the container
+ /// </summary>
+ Top = 0x8,
+ /// <summary>
+ /// At the bottom edge of the container
+ /// </summary>
+ Bottom = 0x10,
+ /// <summary>
+ /// At the vertical center of the container
+ /// </summary>
+ CenterVertical = 0x20
}
- protected override void Dispose(DisposeTypes type)
+ struct HeightAndWidthState
{
- if (disposed)
+ public MeasuredSize.StateType widthState;
+ public MeasuredSize.StateType heightState;
+
+ public HeightAndWidthState( MeasuredSize.StateType width, MeasuredSize.StateType height)
{
- return;
+ widthState = width;
+ heightState = height;
}
+ }
- if (type == DisposeTypes.Explicit)
+ /// <summary>
+ /// [Draft] Get/Set the orientation in the layout
+ /// </summary>
+ public LinearLayout.Orientation LinearOrientation
+ {
+ get
{
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
-
+ return _linearOrientation;
}
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ set
{
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.LinearLayout.delete_LinearLayout(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ _linearOrientation = value;
+ RequestLayout();
}
- base.Dispose(type);
}
- internal static new class ChildProperty
- {
- internal static readonly int WEIGHT = Interop.LinearLayout.LinearLayout_ChildProperty_WEIGHT_get();
- }
- public LinearLayout() : this(Interop.LinearLayout.LinearLayout_New(), true)
+ /// <summary>
+ /// [Draft] Get/Set the padding between cells in the layout
+ /// </summary>
+ public Size2D CellPadding
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ get
+ {
+ return _cellPadding;
+ }
+ set
+ {
+ _cellPadding = value;
+ RequestLayout();
+ }
}
- public static LinearLayout DownCast(BaseHandle handle)
- {
- LinearLayout ret = new LinearLayout(Interop.LinearLayout.LinearLayout_DownCast(BaseHandle.getCPtr(handle)), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
- internal LinearLayout(LinearLayout other) : this(Interop.LinearLayout.new_LinearLayout__SWIG_1(LinearLayout.getCPtr(other)), true)
+ /// <summary>
+ /// [Draft] Get/Set the alignment in the layout
+ /// </summary>
+ public LinearLayout.Alignment LinearAlignment{ get; set; } = Alignment.CenterVertical;
+
+ private float _totalLength = 0.0f;
+ private Size2D _cellPadding = new Size2D(0,0);
+ private Orientation _linearOrientation = Orientation.Horizontal;
+
+ /// <summary>
+ /// [Draft] Constructor
+ /// </summary>
+ public LinearLayout()
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal LinearLayout Assign(LinearLayout other)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- LinearLayout ret = new LinearLayout(Interop.LinearLayout.LinearLayout_Assign(swigCPtr, LinearLayout.getCPtr(other)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ if (_linearOrientation == Orientation.Horizontal)
+ {
+ MeasureHorizontal(widthMeasureSpec, heightMeasureSpec);
+ }
+ else
+ {
+ MeasureVertical(widthMeasureSpec, heightMeasureSpec);
+ }
}
- internal void SetCellPadding(LayoutSize size)
+ protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- Interop.LinearLayout.LinearLayout_SetCellPadding(swigCPtr, LayoutSize.getCPtr(size));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ if (_linearOrientation == Orientation.Horizontal)
+ {
+ LayoutHorizontal(left, top, right, bottom);
+ }
+ else
+ {
+ LayoutVertical(left, top, right, bottom);
+ }
}
- internal LayoutSize GetCellPadding()
+ private void MeasureHorizontal(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- LayoutSize ret = new LayoutSize(Interop.LinearLayout.LinearLayout_GetCellPadding(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ var widthMode = widthMeasureSpec.Mode;
+ var heightMode = heightMeasureSpec.Mode;
+ bool isExactly = ( widthMode == MeasureSpecification.ModeType.Exactly );
+ bool matchHeight = false;
+ bool allFillParent = true;
+ float maxHeight = 0.0f;
+ float alternativeMaxHeight = 0.0f;
+ float weightedMaxHeight = 0.0f;
+ float totalWeight = 0.0f;
+ // Reset total length
+ _totalLength = 0.0f;
+ LayoutLength usedExcessSpace = new LayoutLength(0);
- internal void SetOrientation(LinearLayout.Orientation orientation)
- {
- Interop.LinearLayout.LinearLayout_SetOrientation(swigCPtr, (int)orientation);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ HeightAndWidthState childState = new HeightAndWidthState(MeasuredSize.StateType.MeasuredSizeOK,
+ MeasuredSize.StateType.MeasuredSizeOK);
- internal LinearLayout.Orientation GetOrientation()
- {
- LinearLayout.Orientation ret = (LinearLayout.Orientation)Interop.LinearLayout.LinearLayout_GetOrientation(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ // Measure children, and determine if further resolution is required
- internal void SetAlignment(LinearLayout.Alignment alignment)
- {
- Interop.LinearLayout.LinearLayout_SetAlignment(swigCPtr, (uint)alignment);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ // 1st phase:
+ // We cycle through all children and measure children with weight 0 (non weighted children) according to their specs
+ // to accumulate total used space in totalLength based on measured sizes and margins.
+ // Weighted children are not measured at this phase.
+ // Available space for weighted children will be calculated in the phase 2 based on totalLength value.
- internal LinearLayout.Alignment GetAlignment()
- {
- LinearLayout.Alignment ret = (LinearLayout.Alignment)Interop.LinearLayout.LinearLayout_GetAlignment(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
+ Log.Info("NUI", "Measuring Horizontal, " + _children.Count + " child(ren) with parent width mode:" + widthMode + ",height mode:" + heightMode + "\n");
- internal enum PropertyRange
- {
- CHILD_PROPERTY_START_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX,
- CHILD_PROPERTY_END_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000
- }
+ foreach( LayoutItem childLayout in _children )
+ {
+ LayoutLength childDesiredWidth = new LayoutLength(childLayout.Owner.WidthSpecification);
+ LayoutLength childDesiredHeight = new LayoutLength(childLayout.Owner.HeightSpecification);
+ float childWeight = childLayout.Owner.Weight;
+ Extents childMargin = childLayout.Owner.Margin;
+ Log.Info("NUI", "Retrieved parameters for child:" + childLayout.Owner.Name
+ + " childDesiredWidth: " + childDesiredWidth.AsRoundedValue()
+ + " childDesiredHeight:" + childDesiredHeight.AsRoundedValue()
+ + " childWeight:" + childWeight+ "\n");
- /// <summary>
- /// [Draft] Get/Set the orientation in the layout
- /// </summary>
- public LinearLayout.Orientation LinearOrientation
+ totalWeight += childWeight;
+
+ bool useExcessSpace = (childDesiredWidth.AsRoundedValue() == 0 ) && (childWeight > 0);
+ if( isExactly && useExcessSpace )
+ {
+ _totalLength += childMargin.Start + childMargin.End;
+ }
+ else
+ {
+ if( useExcessSpace )
+ {
+ // The widthMode is either UNSPECIFIED or AT_MOST, and
+ // this child is only laid out using excess space. Measure
+ // using WRAP_CONTENT so that we can find out the view's
+ // optimal width.
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(widthMeasureSpec, new LayoutLength(childLayout.Owner.Padding.Start + childLayout.Owner.Padding.End),
+ new LayoutLength(LayoutParamPolicies.WrapContent) );
+ MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(heightMeasureSpec, new LayoutLength(childLayout.Owner.Padding.Top + childLayout.Owner.Padding.Bottom),
+ childDesiredHeight);
+ childLayout.Measure( childWidthMeasureSpec, childHeightMeasureSpec);
+ usedExcessSpace += childLayout.MeasuredWidth.Size;
+ }
+ else
+ {
+ MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec);
+ }
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+
+ LayoutLength length = childWidth + childMargin.Start + childMargin.End;
+ if( isExactly )
+ {
+ _totalLength += length.AsDecimal();
+ }
+ else
+ {
+ _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + CellPadding.Width);
+ }
+ }
+
+ bool matchHeightLocally = false;
+ if(heightMode != MeasureSpecification.ModeType.Exactly && (int)childDesiredHeight.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Will have to re-measure at least this child when we know exact height.
+ matchHeight = true;
+ matchHeightLocally = true;
+ }
+
+ LayoutLength marginHeight = new LayoutLength(childMargin.Top + childMargin.Bottom);
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size + marginHeight;
+
+ if( childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall )
+ {
+ childState.widthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+ if( childLayout.MeasuredHeightAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+
+ maxHeight = Math.Max( maxHeight, childHeight.AsDecimal());
+ allFillParent = ( allFillParent && childDesiredHeight.AsRoundedValue() == LayoutParamPolicies.MatchParent );
+
+ if( childWeight > 0 )
+ {
+ /*
+ * Heights of weighted Views are bogus if we end up
+ * remeasuring, so keep them separate.
+ */
+ weightedMaxHeight = Math.Max( weightedMaxHeight, matchHeightLocally ? marginHeight.AsDecimal() : childHeight.AsDecimal());
+ }
+ else
+ {
+ alternativeMaxHeight = Math.Max( alternativeMaxHeight, matchHeightLocally ? marginHeight.AsDecimal() : childHeight.AsDecimal() );
+ }
+ } // foreach
+
+ Extents padding = Owner.Padding;
+ _totalLength += padding.Start + padding.End;
+ LayoutLength widthSize = new LayoutLength(_totalLength);
+ widthSize = new LayoutLength( Math.Max( widthSize.AsDecimal(), SuggestedMinimumWidth.AsDecimal()));
+ MeasuredSize widthSizeAndState = ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
+ widthSize = widthSizeAndState.Size;
+
+ if (!allFillParent && heightMode != MeasureSpecification.ModeType.Exactly)
+ {
+ maxHeight = alternativeMaxHeight;
+ }
+ maxHeight += padding.Top + padding.Bottom;
+ maxHeight = Math.Max( maxHeight, SuggestedMinimumHeight.AsRoundedValue() );
+
+ widthSizeAndState.State = childState.widthState;
+
+ SetMeasuredDimensions(widthSizeAndState,
+ ResolveSizeAndState( new LayoutLength(maxHeight), heightMeasureSpec, childState.heightState ));
+
+ if (matchHeight)
+ {
+ ForceUniformHeight( _children.Count, widthMeasureSpec );
+ }
+ } // MeasureHorizontally
+
+ void MeasureVertical( MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec )
{
- get
+ var widthMode = widthMeasureSpec.Mode;
+ var heightMode = heightMeasureSpec.Mode;
+ bool isExactly = ( heightMode == MeasureSpecification.ModeType.Exactly);
+ bool matchWidth = false;
+ bool allFillParent = true;
+ float maxWidth = 0.0f;
+ float alternativeMaxWidth = 0.0f;
+ float weightedMaxWidth = 0.0f;
+ float totalWeight = 0.0f;
+
+ // Reset total length
+ _totalLength = 0.0f;
+ LayoutLength usedExcessSpace = new LayoutLength(0);
+
+ HeightAndWidthState childState = new HeightAndWidthState(MeasuredSize.StateType.MeasuredSizeOK,
+ MeasuredSize.StateType.MeasuredSizeTooSmall);
+
+
+ // measure children, and determine if further resolution is required
+
+ // 1st phase:
+ // We cycle through all children and measure children with weight 0 (non weighted children) according to their specs
+ // to accumulate total used space in mTotalLength based on measured sizes and margins.
+ // Weighted children are not measured at this phase.
+ // Available space for weighted children will be calculated in the phase 2 based on mTotalLength value.
+
+ Log.Info("NUI", "Measuring Vertical[" + _children.Count + "] child with parent width mode:" + widthMode + ",height mode:" + heightMode + "\n");
+
+ uint index = 0;
+ foreach( LayoutItem childLayout in _children )
{
- return GetOrientation();
+ LayoutLength childDesiredWidth = new LayoutLength(childLayout.Owner.WidthSpecification);
+ LayoutLength childDesiredHeight = new LayoutLength(childLayout.Owner.HeightSpecification);
+ float childWeight = childLayout.Owner.Weight;
+ Extents childMargin = childLayout.Owner.Margin;
+ Log.Info("NUI", "Retrieved parameters for child:" + childLayout.Owner.Name
+ + " desiredWidth: " + childDesiredWidth.AsRoundedValue()
+ + " desiredHeight:" + childDesiredHeight.AsRoundedValue()
+ + " childWeight:" + childWeight + "\n");
+
+ totalWeight += childWeight;
+
+ bool useExcessSpace = (childDesiredHeight.AsRoundedValue() == 0) && (childWeight > 0);
+
+ if( isExactly && useExcessSpace )
+ {
+ LayoutLength totalLength = new LayoutLength(_totalLength);
+ _totalLength = Math.Max( totalLength.AsDecimal(), (totalLength + childMargin.Top + childMargin.Bottom).AsDecimal() );
+ }
+ else
+ {
+ LayoutLength childHeight = new LayoutLength(0);
+ if( useExcessSpace )
+ {
+ // The heightMode is either Unspecified or AtMost, and
+ // this child is only laid out using excess space. Measure
+ // using WrapContent so that we can find out the view's
+ // optimal height. We'll restore the original height of 0
+ // after measurement.
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification( widthMeasureSpec,
+ new LayoutLength(childLayout.Owner.Padding.Start + childLayout.Owner.Padding.End),
+ childDesiredWidth);
+ MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification( heightMeasureSpec,
+ new LayoutLength(childLayout.Owner.Padding.Top + childLayout.Owner.Padding.Bottom),
+ new LayoutLength(LayoutParamPolicies.WrapContent) );
+ childLayout.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
+ childHeight = childLayout.MeasuredHeight.Size;
+ usedExcessSpace += childHeight;
+ }
+ else
+ {
+ MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+ childHeight = childLayout.MeasuredHeight.Size;
+ }
+
+ float length = (childHeight + childMargin.Top + childMargin.Bottom).AsDecimal();
+ float cellPadding = CellPadding.Height;
+ // No need to add cell padding to the end of last item.
+ if (index>=_children.Count-1)
+ {
+ cellPadding = 0.0f;
+ }
+ _totalLength = Math.Max( _totalLength, _totalLength + length + cellPadding );
+ }
+
+ bool matchWidthLocally = false;
+ if( widthMode != MeasureSpecification.ModeType.Exactly && childDesiredWidth == new LayoutLength(LayoutParamPolicies.MatchParent) )
+ {
+ // Will have to re-measure at least this child when we know exact height.
+ matchWidth = true;
+ matchWidthLocally = true;
+ }
+
+ float marginWidth = (childLayout.Owner.Margin.Start) + (childLayout.Owner.Margin.End);
+ LayoutLength childWidth = new LayoutLength(childLayout.MeasuredWidth.Size.AsDecimal() + marginWidth);
+
+ // was combineMeasuredStates()
+ if (childLayout.MeasuredWidthAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.widthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+ if (childLayout.MeasuredHeightAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+
+ maxWidth = (Math.Max( maxWidth, childWidth.AsDecimal()));
+ allFillParent = (allFillParent && (childDesiredWidth == new LayoutLength(LayoutParamPolicies.MatchParent)));
+
+ float widthforWeight = childWidth.AsDecimal();
+ if (matchWidthLocally)
+ {
+ widthforWeight = marginWidth;
+ }
+
+ if (childWeight > 0)
+ {
+ /*
+ * Widths of weighted Views are bogus if we end up remeasuring, so keep them separate.
+ */
+ weightedMaxWidth = Math.Max( weightedMaxWidth, widthforWeight);
+ }
+ else
+ {
+ alternativeMaxWidth = Math.Max( alternativeMaxWidth, widthforWeight);
+ }
+ } // foreach
+
+
+ Extents padding = Owner.Padding;
+ _totalLength += padding.Top + padding.Bottom;
+ LayoutLength heightSize = new LayoutLength(_totalLength);
+ heightSize = new LayoutLength(Math.Max( heightSize.AsDecimal(), SuggestedMinimumHeight.AsDecimal() ));
+ MeasuredSize heightSizeAndState = ResolveSizeAndState( heightSize, heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
+ heightSize = heightSizeAndState.Size;
+
+ // Either expand children with weight to take up available space or
+ // shrink them if they extend beyond our current bounds. If we skipped
+ // measurement on any children, we need to measure them now.
+
+ // 2nd phase:
+ // We cycle through weighted children now (children with weight > 0).
+ // The children are measured with exact size equal to their share of the available space based on their weights.
+ // TotalLength is updated to include weighted children measured sizes.
+
+ float remainingExcess = heightSize.AsDecimal() - _totalLength + usedExcessSpace.AsDecimal();
+
+ if( remainingExcess != 0 && totalWeight > 0.0f )
+ {
+ float remainingWeightSum = totalWeight;
+
+ _totalLength = 0;
+
+ foreach( LayoutItem childLayout in _children )
+ {
+ int desiredWidth = childLayout.Owner.WidthSpecification;
+ int desiredHeight = childLayout.Owner.HeightSpecification;
+ float childWeight = childLayout.Owner.Weight;
+ Extents childMargin = childLayout.Owner.Margin;
+
+ float childHeight = 0;
+ if( childWeight > 0 )
+ {
+ float share = ( childWeight * remainingExcess ) / remainingWeightSum;
+ remainingExcess -= share;
+ remainingWeightSum -= childWeight;
+
+ // Always lay out weighted elements with intrinsic size regardless of the parent spec
+ // for consistency between specs.
+ if( desiredHeight == 0 )
+ {
+ // This child needs to be laid out from scratch using
+ // only its share of excess space.
+ childHeight = share;
+ }
+ else
+ {
+ // This child had some intrinsic width to which we
+ // need to add its share of excess space.
+ childHeight = childLayout.MeasuredHeight.Size.AsDecimal() + share;
+ }
+
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification( widthMeasureSpec,
+ new LayoutLength(Owner.Padding.Start + Owner.Padding.End),
+ new LayoutLength(desiredWidth) );
+
+ MeasureSpecification childHeightMeasureSpec = new MeasureSpecification( new LayoutLength(childHeight), MeasureSpecification.ModeType.Exactly);
+ childLayout.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
+
+ // Child may now not fit in vertical dimension.
+ if( childLayout.MeasuredHeightAndState.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ {
+ childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
+ }
+ }
+
+ bool matchWidthLocally = false;
+ if( widthMode != MeasureSpecification.ModeType.Exactly && desiredWidth == (int)ChildLayoutData.MatchParent )
+ {
+ // Will have to re-measure at least this child when we know exact height.
+ matchWidth = true;
+ matchWidthLocally = true;
+ }
+
+ float marginWidth = childMargin.Start + childMargin.End;
+ float childWidth = childLayout.MeasuredWidth.Size.AsDecimal() + marginWidth;
+ maxWidth = Math.Max( maxWidth, childWidth );
+ allFillParent = allFillParent && desiredWidth == (int)ChildLayoutData.MatchParent;
+
+
+ alternativeMaxWidth = Math.Max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
+
+ childHeight = childLayout.MeasuredHeight.Size.AsDecimal();
+ float length = childHeight + childMargin.Top + childMargin.Bottom;
+ float cellPadding = CellPadding.Height;
+ // No need to add cell padding to the end of last item.
+ if (index>=_children.Count-1)
+ {
+ cellPadding = 0.0f;
+ }
+ _totalLength = Math.Max( _totalLength, _totalLength + length + cellPadding );
+ } // foreach
+
+ // Add in our padding
+ _totalLength += Owner.Padding.Top + Owner.Padding.Bottom;
}
- set
+ else
{
- SetOrientation(value);
+ alternativeMaxWidth = Math.Max( alternativeMaxWidth, weightedMaxWidth );
}
- }
- /// <summary>
- /// [Draft] Get/Set the padding between cells in the layout
- /// </summary>
- public LayoutSize CellPadding
+ if (!allFillParent && widthMode != MeasureSpecification.ModeType.Exactly)
+ {
+ maxWidth = alternativeMaxWidth;
+ }
+ maxWidth += padding.Start + padding.End;
+ maxWidth = Math.Max( maxWidth, SuggestedMinimumWidth.AsRoundedValue());
+
+ heightSizeAndState.State = childState.heightState;
+
+ SetMeasuredDimensions( ResolveSizeAndState( new LayoutLength(maxWidth), widthMeasureSpec, childState.widthState ),
+ heightSizeAndState );
+
+ if( matchWidth )
+ {
+ ForceUniformWidth( _children.Count, heightMeasureSpec );
+ }
+ } // MeasureVertically
+
+ void LayoutHorizontal(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- get
+ Log.Info("NUI", "left,top,right,bottom:" + left.AsRoundedValue() + "," + top.AsRoundedValue()
+ + " " + right .AsRoundedValue() + "," + bottom.AsRoundedValue() + "\n");
+ bool isLayoutRtl = Owner.LayoutDirection == ViewLayoutDirectionType.RTL;
+
+ LayoutLength childTop = new LayoutLength(Owner.Padding.Top);
+ LayoutLength childLeft = new LayoutLength(Owner.Padding.Start);
+
+ // Where bottom of child should go
+ LayoutLength height = new LayoutLength(bottom - top);
+
+ // Space available for child
+ LayoutLength childSpace = new LayoutLength( height - Owner.Padding.Top - Owner.Padding.Bottom);
+
+ int count = _children.Count;
+
+ switch (LinearAlignment)
{
- return GetCellPadding();
+ case Alignment.Begin:
+ default:
+ // totalLength contains the padding already
+ // In case of RTL map BEGIN alignment to the right edge
+ if (isLayoutRtl)
+ {
+ childLeft = new LayoutLength(Owner.Padding.Start + right.AsDecimal() - left.AsDecimal() - _totalLength);
+ }
+ else
+ {
+ childLeft = new LayoutLength(Owner.Padding.Start);
+ }
+ break;
+ case Alignment.End:
+ // totalLength contains the padding already
+ // In case of RTL map END alignment to the left edge
+ if (isLayoutRtl)
+ {
+ childLeft = new LayoutLength(Owner.Padding.Start);
+ }
+ else
+ {
+ childLeft = new LayoutLength(Owner.Padding.Start + right.AsDecimal() - left.AsDecimal() - _totalLength);
+ }
+ break;
+ case Alignment.CenterHorizontal:
+ // totalLength contains the padding already
+ childLeft = new LayoutLength(Owner.Padding.Start + (right.AsDecimal() - left.AsDecimal() - _totalLength) / 2.0f);
+ break;
}
- set
+
+ int start = 0;
+ int dir = 1;
+
+ // In case of RTL, start drawing from the last child.
+ if (isLayoutRtl)
{
- SetCellPadding(value);
+ start = count - 1;
+ dir = -1;
}
- }
- /// <summary>
- /// [Draft] Get/Set the alignment in the layout
- /// </summary>
- public LinearLayout.Alignment LinearAlignment
+ for( int i = 0; i < count; i++)
+ {
+ int childIndex = start + dir * i;
+ // Get a reference to the childLayout at the given index
+ LayoutItem childLayout = _children[childIndex];
+ if( childLayout != null )
+ {
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+ Extents childMargin = childLayout.Owner.Margin;
+
+ switch ( LinearAlignment )
+ {
+ case Alignment.Top:
+ childTop = new LayoutLength(Owner.Padding.Top + childMargin.Top);
+ break;
+ case Alignment.Bottom:
+ childTop = new LayoutLength(height - Owner.Padding.Bottom - childHeight - childMargin.Bottom);
+ break;
+ case Alignment.CenterVertical: // FALLTHROUGH
+ default:
+ childTop = new LayoutLength(Owner.Padding.Top + ( ( childSpace - childHeight ).AsDecimal() / 2.0f ) + childMargin.Top - childMargin.Bottom);
+ break;
+ }
+ childLeft += childMargin.Start;
+ childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+ childLeft += childWidth + childMargin.End + CellPadding.Width;
+ }
+ }
+ } // LayoutHorizontally
+
+ void LayoutVertical(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- get
+ Log.Info("NUI", "left,top,right,bottom:" + left.AsRoundedValue() + "," + top.AsRoundedValue()
+ + " " + right .AsRoundedValue() + "," + bottom.AsRoundedValue() + "\n");
+
+ LayoutLength childTop = new LayoutLength(Owner.Padding.Top);
+ LayoutLength childLeft = new LayoutLength(Owner.Padding.Start);
+
+ // Where end of child should go
+ LayoutLength width = new LayoutLength(right - left);
+
+ // Space available for child
+ LayoutLength childSpace = new LayoutLength( width - Owner.Padding.Start - Owner.Padding.End);
+
+ int count = _children.Count;
+
+ switch (LinearAlignment)
{
- return GetAlignment();
+ case Alignment.Top:
+ // totalLength contains the padding already
+ childTop = new LayoutLength( Owner.Padding.Top );
+ break;
+ case Alignment.Bottom:
+ // totalLength contains the padding already
+ childTop = new LayoutLength( Owner.Padding.Top + bottom.AsDecimal() - top.AsDecimal() - _totalLength);
+ break;
+ case Alignment.CenterVertical:
+ default:
+ // totalLength contains the padding already
+ childTop = new LayoutLength(Owner.Padding.Top + ( bottom.AsDecimal() - top.AsDecimal() - _totalLength ) / 2.0f);
+ break;
}
- set
+
+ for( int i = 0; i < count; i++)
{
- SetAlignment(value);
+ LayoutItem childLayout = _children[i];
+ if( childLayout != null )
+ {
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+ Extents childMargin = childLayout.Owner.Margin;
+
+ childTop += childMargin.Top;
+ switch ( LinearAlignment )
+ {
+ case Alignment.Begin:
+ default:
+ {
+ childLeft = new LayoutLength( Owner.Padding.Start + childMargin.Start);
+ break;
+ }
+ case Alignment.End:
+ {
+ childLeft = new LayoutLength(width - Owner.Padding.End - childWidth - childMargin.End);
+ break;
+ }
+ case Alignment.CenterHorizontal:
+ {
+ childLeft = new LayoutLength(Owner.Padding.Start + (( childSpace - childWidth ).AsDecimal() / 2.0f) + childMargin.Start - childMargin.End);
+ break;
+ }
+ }
+ childLayout.Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
+ childTop += childHeight + childMargin.Bottom + CellPadding.Height;
+ }
}
- }
+ } // LayoutVertical
- /// <summary>
- /// [Draft] Enumeration for the direction in which the content is laid out
- /// </summary>
- public enum Orientation
+ void ForceUniformHeight( int count, MeasureSpecification widthMeasureSpec )
{
- /// <summary>
- /// Horizontal (row)
- /// </summary>
- Horizontal,
- /// <summary>
- /// Vertical (column)
- /// </summary>
- Vertical
+ // Pretend that the linear layout has an exact size. This is the measured height of
+ // ourselves. The measured height should be the max height of the children, changed
+ // to accommodate the heightMeasureSpec from the parent
+ MeasureSpecification uniformMeasureSpec = new MeasureSpecification( MeasuredHeight.Size, MeasureSpecification.ModeType.Exactly);
+ for (int i = 0; i < count; ++i)
+ {
+ LayoutItem childLayout = _children[i];
+ if (childLayout != null)
+ {
+ LayoutLength desiredWidth = new LayoutLength(childLayout.Owner.WidthSpecification);
+ LayoutLength desiredHeight = new LayoutLength(Owner.WidthSpecification );
+
+ if (desiredHeight.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Temporarily force children to reuse their old measured width
+ LayoutLength oldWidth = desiredWidth;
+ childLayout.Owner.WidthSpecification = (int)childLayout.MeasuredWidth.Size.AsRoundedValue();
+ // Remeasure with new dimensions
+ MeasureChildWithMargins( childLayout, widthMeasureSpec, new LayoutLength(0),
+ uniformMeasureSpec, new LayoutLength(0) );
+
+ childLayout.Owner.WidthSpecification = (int)oldWidth.AsRoundedValue();
+ }
+ }
+ }
}
- /// <summary>
- /// [Draft] Enumeration for the alignment of the linear layout items
- /// </summary>
- public enum Alignment
+ void ForceUniformWidth( int count, MeasureSpecification heightMeasureSpec )
{
- /// <summary>
- /// At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation)
- /// </summary>
- Begin = 0x1,
- /// <summary>
- /// At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation)
- /// </summary>
- End = 0x2,
- /// <summary>
- /// At the horizontal center of the container
- /// </summary>
- CenterHorizontal = 0x4,
- /// <summary>
- /// At the top edge of the container
- /// </summary>
- Top = 0x8,
- /// <summary>
- /// At the bottom edge of the container
- /// </summary>
- Bottom = 0x10,
- /// <summary>
- /// At the vertical center of the container
- /// </summary>
- CenterVertical = 0x20
+ // Pretend that the linear layout has an exact size.
+ MeasureSpecification uniformMeasureSpec = new MeasureSpecification( MeasuredWidth.Size, MeasureSpecification.ModeType.Exactly);
+ for (int i = 0; i < count; ++i)
+ {
+ LayoutItem childLayout = _children[i];
+ if (childLayout != null)
+ {
+ LayoutLength desiredWidth = new LayoutLength(childLayout.Owner.WidthSpecification);
+ LayoutLength desiredHeight = new LayoutLength(Owner.WidthSpecification );
+
+ if( desiredWidth.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Temporarily force children to reuse their old measured height
+ LayoutLength oldHeight = desiredHeight;
+ childLayout.Owner.HeightSpecification = (int)childLayout.MeasuredHeight.Size.AsRoundedValue();
+
+ // Remeasure with new dimensions
+ MeasureChildWithMargins( childLayout, uniformMeasureSpec, new LayoutLength(0),
+ heightMeasureSpec, new LayoutLength(0));
+
+ childLayout.Owner.HeightSpecification = (int)oldHeight.AsRoundedValue();
+ }
+ }
+ }
}
- }
+ } //LinearLayout
-}
+} // namespace
/// [Draft] A MeasureSpecification is used during the Measure pass by a LayoutGroup to inform it's children how to be measured.
/// For instance, it may measure a child with an exact width and an unspecified height in order to determine height for width.
/// </summary>
- internal class MeasureSpecification
+ internal struct MeasureSpecification
{
/// <summary>
/// MeasureSpecification Size value.
/// </summary>
- public LayoutLengthEx Size;
+ public LayoutLength Size;
/// <summary>
/// MeasureSpecification Mode.
/// </summary>
/// <param name="size">size value.</param>
/// <param name="mode">mode vaue.</param>
- public MeasureSpecification(LayoutLengthEx size, MeasureSpecification.ModeType mode)
+ public MeasureSpecification(LayoutLength size, MeasureSpecification.ModeType mode)
{
Size = size;
Mode = mode;
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/// <summary>
/// [Draft] Class that encodes a measurement and a measure state, which is set if the measured size is too small.
/// </summary>
- internal class MeasuredSize : global::System.IDisposable
+ internal struct MeasuredSize
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- protected bool swigCMemOwn;
-
- internal MeasuredSize(global::System.IntPtr cPtr, bool cMemoryOwn)
- {
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- }
-
- internal static global::System.Runtime.InteropServices.HandleRef getCPtr(MeasuredSize obj)
- {
- return (obj.Equals(null)) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
- }
-
- //A Flag to check who called Dispose(). (By User or DisposeQueue)
- private bool isDisposeQueued = false;
/// <summary>
- /// A Flat to check if it is already disposed.
+ /// Constructor
/// </summary>
- protected bool disposed = false;
-
- /// <summary>
- /// Dispose.
- /// </summary>
- ~MeasuredSize()
+ /// <param name="measuredSize">size parameter</param>
+ /// <param name="state">State</param>
+ public MeasuredSize(LayoutLength measuredSize, MeasuredSize.StateType state)
{
- if (!isDisposeQueued)
- {
- isDisposeQueued = true;
- DisposeQueue.Instance.Add(this);
- }
+ Size = measuredSize;
+ State = state;
}
/// <summary>
- /// Dispose.
+ /// Creates a MeasuredSize from a LayoutLength
/// </summary>
- public void Dispose()
+ /// <param name="measuredSize">LayoutLength to create </param>
+ public static implicit operator MeasuredSize(LayoutLength measuredSize)
{
- //Throw excpetion if Dispose() is called in separate thread.
- if (!Window.IsInstalled())
- {
- throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
- }
-
- if (isDisposeQueued)
- {
- Dispose(DisposeTypes.Implicit);
- }
- else
- {
- Dispose(DisposeTypes.Explicit);
- System.GC.SuppressFinalize(this);
- }
+ return new MeasuredSize(measuredSize, StateType.MeasuredSizeOK);
}
/// <summary>
- /// Dispose.
+ /// LayoutLength size property
/// </summary>
- protected virtual void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.MeasuredSize.delete_MeasuredSize(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- disposed = true;
- }
-
- public MeasuredSize() : this(Interop.MeasuredSize.new_MeasuredSize__SWIG_0(), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public MeasuredSize(LayoutLength measuredSize) : this(Interop.MeasuredSize.new_MeasuredSize__SWIG_1(LayoutLength.getCPtr(measuredSize)), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- public MeasuredSize(LayoutLength measuredSize, MeasuredSize.StateType state) : this(Interop.MeasuredSize.new_MeasuredSize__SWIG_2(LayoutLength.getCPtr(measuredSize), (int)state), true)
- {
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
+ public LayoutLength Size{ get; set;}
/// <summary>
- /// Determines whether the specified object is equal to the current object.
+ /// Measured state for this size.
/// </summary>
- /// <param name="obj">The object to compare with the current object.</param>
- /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
- public override bool Equals(object obj)
- {
- MeasuredSize measuredSize = obj as MeasuredSize;
- bool equal = false;
- if ( measuredSize != null )
- {
- if ( Size == measuredSize.Size && State == measuredSize.State)
- {
- equal = true;
- }
- }
- return equal;
- }
+ public StateType State{ get; set; }
/// <summary>
- /// Gets the the hash code of this MeasuredSize.
+ /// Measured states for a Size value.
/// </summary>
- /// <returns>The Hash Code.</returns>
- /// <since_tizen> 5 </since_tizen>
- public override int GetHashCode()
- {
- return swigCPtr.Handle.GetHashCode();
- }
-
- private bool EqualTo(MeasuredSize value)
- {
- bool ret = Interop.MeasuredSize.MeasuredSize_EqualTo(swigCPtr, MeasuredSize.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private bool NotEqualTo(MeasuredSize value)
- {
- bool ret = Interop.MeasuredSize.MeasuredSize_NotEqualTo(swigCPtr, MeasuredSize.getCPtr(value));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public MeasuredSize.StateType State
- {
- get
- {
- return GetState();
- }
- set
- {
- SetState(value);
- }
- }
-
- private void SetState(MeasuredSize.StateType state)
- {
- Interop.MeasuredSize.MeasuredSize_SetState(swigCPtr, (int)state);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- private MeasuredSize.StateType GetState()
- {
- MeasuredSize.StateType ret = (MeasuredSize.StateType)Interop.MeasuredSize.MeasuredSize_GetState(swigCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- public LayoutLength Size
- {
- get
- {
- return GetSize();
- }
- set
- {
- SetSize(value);
- }
- }
-
- private void SetSize(LayoutLength size)
- {
- Interop.MeasuredSize.MeasuredSize_SetSize(swigCPtr, LayoutLength.getCPtr(size));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
- private LayoutLength GetSize()
- {
- LayoutLength ret = new LayoutLength(Interop.MeasuredSize.MeasuredSize_GetSize(swigCPtr), true);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
public enum StateType
{
/// <summary>
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// [Draft] Class that encodes a measurement and a measure state, which is set if the measured size is too small.
- /// </summary>
- internal class MeasuredSizeEx
- {
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="measuredSize">size parameter</param>
- /// <param name="state">State</param>
- public MeasuredSizeEx(LayoutLengthEx measuredSize, MeasuredSizeEx.StateType state)
- {
- Size = measuredSize;
- State = state;
- }
-
- /// <summary>
- /// Creates a MeasuredSize from a LayoutLength
- /// </summary>
- /// <param name="measuredSize">LayoutLength to create </param>
- public static implicit operator MeasuredSizeEx(LayoutLengthEx measuredSize)
- {
- return new MeasuredSizeEx(measuredSize, StateType.MeasuredSizeOK);
- }
-
- /// <summary>
- /// LayoutLength size property
- /// </summary>
- public LayoutLengthEx Size{ get; set;}
-
- /// <summary>
- /// Measured state for this size.
- /// </summary>
- public StateType State{ get; set; }
-
- /// <summary>
- /// Measured states for a Size value.
- /// </summary>
- public enum StateType
- {
- /// <summary>
- /// The measured size is good
- /// </summary>
- MeasuredSizeOK,
- /// <summary>
- /// The measured size is too small
- /// </summary>
- MeasuredSizeTooSmall
- }
- }
-}
internal class NDalic
{
- internal NDalic()
- {
- Tizen.Log.Error("NUI", "Create NDalic");
- }
-
public static uint int_to_uint(int x)
{
uint ret = Interop.NDalic.int_to_uint(x);
RTL
}
+ /// <summary>
+ /// [Draft] Available policies for layout parameters
+ /// </summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static class LayoutParamPolicies
+ {
+ /// <summary>
+ /// Constant which indicates child size should match parent size
+ /// </summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public const int MatchParent = -1;
+ /// <summary>
+ /// Constant which indicates parent should take the smallest size possible to wrap it's children with their desired size
+ /// </summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public const int WrapContent = -2;
+ }
+
+ /// <summary>
+ /// [Draft] Replaced by LayoutParamPolicies, will be removed once occurrences replaced.
+ /// </summary>
internal enum ChildLayoutData
{
/// <summary>
/// Constant which indicates child size should match parent size
/// </summary>
- MatchParent = -1,
+ MatchParent = LayoutParamPolicies.MatchParent,
/// <summary>
/// Constant which indicates parent should take the smallest size possible to wrap it's children with their desired size
/// </summary>
- WrapContent = -2,
+ WrapContent = LayoutParamPolicies.WrapContent,
}
internal enum ResourceLoadingStatusType
default: return Tizen.NUI.VerticalAlignmentType.Top;
}
});
- /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+
+ /// <summary>
+ /// "Please DO NOT use! This will be deprecated! Please use 'View Weight' instead of BindableProperty"
+ /// This needs to be hidden as inhouse API until all applications using it have been updated. Do not make public.
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty WeightProperty = BindableProperty.Create("Weight", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
var view = (View)bindable;
if (newValue != null)
{
- Tizen.NUI.Object.SetProperty(view.swigCPtr, LinearLayout.ChildProperty.WEIGHT, new Tizen.NUI.PropertyValue((float)newValue));
+ view.Weight = (float)newValue;
}
},
+
defaultValueCreator: (bindable) =>
{
var view = (View)bindable;
- float temp = 0.0f;
- Tizen.NUI.Object.GetProperty(view.swigCPtr, LinearLayout.ChildProperty.WEIGHT).Get(out temp);
- return temp;
+ return view.Weight;
});
+
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty LeftFocusableViewProperty = BindableProperty.Create(nameof(View.LeftFocusableView), typeof(View), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty StyleProperty = BindableProperty.Create("Style", typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue);
- internal readonly MergedStyle _mergedStyle;
+ /// <summary>
+ /// Flag to indicate if layout set explicitly via API call or View was automatically given a Layout.
+ /// </summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool layoutSet = false;
+
/// <summary>
/// Flag to allow Layouting to be disabled for Views.
/// Once a View has a Layout set then any children added to Views from then on will receive
/// automatic Layouts.
/// </summary>
- private static bool layoutingDisabled = true;
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static bool layoutingDisabled{get; set;} = true;
- private bool layoutSet = false; // Flag to indicate if SetLayout was called or View was automatically given a Layout
+ internal readonly MergedStyle _mergedStyle;
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ private LayoutItem _layout; // Exclusive layout assigned to this View.
+ private int _widthPolicy = LayoutParamPolicies.WrapContent; // Layout width policy
+ private int _heightPolicy = LayoutParamPolicies.WrapContent; // Layout height policy
+ private float _weight = 0.0f; // Weighting of child View in a Layout
+ private MeasureSpecification _measureSpecificationWidth; // Layout width and internal Mode
+ private MeasureSpecification _measureSpecificationHeight; // Layout height and internal Mode
private bool _backgroundImageSynchronosLoading = false;
private EventHandler _offWindowEventHandler;
private OffWindowEventCallbackType _offWindowEventCallback;
SetValue(Size2DProperty, value);
// Set Specification so when layouts measure this View it matches the value set here.
// All Views are currently Layouts.
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Width));
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Height));
+ MeasureSpecificationWidth = new MeasureSpecification(new LayoutLength(value.Width), MeasureSpecification.ModeType.Exactly);
+ MeasureSpecificationHeight = new MeasureSpecification(new LayoutLength(value.Height), MeasureSpecification.ModeType.Exactly);
NotifyPropertyChanged();
}
}
/// This is true by default.
/// </summary>
/// <remarks>If false, then the top-left of the view is used for the position.
- /// Setting this to false will allow scaling or rotation around the anchor-point without affecting the view's position.
+ /// Setting this to false will allow scaling or rotation around the pivot point without affecting the view's position.
/// </remarks>
/// <since_tizen> 3 </since_tizen>
public bool PositionUsesPivotPoint
set
{
SetValue(SizeWidthProperty, value);
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value));
+ WidthSpecification = (int)Math.Ceiling(value);
NotifyPropertyChanged();
}
}
set
{
SetValue(SizeHeightProperty, value);
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value));
+ HeightSpecification = (int)Math.Ceiling(value);
NotifyPropertyChanged();
}
}
{
case ResizePolicyType.UseNaturalSize:
{
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) );
+ WidthSpecification = LayoutParamPolicies.WrapContent;
break;
}
case ResizePolicyType.FillToParent:
{
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue((int)ChildLayoutData.MatchParent));
+ WidthSpecification = LayoutParamPolicies.MatchParent;
break;
}
case ResizePolicyType.FitToChildren:
{
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue((int)ChildLayoutData.WrapContent));
+ WidthSpecification = LayoutParamPolicies.WrapContent;
break;
}
default:
{
case ResizePolicyType.UseNaturalSize:
{
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) );
+ HeightSpecification = LayoutParamPolicies.WrapContent;
break;
}
case ResizePolicyType.FillToParent:
{
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue((int)ChildLayoutData.MatchParent));
+ HeightSpecification = LayoutParamPolicies.MatchParent;
break;
}
case ResizePolicyType.FitToChildren:
{
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue((int)ChildLayoutData.WrapContent));
+ HeightSpecification = LayoutParamPolicies.WrapContent;
break;
}
default:
{
SetValue(PaddingProperty, value);
NotifyPropertyChanged();
+ _layout?.RequestLayout();
}
}
}
set
{
- if (Layout != null)
+ if (_layout != null)
{
// Note: it only works if minimum size is >= than natural size.
// To force the size it should be done through the width&height spec or Size2D.
- Layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Width);
- Layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Height);
+ _layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Width);
+ _layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Height);
+ _layout.RequestLayout();
}
SetValue(MinimumSizeProperty, value);
NotifyPropertyChanged();
{
// We don't have Layout.Maximum(Width|Height) so we cannot apply it to layout.
// MATCH_PARENT spec + parent container size can be used to limit
+ if (_layout != null)
+ {
+ // Note: it only works if minimum size is >= than natural size.
+ // To force the size it should be done through the width&height spec or Size2D.
+ _layout.MinimumHeight = new Tizen.NUI.LayoutLength(value.Width);
+ _layout.MinimumWidth = new Tizen.NUI.LayoutLength(value.Height);
+ _layout.RequestLayout();
+ }
SetValue(MaximumSizeProperty, value);
NotifyPropertyChanged();
}
SetValue(SizeProperty, value);
// Set Specification so when layouts measure this View it matches the value set here.
// All Views are currently Layouts.
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Width));
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Height));
+ WidthSpecification = (int)Math.Ceiling(value.Width);
+ HeightSpecification = (int)Math.Ceiling(value.Height);
NotifyPropertyChanged();
}
}
{
SetValue(LayoutDirectionProperty, value);
NotifyPropertyChanged();
+ _layout?.RequestLayout();
}
}
{
SetValue(MarginProperty, value);
NotifyPropertyChanged();
+ _layout?.RequestLayout();
+ }
+ }
+
+ ///<summary>
+ /// The required policy for this dimension, ChildLayoutData enum or exact value.
+ ///</summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int WidthSpecification
+ {
+ get
+ {
+ return _widthPolicy;
+ }
+ set
+ {
+ _widthPolicy = value;
+ if (_widthPolicy >= 0)
+ {
+ _measureSpecificationWidth = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
+ Size2D.Width = _widthPolicy;
+ }
+ _layout?.RequestLayout();
+ }
+ }
+
+ ///<summary>
+ /// The required policy for this dimension, ChildLayoutData enum or exact value.
+ ///</summary>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int HeightSpecification
+ {
+ get
+ {
+ return _heightPolicy;
+ }
+ set
+ {
+ _heightPolicy = value;
+ if (_heightPolicy >= 0)
+ {
+ _measureSpecificationHeight = new MeasureSpecification( new LayoutLength(value), MeasureSpecification.ModeType.Exactly );
+ Size2D.Height = _heightPolicy;
+ }
+ _layout?.RequestLayout();
}
}
{
SetProperty(View.Property.PADDING, new Tizen.NUI.PropertyValue(value));
NotifyPropertyChanged();
+ _layout?.RequestLayout();
}
}
{
get
{
- int tmp = 0;
- if (GetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION).Get(out tmp) == false)
- {
- NUILog.Error("WidthSpecificationFixed get error!");
- }
- return tmp;
+ return _widthPolicy;
}
set
{
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value));
+ _widthPolicy = value;
+ _measureSpecificationWidth = new MeasureSpecification(new LayoutLength(value), MeasureSpecification.ModeType.Exactly);
+ Size2D.Width = value;
+ _layout?.RequestLayout();
}
}
{
get
{
- int tmp = 0;
- if (GetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION).Get(out tmp) == false)
- {
- NUILog.Error("HeightSpecificationFixed get error!");
- }
- return tmp;
+ return _heightPolicy;
}
set
{
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value));
+ _heightPolicy = value;
+ _measureSpecificationHeight = new MeasureSpecification(new LayoutLength(value), MeasureSpecification.ModeType.Exactly);
+ Size2D.Height = value;
+ _layout?.RequestLayout();
}
}
{
get
{
- int tmp = 0;
- if (GetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION).Get(out tmp) == false)
- {
- NUILog.Error("WidthSpecificationFixed get error!");
- }
- return (ChildLayoutData)tmp;
+ return (ChildLayoutData)_widthPolicy;
}
set
{
- SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue((int)value));
+ _widthPolicy = (int)value;
}
}
{
get
{
- int tmp = 0;
- if (GetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION).Get(out tmp) == false)
- {
- NUILog.Error("HeightSpecificationFixed get error!");
- }
- return (ChildLayoutData)tmp;
+ return (ChildLayoutData)_heightPolicy;
}
set
{
- SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue((int)value));
+ _heightPolicy = (int)value;
}
}
{
get
{
- return (float)GetValue(WeightProperty);
+ return _weight;
}
set
{
- SetValue(WeightProperty, value);
- NotifyPropertyChanged();
+ _weight = value;
+ _layout.RequestLayout();
}
}
}
/// <summary>
- /// Set the layout on this control.
+ /// Set the layout on this View. Replaces any existing Layout.
/// </summary>
/// <remarks>
/// </remarks>
{
get
{
- IntPtr cPtr = Interop.Layout.GetLayout__SWIG_1(View.getCPtr(this));
-
- HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle);
- Interop.BaseHandle.delete_BaseHandle(CPtr);
- CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- return basehandle as LayoutItem;
+ return _layout;
}
set
{
- Log.Info("NUI", "Set Layout on:" + Name + "\n");
+ // Do nothing if layout provided is already set on this View.
+ if (value == _layout)
+ {
+ return;
+ }
+
+ Log.Info("NUI", "Setting Layout on:" + Name + "\n");
layoutingDisabled = false;
layoutSet = true;
+
+ // If new layout being set already has a owner then that owner receives a replacement default layout.
+ // First check if the layout to be set already has a owner.
+ if ( value.Owner != null )
+ {
+ Log.Info("NUI", "Set layout already in use by another View: " + value.Owner.Name + "will get a LayoutGroup\n");
+ // Previous owner of the layout gets a default layout as a replacement.
+ value.Owner.Layout = new LayoutGroup();
+ }
+
+ // Remove existing layout from it's parent layout group.
+ _layout?.Unparent();
+
+ // Set layout to this view
SetLayout(value);
}
}
+ internal void SetLayout(LayoutItem layout)
+ {
+ _layout = layout;
+ _layout.AttachToOwner(this);
+ _layout.RequestLayout();
+ }
+
/// <summary>
- /// Set that layouting is required on this View. It will automatically receive a Layout.
+ /// Stores the calculated width value and its ModeType. Width component.
/// </summary>
- /// <remarks>
- /// </remarks>
- internal bool LayoutingRequired
+ internal MeasureSpecification MeasureSpecificationWidth
{
+ set
+ {
+ _measureSpecificationWidth = value;
+ _layout?.RequestLayout();
+ }
get
{
- bool result = Interop.View.View_IsLayoutingRequired(View.getCPtr(this));
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return result;
+ return _measureSpecificationWidth;
}
+ }
+
+ /// <summary>
+ /// Stores the calculated width value and its ModeType. Height component.
+ /// </summary>
+ internal MeasureSpecification MeasureSpecificationHeight
+ {
set
{
- Tizen.NUI.Interop.View.View_SetLayoutingRequired(View.getCPtr(this), value);
+ _measureSpecificationHeight = value;
+ _layout?.RequestLayout();
+ }
+ get
+ {
+ return _measureSpecificationHeight;
}
}
/// <since_tizen> 4 </since_tizen>
public override void Add(View child)
{
+ bool hasLayout = (_layout != null);
+ Log.Info("NUI", "Add:" + child.Name + " to View:" + Name + "which has layout[" + hasLayout + "] + \n");
+
if (null == child)
{
Tizen.Log.Fatal("NUI", "Child is null");
return;
}
- Log.Info("NUI", "Adding Child:" + child.Name + " to " + Name + "\n");
-
Container oldParent = child.GetParent();
if (oldParent != this)
{
+ // If child already has a parent then re-parent child
if (oldParent != null)
{
oldParent.Remove(child);
}
child.InternalParent = this;
- // Only give children a layout if their parent is an explicit container or a pure View.
- // Pure View meaning not derived from a View, e.g a Legacy container.
- // layoutSet flag is true when the View became a layout using the set Layout API opposed to automatically due to it's parent.
- // First time the set Layout API is used by any View the Window no longer has layoutingDisabled.
- if ((true == layoutSet || GetType() == typeof(View)) && null == child.Layout && false == layoutingDisabled)
- {
- Log.Info("NUI", "Parent[" + Name + "] Layout set[" + layoutSet.ToString() + "] Pure View[" + (!layoutSet).ToString() + "]\n");
- // If child is a View or explicitly set to require layouting then set child as a LayoutGroup.
- // If the child is derived from a View then it may be a legacy or existing container hence will do layouting itself.
- if (child.GetType() == typeof(View) || true == child.LayoutingRequired)
- {
- Log.Info("NUI", "Creating LayoutGroup for " + child.Name + " LayoutingRequired[" + child.LayoutingRequired.ToString() + "]\n");
- child.SetLayout(new LayoutGroup());
- }
- else
- {
- // Adding child as a leaf, layouting will not propagate past this child.
- // Legacy containers will be a LayoutItems too and layout their children how they wish.
- Log.Info("NUI", "Creating LayoutItem for " + child.Name + "\n");
- child.SetLayout(new LayoutItem());
- }
- }
-
- if (Layout)
- {
- Layout.LayoutChildren.Add(child.Layout);
- }
-
Interop.Actor.Actor_Add(swigCPtr, View.getCPtr(child));
+
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Children.Add(child);
/// <since_tizen> 4 </since_tizen>
public override void Remove(View child)
{
+ bool hasLayout = (_layout != null);
+ Log.Info("NUI","Removing View:" + child.Name + "layout[" + hasLayout.ToString() +"]\n");
+
Interop.Actor.Actor_Remove(swigCPtr, View.getCPtr(child));
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Children.Remove(child);
child.InternalParent = null;
- if (Layout)
- {
- if (child.Layout)
- {
- Layout.LayoutChildren.Remove(child.Layout);
- }
- }
-
if (ChildRemoved != null)
{
ChildRemovedEventArgs e = new ChildRemovedEventArgs
return (IntPtr)swigCPtr;
}
- internal void SetLayout(LayoutItem layout)
+ /// <summary>
+ /// Removes the layout from this View.
+ /// </summary>
+ internal void ResetLayout()
{
- Interop.Layout.SetLayout__SWIG_1(View.getCPtr(this), LayoutItem.getCPtr(layout));
- layout.LayoutChildren.Clear();
- foreach (View view in Children)
- {
- layout.LayoutChildren.Add(view.Layout);
- }
+ _layout = null;
}
internal ResourceLoadingStatusType GetBackgroundResourceStatus()
public class Layer : Container
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
- private global::System.IntPtr rootLayoutIntPtr;
- private global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
/// <summary>
/// Creates a Layer object.
internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Layer.Layer_SWIGUpcast(cPtr), cMemoryOwn)
{
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to this Layer.
- // Enables layouts added to the Layer to have a parent layout. As parent layout is needed to store measure spec properties.
- rootLayoutIntPtr = Interop.Window.Window_NewRootLayout();
- // Store HandleRef used by Add()
- rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
- // Add the root layout created above to this layer.
- Interop.Actor.Actor_Add(swigCPtr, rootLayoutCPtr);
}
/// <summary>
{
child.InternalParent = this;
}
- // If adding a View then set layout required flag
- if (child.GetType() == typeof(View))
- {
- Log.Info("NUI", "Add child[" + child.Name + "] LayoutingRequired set as pure view\n");
- child.LayoutingRequired = true;
- }
-
- Interop.Actor.Actor_Add(rootLayoutCPtr, View.getCPtr(child));
+ Interop.Actor.Actor_Add( swigCPtr , View.getCPtr(child));
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
Children.Add(child);
/// <since_tizen> 4 </since_tizen>
public override void Remove(View child)
{
- Interop.Actor.Actor_Remove(rootLayoutCPtr, View.getCPtr(child));
+ Interop.Actor.Actor_Remove( swigCPtr, View.getCPtr(child));
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+
/*
* Copyright(c) 2019 Samsung Electronics Co., Ltd.
*
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private global::System.Runtime.InteropServices.HandleRef stageCPtr;
- private readonly global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
private Layer _rootLayer;
private string _windowTitle;
- private readonly LayoutItem rootLayoutItem;
-
private List<Layer> _childLayers = new List<Layer>();
private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
{
stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
- localController = new LayoutController();
+ localController = new LayoutController(this);
NUILog.Debug("layoutController id:" + localController.GetId() );
-
- // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to the Window
- // Enables layouts added to the Window to have a parent layout. As parent layout is needed to store measure spec properties.
- // Currently without these measure specs the new layout added will always be the size of the window.
- global::System.IntPtr rootLayoutIntPtr = Interop.Window.Window_NewRootLayout();
- // Store HandleRef used by Add()
- rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
- Layer rootLayer = GetRootLayer();
- // Add the root layout created above to the root layer.
- Interop.Actor.Actor_Add( Layer.getCPtr(rootLayer), rootLayoutCPtr );
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- global::System.IntPtr rootControlLayoutIntPtr = Interop.Layout.GetLayout__SWIG_1(rootLayoutCPtr);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- rootLayoutItem = new LayoutItem(rootControlLayoutIntPtr, true);
}
}
}
}
+ internal LayoutController LayoutController
+ {
+ get
+ {
+ return localController;
+ }
+ }
+
/// <summary>
/// Feed a key-event into the window.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public void Add(View view)
{
- Interop.Actor.Actor_Add(rootLayoutCPtr, View.getCPtr(view));
+ Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
view.InternalParent = this.GetRootLayer();
/// <since_tizen> 3 </since_tizen>
public void Remove(View view)
{
- Interop.Actor.Actor_Remove(rootLayoutCPtr, View.getCPtr(view));
+ Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
view.InternalParent = null;
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if(rootLayoutItem != null)
- {
- rootLayoutItem.RequestLayout();
- }
+ // Resetting Window size should request a relayout of the tree.
}
internal Size2D GetWindowSize()
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if(rootLayoutItem != null)
- {
- rootLayoutItem.RequestLayout();
- }
+ // Setting Position of the window should request a relayout of the tree.
+
}
internal Position2D GetPosition()
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if(rootLayoutItem != null)
- {
- rootLayoutItem.RequestLayout();
- }
+ // Setting Position of the window should request a relayout of the tree.
+
}
/// <summary>
Interop.Window.SetTransparency(swigCPtr, transparent);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if(rootLayoutItem != null)
- {
- rootLayoutItem.RequestLayout();
- }
+ // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
+
}
internal System.IntPtr GetNativeWindowHandler()
{
public class CustomLayout : LayoutGroup
{
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var accumulatedWidth = new LayoutLength(0);
var maxHeight = 0;
var measuredWidth = new LayoutLength(0);
LayoutLength measuredHeight = new LayoutLength(0);
- LayoutMeasureSpec.ModeType widthMode = widthMeasureSpec.Mode;
- LayoutMeasureSpec.ModeType heightMode = heightMeasureSpec.Mode;
+ MeasureSpecification.ModeType widthMode = widthMeasureSpec.Mode;
+ MeasureSpecification.ModeType heightMode = heightMeasureSpec.Mode;
- bool isWidthExact = (widthMode == LayoutMeasureSpec.ModeType.EXACTLY);
- bool isHeightExact = (heightMode == LayoutMeasureSpec.ModeType.EXACTLY);
+ bool isWidthExact = (widthMode == MeasureSpecification.ModeType.EXACTLY);
+ bool isHeightExact = (heightMode == MeasureSpecification.ModeType.EXACTLY);
// In this layout we will:
// Measuring the layout with the children in a horizontal configuration, one after another
{
Console.WriteLine($"CustomLayoutHorizental() constructor!");
}
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Console.WriteLine($"CustomLayoutHorizental OnMeasure() START");
private static LayoutItem[] childLayouts = new LayoutItem[10];
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var accumulatedHeight = new LayoutLength(0);
var maxWidth = new LayoutLength(0);
Console.WriteLine($"CustomLayoutVertical OnLayout() END");
}
}
-
+
class Example : NUIApplication
{
public Example() : base()
{
Console.WriteLine($"CustomLayoutHorizental() constructor!");
}
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Console.WriteLine($"CustomLayoutHorizental OnMeasure() START");
private static LayoutItem[] childLayouts = new LayoutItem[10];
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var accumulatedHeight = new LayoutLength(0);
var maxWidth = new LayoutLength(0);
Console.WriteLine($"CustomLayoutVertical OnLayout() END");
}
}
-
+
class Example : NUIApplication
{
public Example() : base()
{
public class CustomLayout : LayoutGroup
{
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var accumulatedWidth = new LayoutLength(0);
var maxHeight = 0;
var measuredWidth = new LayoutLength(0);
LayoutLength measuredHeight = new LayoutLength(0);
- LayoutMeasureSpec.ModeType widthMode = widthMeasureSpec.Mode;
- LayoutMeasureSpec.ModeType heightMode = heightMeasureSpec.Mode;
+ MeasureSpecification.ModeType widthMode = widthMeasureSpec.Mode;
+ MeasureSpecification.ModeType heightMode = heightMeasureSpec.Mode;
- bool isWidthExact = (widthMode == LayoutMeasureSpec.ModeType.EXACTLY);
- bool isHeightExact = (heightMode == LayoutMeasureSpec.ModeType.EXACTLY);
+ bool isWidthExact = (widthMode == MeasureSpecification.ModeType.EXACTLY);
+ bool isHeightExact = (heightMode == MeasureSpecification.ModeType.EXACTLY);
// In this layout we will:
// Measuring the layout with the children in a horizontal configuration, one after another
{
public class CustomLayout : LayoutGroup
{
- protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
+ protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var accumulatedWidth = new LayoutLength(0);
var maxHeight = 0;
var measuredWidth = new LayoutLength(0);
LayoutLength measuredHeight = new LayoutLength(0);
- LayoutMeasureSpec.ModeType widthMode = widthMeasureSpec.Mode;
- LayoutMeasureSpec.ModeType heightMode = heightMeasureSpec.Mode;
+ MeasureSpecification.ModeType widthMode = widthMeasureSpec.Mode;
+ MeasureSpecification.ModeType heightMode = heightMeasureSpec.Mode;
- bool isWidthExact = (widthMode == LayoutMeasureSpec.ModeType.EXACTLY);
- bool isHeightExact = (heightMode == LayoutMeasureSpec.ModeType.EXACTLY);
+ bool isWidthExact = (widthMode == MeasureSpecification.ModeType.EXACTLY);
+ bool isHeightExact = (heightMode == MeasureSpecification.ModeType.EXACTLY);
// In this layout we will:
// Measuring the layout with the children in a horizontal configuration, one after another