LayoutLength childLeft = new LayoutLength(childPosition.X);
LayoutLength childTop = new LayoutLength(childPosition.Y);
- childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+ childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight, true);
}
}
}
set
{
ContentContainer.Layout = value;
- if (ContentContainer.Layout != null)
- {
- ContentContainer.Layout.SetPositionByLayout = false;
- }
}
}
ContentContainer = new View()
{
Name = "ContentContainer",
+ ExcludeLayouting = false,
WidthSpecification = ScrollingDirection == Direction.Vertical ? LayoutParamPolicies.MatchParent : LayoutParamPolicies.WrapContent,
HeightSpecification = ScrollingDirection == Direction.Vertical ? LayoutParamPolicies.WrapContent : LayoutParamPolicies.MatchParent,
- Layout = new AbsoluteLayout()
- {
- SetPositionByLayout = false
- },
};
ContentContainer.Relayout += OnScrollingChildRelayout;
propertyNotification = ContentContainer.AddPropertyNotification("position", PropertyCondition.Step(mScrollingEventThreshold));
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
private void InitChildrenData(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- int childCount = LayoutChildren.Count;
+ int gridChildCount = 0;
+ for (int i = 0; i < LayoutChildren.Count; i++)
+ {
+ LayoutItem item = LayoutChildren[i];
+ View view = item?.Owner;
+ if (view == null) continue;
+ if (item.Owner.ExcludeLayouting)
+ {
+ gridChildCount++;
+ }
+ }
bool isHorizontal = (GridOrientation == Orientation.Horizontal);
int mainPivot = 0, subPivot = 0;
int[] pivotStack = new int[isHorizontal ? Columns : Rows];
vLocations = hLocations = null;
vEdgeList = hEdgeList = null;
- gridChildren = new GridChild[childCount];
+ gridChildren = new GridChild[gridChildCount];
maxColumnConut = Columns;
maxRowCount = Rows;
totalVerticalExpand = 0;
totalHorizontalExpand = 0;
- for (int i = 0; i < childCount; i++)
+ for (int i = 0, gridChildIndex = 0; i < LayoutChildren.Count; i++, gridChildIndex++)
{
LayoutItem item = LayoutChildren[i];
+
View view = item?.Owner;
if (view == null) continue;
+ if (!view.ExcludeLayouting)
+ {
+ MeasureChildWithoutPadding(item, widthMeasureSpec, heightMeasureSpec);
+ gridChildIndex--;
+ continue;
+ }
+
int column, columnSpan, row, rowSpan;
StretchFlags verticalStretch, horizontalStretch;
else
Tizen.Log.Error("NUI", "Row + RowSapn exceeds Grid Rows. Row + RowSapn (" + row + " + " + rowSpan + ") > Grid Rows(" + maxRowCount + ")");
- gridChildren[i] = new GridChild(null, new Node(0, 1, 0, 0), new Node(0, 1, 0, 0));
+ gridChildren[gridChildIndex] = new GridChild(null, new Node(0, 1, 0, 0), new Node(0, 1, 0, 0));
continue;
}
maxRowCount = row + rowSpan;
MeasureChildWithMargins(item, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
- gridChildren[i] = new GridChild(item,
+ gridChildren[gridChildIndex] = new GridChild(item,
new Node(column, columnSpan, item.MeasuredWidth.Size.AsDecimal() + item.Owner.Margin.Start + item.Owner.Margin.End, horizontalStretch),
new Node(row, rowSpan, item.MeasuredHeight.Size.AsDecimal() + item.Owner.Margin.Top + item.Owner.Margin.Bottom, verticalStretch));
}
edgeList[i] = isHorizontal ? gridChildren[i].Column : gridChildren[i].Row;
// Add virtual edge that have no edge for connecting adjacent cells.
- for (int i = LayoutChildren.Count, end = LayoutChildren.Count + axisCount, v = 0; i < end; i++, v++)
+ for (int i = gridChildren.Length, end = gridChildren.Length + axisCount, v = 0; i < end; i++, v++)
edgeList[i] = new Node(v, 1, 0, 0);
Array.Sort(edgeList, (a, b) => a.Start.CompareTo(b.Start));
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2020 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.
private bool controlStatePropagation = false;
private ViewStyle viewStyle;
private bool themeChangeSensitive = false;
+ private bool excludeLayouting = true;
internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set.
internal BackgroundExtraData backgroundExtraData;
}
}
+ /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool ExcludeLayouting
+ {
+ get
+ {
+ return excludeLayouting;
+ }
+ set
+ {
+ excludeLayouting = value;
+ if(Layout != null && Layout.SetPositionByLayout != value)
+ {
+ Layout.SetPositionByLayout = value;
+ Layout.RequestLayout();
+ }
+ }
+ }
+
/// 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 bool IsResourcesCreated
// Remove existing layout from it's parent layout group.
_layout?.Unparent();
+ value.SetPositionByLayout = excludeLayouting;
+
// Set layout to this view
SetLayout(value);
}
-/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 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.
// Get size of child with no padding, no margin. we won't support margin, padding for AbsolutLayout.
MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec);
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ continue;
+ }
+
// Determine the width and height needed by the children using their given position and size.
// Children could overlap so find the right most child.
Position2D childPosition = childLayout.Owner.Position2D;
for (int i = 0; i < LayoutChildren.Count; i++)
{
LayoutItem childLayout = LayoutChildren[i];
- if ( childLayout != null )
+ if (childLayout != null)
{
LayoutLength childWidth = childLayout.MeasuredWidth.Size;
LayoutLength childHeight = childLayout.MeasuredHeight.Size;
LayoutLength childLeft = new LayoutLength(childPosition.X);
LayoutLength childTop = new LayoutLength(childPosition.Y);
- childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+ childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight, true);
}
}
}
-
- private void MeasureChildWithoutPadding(LayoutItem child, MeasureSpecification parentWidthMeasureSpec, MeasureSpecification parentHeightMeasureSpec)
- {
- View childOwner = child.Owner;
-
- MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(
- new MeasureSpecification(new LayoutLength(parentWidthMeasureSpec.Size), parentWidthMeasureSpec.Mode),
- new LayoutLength(0),
- new LayoutLength(childOwner.WidthSpecification));
-
- MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
- new MeasureSpecification(new LayoutLength(parentHeightMeasureSpec.Size), parentHeightMeasureSpec.Mode),
- new LayoutLength(0),
- new LayoutLength(childOwner.HeightSpecification));
-
- child.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
- }
}
} // namespace
-/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 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.
public static void SetFlexGrow(View view, float value) => SetAttachedValue(view, FlexGrowProperty, value);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void ChildMeasureCallback( global::System.IntPtr child, float width, int measureModeWidth, float height, int measureModeHeight, out MeasuredSize measureSize );
+ internal delegate void ChildMeasureCallback(global::System.IntPtr child, float width, int measureModeWidth, float height, int measureModeHeight, out MeasuredSize measureSize);
event ChildMeasureCallback measureChildDelegate; // Stores a delegate to the child measure callback. Used for all children of this FlexLayout.
if (childHandleRef.Handle == IntPtr.Zero || Child == null)
continue;
+ if (!layoutItem.Owner.ExcludeLayouting)
+ {
+ SetFlexPositionType(Child, PositionType.Absolute);
+ Interop.FlexLayout.FlexLayout_SetFlexPositionType(childHandleRef, (int)PositionType.Absolute);
+ MeasureChildWithoutPadding(layoutItem, widthMeasureSpec, heightMeasureSpec);
+ continue;
+ }
+ else
+ {
+ SetFlexPositionType(Child, PositionType.Relative);
+ Interop.FlexLayout.FlexLayout_SetFlexPositionType(childHandleRef, (int)PositionType.Relative);
+ }
+
AlignmentType flexAlignemnt = GetFlexAlignmentSelf(Child);
- PositionType flexPosition = GetFlexPositionType(Child);
float flexAspectRatio = GetFlexAspectRatio(Child);
float flexBasis = GetFlexBasis(Child);
float flexShrink = GetFlexShrink(Child);
float flexGrow = GetFlexGrow(Child);
Interop.FlexLayout.FlexLayout_SetFlexAlignmentSelf(childHandleRef, (int)flexAlignemnt);
- Interop.FlexLayout.FlexLayout_SetFlexPositionType(childHandleRef, (int)flexPosition);
Interop.FlexLayout.FlexLayout_SetFlexAspectRatio(childHandleRef, flexAspectRatio);
Interop.FlexLayout.FlexLayout_SetFlexBasis(childHandleRef, flexBasis);
Interop.FlexLayout.FlexLayout_SetFlexShrink(childHandleRef, flexShrink);
LayoutItem childLayout = LayoutChildren[childIndex];
if (childLayout != null)
{
- // Get the frame for the child, start, top, end, bottom.
- Vector4 frame = new Vector4(Interop.FlexLayout.FlexLayout_GetNodeFrame(swigCPtr, childIndex), true);
- childLayout.Layout(new LayoutLength(frame.X), new LayoutLength(frame.Y), new LayoutLength(frame.Z), new LayoutLength(frame.W));
+ if (childLayout.Owner.ExcludeLayouting)
+ {
+ // Get the frame for the child, start, top, end, bottom.
+ Vector4 frame = new Vector4(Interop.FlexLayout.FlexLayout_GetNodeFrame(swigCPtr, childIndex), true);
+ childLayout.Layout(new LayoutLength(frame.X), new LayoutLength(frame.Y), new LayoutLength(frame.Z), new LayoutLength(frame.W));
+ }
}
}
+ LayoutForIndependentChild();
}
-
} // FLexlayout
} // namesspace Tizen.NUI
-/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 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.
child.LayoutItem.Layout(new LayoutLength(l), new LayoutLength(t), new LayoutLength(l + width), new LayoutLength(t + height));
}
+
+ LayoutForIndependentChild();
}
/// <summary>
/// [Draft] List of child layouts in this container.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- protected List<LayoutItem> LayoutChildren{ get;} // Children of this LayoutGroup
+ protected List<LayoutItem> LayoutChildren { get; } // Children of this LayoutGroup
/// <summary>
/// [Draft] Constructor
/// <since_tizen> 6 </since_tizen>
public void RemoveAll()
{
- foreach( LayoutItem childLayout in LayoutChildren )
+ foreach (LayoutItem childLayout in LayoutChildren)
{
childLayout.ConditionForAnimation = ConditionForAnimation | TransitionCondition.Remove;
childLayout.Owner = null;
public virtual void Remove(LayoutItem layoutItem)
{
bool childRemoved = false;
- foreach( LayoutItem childLayout in LayoutChildren.ToList() )
+ foreach (LayoutItem childLayout in LayoutChildren.ToList())
{
- if( childLayout == layoutItem )
+ if (childLayout == layoutItem)
{
childLayout.ClearReplaceFlag();
LayoutChildren.Remove(childLayout);
[EditorBrowsable(EditorBrowsableState.Never)]
public void ChangeLayoutSiblingOrder(int order)
{
- if(Owner != null && Owner.Parent != null)
+ if (Owner != null && Owner.Parent != null)
{
LayoutGroup parent = Owner.Parent.Layout as LayoutGroup;
- if(parent != null && parent.LayoutChildren.Count>order)
+ if (parent != null && parent.LayoutChildren.Count > order)
{
parent.LayoutChildren.Remove(this);
- parent.LayoutChildren.Insert(order,this);
+ parent.LayoutChildren.Insert(order, this);
}
}
// 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))
+ 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)))
else
{
// Add child layout to this LayoutGroup (Setting parent in the process)
- if(child.Layout != null)
+ if (child.Layout != null)
{
Add(child.Layout);
}
/// <param name="child">Child View to remove.</param>
internal void RemoveChildFromLayoutGroup(View child)
{
- if(child.Layout != null)
+ if (child.Layout != null)
{
Remove(child.Layout);
}
/// Set all children in a LayoutGroup to the supplied condition.
/// Children with Add or Remove conditions should not be changed.
/// </summary>
- private void SetConditionsForAnimationOnLayoutGroup( TransitionCondition conditionToSet)
+ private void SetConditionsForAnimationOnLayoutGroup(TransitionCondition conditionToSet)
{
- foreach( LayoutItem childLayout in LayoutChildren )
+ foreach (LayoutItem childLayout in LayoutChildren)
{
- switch( conditionToSet )
+ switch (conditionToSet)
{
- case TransitionCondition.ChangeOnAdd :
- {
- // If other children also being added (TransitionCondition.Add) then do not change their
- // conditions, Continue to use their Add transitions.
- if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Add))
- {
- break; // Child being Added so don't update it's condition
- }
- else
- {
- // Set siblings for the child being added to use the ChangeOnAdd transition.
- childLayout.ConditionForAnimation = TransitionCondition.ChangeOnAdd;
- }
- break;
- }
- case TransitionCondition.ChangeOnRemove :
- {
- if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Remove))
- {
- break; // Child being Removed so don't update it's condition
- }
- else
- {
- childLayout.ConditionForAnimation = TransitionCondition.ChangeOnRemove;
- }
- break;
- }
- case TransitionCondition.LayoutChanged :
- {
- childLayout.ConditionForAnimation = TransitionCondition.LayoutChanged;
- break;
- }
+ case TransitionCondition.ChangeOnAdd:
+ {
+ // If other children also being added (TransitionCondition.Add) then do not change their
+ // conditions, Continue to use their Add transitions.
+ if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Add))
+ {
+ break; // Child being Added so don't update it's condition
+ }
+ else
+ {
+ // Set siblings for the child being added to use the ChangeOnAdd transition.
+ childLayout.ConditionForAnimation = TransitionCondition.ChangeOnAdd;
+ }
+ break;
+ }
+ case TransitionCondition.ChangeOnRemove:
+ {
+ if (childLayout.ConditionForAnimation.HasFlag(TransitionCondition.Remove))
+ {
+ break; // Child being Removed so don't update it's condition
+ }
+ else
+ {
+ childLayout.ConditionForAnimation = TransitionCondition.ChangeOnRemove;
+ }
+ break;
+ }
+ case TransitionCondition.LayoutChanged:
+ {
+ childLayout.ConditionForAnimation = TransitionCondition.LayoutChanged;
+ break;
+ }
}
}
MeasureSpecification.ModeType resultMode = MeasureSpecification.ModeType.Unspecified;
// Child only can use parent's size without parent's padding and own margin.
- LayoutLength resultSize = new LayoutLength(Math.Max( 0.0f, (parentMeasureSpec.Size - padding).AsDecimal()));
- switch( specMode )
+ LayoutLength resultSize = new LayoutLength(Math.Max(0.0f, (parentMeasureSpec.Size - padding).AsDecimal()));
+ switch (specMode)
{
// Parent has imposed an exact size on us
case MeasureSpecification.ModeType.Exactly:
- {
- if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
- {
- resultMode = MeasureSpecification.ModeType.Exactly;
- }
- else if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.WrapContent)
{
- resultMode = MeasureSpecification.ModeType.AtMost;
- }
- else
- {
- resultSize = childDimension;
- resultMode = MeasureSpecification.ModeType.Exactly;
- }
+ if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+ else if ((int)childDimension.AsRoundedValue() == LayoutParamPolicies.WrapContent)
+ {
+ resultMode = MeasureSpecification.ModeType.AtMost;
+ }
+ else
+ {
+ resultSize = childDimension;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
- break;
- }
+ break;
+ }
// Parent has imposed a maximum size on us
case MeasureSpecification.ModeType.AtMost:
- {
- if (childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
{
- // Crashed. Cannot calculate.
+ if (childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent)
+ {
+ // Crashed. Cannot calculate.
- // 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.
+ // 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.
- // Don't need parent's size. Size of this child will be determined by its children.
- resultMode = MeasureSpecification.ModeType.AtMost;
- }
- else
- {
- // Child wants a specific size... so be it
- resultSize = childDimension;
- resultMode = MeasureSpecification.ModeType.Exactly;
- }
+ // Don't need parent's size. Size of this child will be determined by its children.
+ resultMode = MeasureSpecification.ModeType.AtMost;
+ }
+ else
+ {
+ // Child wants a specific size... so be it
+ resultSize = childDimension;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
- break;
- }
+ 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
+ if ((childDimension.AsRoundedValue() == LayoutParamPolicies.MatchParent))
+ {
+ // Child wants to be our size... find out how big it should be
- // There is no one who has exact size in parent hierarchy.
- // Cannot calculate.
- 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;
- resultMode = MeasureSpecification.ModeType.Exactly;
+ // There is no one who has exact size in parent hierarchy.
+ // Cannot calculate.
+ 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;
+ resultMode = MeasureSpecification.ModeType.Exactly;
+ }
+ break;
}
- break;
- }
} // switch
- return new MeasureSpecification( resultSize, resultMode );
+ return new MeasureSpecification(resultSize, resultMode);
}
/// <summary>
LayoutLength measuredHeight = new LayoutLength(0.0f);
// Layout takes size of largest child width and largest child height dimensions
- foreach( LayoutItem childLayout in LayoutChildren )
+ foreach (LayoutItem childLayout in LayoutChildren)
{
- if( childLayout != null )
+ if (childLayout != null)
{
- MeasureChildWithMargins( childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0) );
+ MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
LayoutLength childWidth = new LayoutLength(childLayout.MeasuredWidth.Size);
- LayoutLength childHeight = new LayoutLength( childLayout.MeasuredHeight.Size);
+ LayoutLength childHeight = new LayoutLength(childLayout.MeasuredHeight.Size);
Extents childMargin = childLayout.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));
+ 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 == LayoutChildren.Count )
+ if (0 == LayoutChildren.Count)
{
// Must be a leaf as has no children
- measuredWidth = GetDefaultSize( SuggestedMinimumWidth, widthMeasureSpec );
- measuredHeight = GetDefaultSize( SuggestedMinimumHeight, heightMeasureSpec );
+ measuredWidth = GetDefaultSize(SuggestedMinimumWidth, widthMeasureSpec);
+ measuredHeight = GetDefaultSize(SuggestedMinimumHeight, heightMeasureSpec);
}
- SetMeasuredDimensions( new MeasuredSize( measuredWidth, MeasuredSize.StateType.MeasuredSizeOK ),
- new MeasuredSize( measuredHeight, MeasuredSize.StateType.MeasuredSizeOK ) );
+ SetMeasuredDimensions(new MeasuredSize(measuredWidth, MeasuredSize.StateType.MeasuredSizeOK),
+ new MeasuredSize(measuredHeight, MeasuredSize.StateType.MeasuredSizeOK));
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
protected override void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- foreach( LayoutItem childLayout in LayoutChildren )
+ foreach (LayoutItem childLayout in LayoutChildren)
{
- if( childLayout !=null )
+ if (childLayout != null)
{
// Use position if explicitly set to child otherwise will be top left.
- var childLeft = new LayoutLength( childLayout.Owner.Position2D.X );
- var childTop = new LayoutLength( childLayout.Owner.Position2D.Y );
+ var childLeft = new LayoutLength(childLayout.Owner.Position2D.X);
+ var childTop = new LayoutLength(childLayout.Owner.Position2D.Y);
View owner = Owner;
- if ( owner )
+ if (owner)
{
// Margin and Padding only supported when child anchor point is TOP_LEFT.
- if ( owner.PivotPoint == PivotPoint.TopLeft || ( owner.PositionUsesPivotPoint == false ) )
+ if (owner.PivotPoint == PivotPoint.TopLeft || (owner.PositionUsesPivotPoint == false))
{
childLeft = childLeft + owner.Padding.Start + childLayout.Margin.Start;
childTop = childTop + owner.Padding.Top + childLayout.Margin.Top;
}
}
- childLayout.Layout( childLeft, childTop, childLeft + childLayout.MeasuredWidth.Size, childTop + childLayout.MeasuredHeight.Size );
+ childLayout.Layout(childLeft, childTop, childLeft + childLayout.MeasuredWidth.Size, childTop + childLayout.MeasuredHeight.Size);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Layout independent children those Owners have false ExcludeLayouting. <br />
+ /// These children are required not to be affected by this layout. <br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void LayoutForIndependentChild()
+ {
+ int count = LayoutChildren.Count;
+ for (int childIndex = 0; childIndex < count; childIndex++)
+ {
+ LayoutItem childLayout = LayoutChildren[childIndex];
+ if (childLayout != null)
+ {
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+
+ Position2D childPosition = childLayout.Owner.Position2D;
+
+ LayoutLength childPositionX = new LayoutLength(childPosition.X);
+ LayoutLength childPositionY = new LayoutLength(childPosition.Y);
+
+ childLayout.Layout(childPositionX, childPositionY, childPositionX + childWidth, childPositionY + childHeight, true);
+ }
}
}
}
/// <since_tizen> 6 </since_tizen>
protected virtual void MeasureChildren(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
- foreach( LayoutItem childLayout in LayoutChildren )
+ foreach (LayoutItem childLayout in LayoutChildren)
{
MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
}
MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(new LayoutLength(parentWidthMeasureSpec.Size), parentWidthMeasureSpec.Mode),
- new LayoutLength(Padding.Start + Padding.End ),
- new LayoutLength(childOwner.WidthSpecification) );
+ new LayoutLength(Padding.Start + Padding.End),
+ new LayoutLength(childOwner.WidthSpecification));
MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(new LayoutLength(parentHeightMeasureSpec.Size), parentHeightMeasureSpec.Mode),
new MeasureSpecification(
new LayoutLength(parentWidthMeasureSpec.Size + widthUsed - (childOwner.Margin.Start + childOwner.Margin.End)),
parentWidthMeasureSpec.Mode),
- new LayoutLength(Padding.Start + Padding.End ),
- new LayoutLength(childOwner.WidthSpecification) );
+ new LayoutLength(Padding.Start + Padding.End),
+ new LayoutLength(childOwner.WidthSpecification));
MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
parentHeightMeasureSpec.Mode),
new LayoutLength(Padding.Top + Padding.Bottom),
new LayoutLength(childOwner.HeightSpecification));
- child.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
+ 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 without its padding.<br />
+ /// and margins. The heavy lifting is 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="parentHeightMeasureSpec">The height requirements for this view.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void MeasureChildWithoutPadding(LayoutItem child, MeasureSpecification parentWidthMeasureSpec, MeasureSpecification parentHeightMeasureSpec)
+ {
+ View childOwner = child.Owner;
+
+ MeasureSpecification childWidthMeasureSpec = GetChildMeasureSpecification(
+ new MeasureSpecification(new LayoutLength(parentWidthMeasureSpec.Size), parentWidthMeasureSpec.Mode),
+ new LayoutLength(0),
+ new LayoutLength(childOwner.WidthSpecification));
+
+ MeasureSpecification childHeightMeasureSpec = GetChildMeasureSpecification(
+ new MeasureSpecification(new LayoutLength(parentHeightMeasureSpec.Size), parentHeightMeasureSpec.Mode),
+ new LayoutLength(0),
+ new LayoutLength(childOwner.HeightSpecification));
+
+ child.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ /// <summary>
/// Gets the value that is contained in the attached BindableProperty.
/// </summary>
/// <typeparam name="T">The return type of property</typeparam>
[FlagsAttribute]
enum LayoutFlags : short
{
- None = 0,
- ForceLayout = 1,
- LayoutRequired = 2,
- MeasuredDimensionSet = 4
+ None = 0,
+ ForceLayout = 1,
+ LayoutRequired = 2,
+ MeasuredDimensionSet = 4
};
/// <summary>
private Extents _margin;
private bool parentReplacement = false;
+ private bool setPositionByLayout = true;
/// <summary>
/// [Draft] Condition event that is causing this Layout to transition.
/// </summary>
- internal TransitionCondition ConditionForAnimation{get; set;}
+ internal TransitionCondition ConditionForAnimation { get; set; }
/// <summary>
/// [Draft] The View that this Layout has been assigned to.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public View Owner{get; set;} // Should not keep a View alive.
+ public View Owner { get; set; } // Should not keep a View alive.
/// <summary>
/// [Draft] Use transition for layouting child
/// <since_tizen> 6 </since_tizen>
/// 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 LayoutWithTransition{get; set;}
+ public bool LayoutWithTransition { get; set; }
/// <summary>
/// [Draft] Set position by layouting result
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public bool SetPositionByLayout{get;set;} = true;
+ public bool SetPositionByLayout
+ {
+ get
+ {
+ return setPositionByLayout;
+ }
+ set
+ {
+ setPositionByLayout = value;
+ if (Owner != null && Owner.ExcludeLayouting != value)
+ {
+ Owner.ExcludeLayouting = value;
+ }
+ }
+ }
/// <summary>
/// [Draft] Margin for this LayoutItem
/// [Draft] Set parent to this layout.
/// </summary>
/// <param name="parent">Parent to set on this Layout.</param>
- internal void SetParent( ILayoutParent parent)
+ internal void SetParent(ILayoutParent parent)
{
Parent = parent as LayoutGroup;
}
OnUnparent();
// Remove myself from parent
- Parent?.Remove( this );
+ Parent?.Remove(this);
// Remove parent reference
Parent = null;
private void Initialize()
{
LayoutWithTransition = false;
- _layoutPositionData = new LayoutData(this,TransitionCondition.Unspecified,0,0,0,0);
- _padding = new Extents(0,0,0,0);
- _margin = new Extents(0,0,0,0);
+ _layoutPositionData = new LayoutData(this, TransitionCondition.Unspecified, 0, 0, 0, 0);
+ _padding = new Extents(0, 0, 0, 0);
+ _margin = new Extents(0, 0, 0, 0);
}
/// <summary>
OnAttachedToOwner();
// Add layout to parent layout if a layout container
View parent = Owner.GetParent() as View;
- (parent?.Layout as LayoutGroup)?.Add( this );
+ (parent?.Layout as LayoutGroup)?.Add(this);
// If Add or ChangeOnAdd then do not update condition
if (ConditionForAnimation.Equals(TransitionCondition.Unspecified))
bool matchesSpecSize = (MeasuredWidth.Size == widthMeasureSpec.Size) &&
(MeasuredHeight.Size == heightMeasureSpec.Size);
- bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize);
+ bool needsLayout = specChanged && (!isSpecExactly || !matchesSpecSize);
needsLayout = needsLayout || ((Flags & LayoutFlags.ForceLayout) == LayoutFlags.ForceLayout);
if (needsLayout)
/// <since_tizen> 6 </since_tizen>
public void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
{
- bool changed = SetFrame(left.AsRoundedValue(),
- top.AsRoundedValue(),
- right.AsRoundedValue(),
- bottom.AsRoundedValue());
+ Layout(left, top, right, bottom, false);
+ }
+
+ /// <summary>
+ /// Assign a size and position to a layout and all of its descendants. <br />
+ /// This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent
+ /// calls layout on all of its children to position them. This is typically done using the child<br />
+ /// measurements that were stored in the measure pass.<br />
+ /// </summary>
+ /// <param name="left">Left position, relative to parent.</param>
+ /// <param name="top">Top position, relative to parent.</param>
+ /// <param name="right">Right position, relative to parent.</param>
+ /// <param name="bottom">Bottom position, relative to parent.</param>
+ /// <param name="independent">true, if this layout is not affected by parent layout.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom, bool independent)
+ {
+ bool changed = true;
+ if (!independent)
+ {
+ changed = SetFrame(left.AsRoundedValue(),
+ top.AsRoundedValue(),
+ right.AsRoundedValue(),
+ bottom.AsRoundedValue());
+ }
+ else
+ {
+ // If height or width specification is not explicitly defined,
+ // the size of the owner view must be reset even the ExcludeLayouting is false.
+ if (Owner.HeightSpecification < 0 || Owner.WidthSpecification < 0)
+ {
+ Owner.SetSize(right.AsRoundedValue() - left.AsRoundedValue(), bottom.AsRoundedValue() - top.AsRoundedValue());
+ }
+ }
// Check if Measure needed before Layouting
if (changed || ((Flags & LayoutFlags.LayoutRequired) == LayoutFlags.LayoutRequired))
switch (specMode)
{
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;
+ break;
}
- else
+ case MeasureSpecification.ModeType.AtMost:
{
- result = specSize;
+ // 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;
}
- break;
- }
case MeasureSpecification.ModeType.Exactly:
- {
- result = specSize;
- break;
- }
+ {
+ result = specSize;
+ break;
+ }
}
return result;
Flags = Flags | LayoutFlags.ForceLayout;
if (Parent != null)
{
- LayoutGroup layoutGroup = Parent as LayoutGroup;
- if(layoutGroup != null && !layoutGroup.LayoutRequested)
- {
+ LayoutGroup layoutGroup = Parent as LayoutGroup;
+ if (layoutGroup != null && !layoutGroup.LayoutRequested)
+ {
layoutGroup.RequestLayout();
- }
+ }
}
-
+
}
/// <summary>
{
get
{
- return ( Flags & LayoutFlags.ForceLayout) == LayoutFlags.ForceLayout;
+ return (Flags & LayoutFlags.ForceLayout) == LayoutFlags.ForceLayout;
}
}
/// This method should be used only during measurement and layout calculations.<br />
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public MeasuredSize MeasuredWidth{ get; set; } = new MeasuredSize( new LayoutLength(-3), MeasuredSize.StateType.MeasuredSizeOK);
+ 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>
/// <since_tizen> 6 </since_tizen>
- public MeasuredSize MeasuredHeight{ get; set; } = new MeasuredSize( new LayoutLength(-3), MeasuredSize.StateType.MeasuredSizeOK);
+ public MeasuredSize MeasuredHeight { get; set; } = new MeasuredSize(new LayoutLength(-3), MeasuredSize.StateType.MeasuredSizeOK);
/// <summary>
/// Returns the suggested minimum width that the layout should use.<br />
float maximumWidth = Owner.MaximumSize.Width;
float minimumWidth = Owner.MinimumSize.Width;
- float baseHeight = Owner.MaximumSize.Height > 0 ? Math.Min(Owner.MaximumSize.Height,Owner.NaturalSize.Height) : Owner.NaturalSize.Height;
+ float baseHeight = Owner.MaximumSize.Height > 0 ? Math.Min(Owner.MaximumSize.Height, Owner.NaturalSize.Height) : Owner.NaturalSize.Height;
float baseWidth = Owner.GetWidthForHeight(baseHeight);
float result = minimumWidth > 0 ? Math.Max(baseWidth, minimumWidth) : baseWidth;
float maximumHeight = Owner.MaximumSize.Height;
float minimumHeight = Owner.MinimumSize.Height;
- float baseWidth = Owner.MaximumSize.Width > 0 ? Math.Min(Owner.MaximumSize.Width,Owner.NaturalSize.Width) : Owner.NaturalSize.Width;
+ float baseWidth = Owner.MaximumSize.Width > 0 ? Math.Min(Owner.MaximumSize.Width, Owner.NaturalSize.Width) : Owner.NaturalSize.Width;
float baseHeight = Owner.GetHeightForWidth(baseWidth);
float result = minimumHeight > 0 ? Math.Max(baseHeight, minimumHeight) : baseHeight;
/// 2. If the owner's View.WidthSpecification 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.WidthSpecification is set to View.LayoutParamPolicies.MatchParent, then the parent width takes precedence over the minimum width.<br />
/// </summary>
- internal LayoutLength MinimumWidth {get; set;}
+ internal LayoutLength MinimumWidth { get; set; }
/// <summary>
/// Sets the minimum height of the layout.<br />
/// 2. If the owner's View.HeightSpecification 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.HeightSpecification is set to View.LayoutParamPolicies.MatchParent, then the parent height takes precedence over the minimum height.<br />
/// </summary>
- internal LayoutLength MinimumHeight {get; set;}
+ internal LayoutLength MinimumHeight { get; set; }
///<summary>
/// Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpecification.
/// <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>
/// <since_tizen> 6 </since_tizen>
- protected MeasuredSize ResolveSizeAndState( LayoutLength size, MeasureSpecification measureSpecification, MeasuredSize.StateType childMeasuredState )
+ protected MeasuredSize ResolveSizeAndState(LayoutLength size, MeasureSpecification measureSpecification, MeasuredSize.StateType childMeasuredState)
{
var specMode = measureSpecification.Mode;
LayoutLength specSize = measureSpecification.Size;
- MeasuredSize result = new MeasuredSize( size, childMeasuredState );
+ MeasuredSize result = new MeasuredSize(size, childMeasuredState);
- switch( specMode )
+ switch (specMode)
{
case MeasureSpecification.ModeType.AtMost:
- {
- if (specSize.AsRoundedValue() < size.AsRoundedValue())
{
- result = new MeasuredSize( specSize, MeasuredSize.StateType.MeasuredSizeTooSmall);
+ if (specSize.AsRoundedValue() < size.AsRoundedValue())
+ {
+ result = new MeasuredSize(specSize, MeasuredSize.StateType.MeasuredSizeTooSmall);
+ }
+ break;
}
- break;
- }
case MeasureSpecification.ModeType.Exactly:
- {
- result.Size = specSize;
- break;
- }
+ {
+ result.Size = specSize;
+ break;
+ }
case MeasureSpecification.ModeType.Unspecified:
default:
- {
- break;
- }
+ {
+ break;
+ }
}
return result;
}
/// <param name="measuredWidth">The measured width of this layout.</param>
/// <param name="measuredHeight">The measured height of this layout.</param>
/// <since_tizen> 6 </since_tizen>
- protected void SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
+ protected void SetMeasuredDimensions(MeasuredSize measuredWidth, MeasuredSize measuredHeight)
{
MeasuredWidth = measuredWidth;
MeasuredHeight = measuredHeight;
protected virtual void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
// GetDefaultSize will limit the MeasureSpec to the suggested minimumWidth and minimumHeight
- SetMeasuredDimensions( GetDefaultSize( SuggestedMinimumWidth, widthMeasureSpec ),
- GetDefaultSize( SuggestedMinimumHeight, heightMeasureSpec ) );
+ SetMeasuredDimensions(GetDefaultSize(SuggestedMinimumWidth, widthMeasureSpec),
+ GetDefaultSize(SuggestedMinimumHeight, heightMeasureSpec));
}
/// <summary>
{
bool changed = false;
- if ( _layoutPositionData.Left != left ||
+ if (_layoutPositionData.Left != left ||
_layoutPositionData.Right != right ||
_layoutPositionData.Top != top ||
- _layoutPositionData.Bottom != bottom )
+ _layoutPositionData.Bottom != bottom)
{
changed = true;
float oldHeight = _layoutPositionData.Bottom - _layoutPositionData.Top;
float newWidth = right - left;
float newHeight = bottom - top;
- bool sizeChanged = ( newWidth != oldWidth ) || ( newHeight != oldHeight );
+ bool sizeChanged = (newWidth != oldWidth) || (newHeight != oldHeight);
// Set condition to layout changed as currently unspecified. Add, Remove would have specified a condition.
if (ConditionForAnimation.Equals(TransitionCondition.Unspecified))
// Store new layout position data
_layoutPositionData = new LayoutData(this, ConditionForAnimation, left, top, right, bottom);
- Debug.WriteLineIf( LayoutDebugFrameData, "LayoutItem FramePositionData View:" + _layoutPositionData.Item.Owner.Name +
+ Debug.WriteLineIf(LayoutDebugFrameData, "LayoutItem FramePositionData View:" + _layoutPositionData.Item.Owner.Name +
" left:" + _layoutPositionData.Left +
" top:" + _layoutPositionData.Top +
" right:" + _layoutPositionData.Right +
- " bottom:" + _layoutPositionData.Bottom );
+ " bottom:" + _layoutPositionData.Bottom);
if (Owner.Parent != null && Owner.Parent.Layout != null && Owner.Parent.Layout.LayoutWithTransition)
{
{
if (Owner.Position != null)
{
- Owner.SetSize(right - left, bottom - top, Owner.Position.Z);
- if (SetPositionByLayout)
- {
- Owner.SetPosition(left, top, Owner.Position.Z);
- }
+ Owner.SetSize(right - left, bottom - top);
+ Owner.SetPosition(left, top);
}
}
-/* Copyright (c) 2019 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2020 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>
/// At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation)
/// </summary>
- Begin = 0x1,
+ Begin = 0x1,
/// <summary>
/// At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation)
/// </summary>
- End = 0x2,
+ End = 0x2,
/// <summary>
/// At the horizontal center of the container
/// </summary>
- CenterHorizontal = 0x4,
+ CenterHorizontal = 0x4,
/// <summary>
/// At the top edge of the container
/// </summary>
- Top = 0x8,
+ Top = 0x8,
/// <summary>
/// At the bottom edge of the container
/// </summary>
- Bottom = 0x10,
+ Bottom = 0x10,
/// <summary>
/// At the vertical center of the container
/// </summary>
- CenterVertical = 0x20,
+ CenterVertical = 0x20,
/// <summary>
/// At the vertical and horizontal center of the container
/// </summary>
- Center = 0x40
+ Center = 0x40
}
struct HeightAndWidthState
public MeasuredSize.StateType widthState;
public MeasuredSize.StateType heightState;
- public HeightAndWidthState( MeasuredSize.StateType width, MeasuredSize.StateType height)
+ public HeightAndWidthState(MeasuredSize.StateType width, MeasuredSize.StateType height)
{
widthState = width;
heightState = height;
/// [Draft] Get/Set the alignment in the layout
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public LinearLayout.Alignment LinearAlignment{ get; set; } = Alignment.Top;
+ public LinearLayout.Alignment LinearAlignment { get; set; } = Alignment.Top;
private float _totalLength = 0.0f;
- private Size2D _cellPadding = new Size2D(0,0);
+ private Size2D _cellPadding = new Size2D(0, 0);
private Orientation _linearOrientation = Orientation.Horizontal;
/// <summary>
{
LayoutVertical(left, top, right, bottom);
}
+ LayoutForIndependentChild();
}
- private void MeasureWeightedChild( LayoutItem childLayout, float remainingExcess, float remainingWeight, float childWeight,
+ private void MeasureWeightedChild(LayoutItem childLayout, float remainingExcess, float remainingWeight, float childWeight,
MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec,
- HeightAndWidthState childState, Orientation orientation )
+ HeightAndWidthState childState, Orientation orientation)
{
bool horizontal = false;
if (orientation == Orientation.Horizontal)
horizontal = true;
}
- float childsShare = ( childWeight * remainingExcess ) / remainingWeight;
+ float childsShare = (childWeight * remainingExcess) / remainingWeight;
remainingExcess -= childsShare;
remainingWeight -= childWeight;
// Always lay out weighted elements with intrinsic size regardless of the parent spec.
// for consistency between specs.
- if( ( horizontal && ( desiredWidth == 0 )) || ( !horizontal && ( desiredHeight == 0 )) )
+ if ((horizontal && (desiredWidth == 0)) || (!horizontal && (desiredHeight == 0)))
{
// This child needs to be laid out from scratch using
// only its share of excess space.
if (horizontal)
{
- childWidthMeasureSpec = new MeasureSpecification( new LayoutLength(childLength), MeasureSpecification.ModeType.Exactly );
- childHeightMeasureSpec = GetChildMeasureSpecification(
+ childWidthMeasureSpec = new MeasureSpecification(new LayoutLength(childLength), MeasureSpecification.ModeType.Exactly);
+ childHeightMeasureSpec = GetChildMeasureSpecification(
new MeasureSpecification(
new LayoutLength(heightMeasureSpec.Size - (childLayout.Owner.Margin.Top + childLayout.Owner.Margin.Bottom)),
heightMeasureSpec.Mode),
new LayoutLength(Padding.Start + Padding.End),
new LayoutLength(desiredWidth));
- childHeightMeasureSpec = new MeasureSpecification( new LayoutLength(childLength), MeasureSpecification.ModeType.Exactly);
+ childHeightMeasureSpec = new MeasureSpecification(new LayoutLength(childLength), MeasureSpecification.ModeType.Exactly);
}
- childLayout.Measure( childWidthMeasureSpec, childHeightMeasureSpec );
+ childLayout.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
// Child may now not fit in horizontal dimension.
- if( childLayout.MeasuredWidth.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ if (childLayout.MeasuredWidth.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
{
childState.widthState = MeasuredSize.StateType.MeasuredSizeTooSmall;
}
// Child may now not fit in vertical dimension.
- if( childLayout.MeasuredHeight.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
+ if (childLayout.MeasuredHeight.State == MeasuredSize.StateType.MeasuredSizeTooSmall)
{
childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
}
{
var widthMode = widthMeasureSpec.Mode;
var heightMode = heightMeasureSpec.Mode;
- bool isExactly = ( widthMode == MeasureSpecification.ModeType.Exactly );
+ bool isExactly = (widthMode == MeasureSpecification.ModeType.Exactly);
bool matchHeight = false;
bool allFillParent = true;
float maxHeight = 0.0f;
for (int i = 0; i < LayoutChildren.Count; i++)
{
LayoutItem childLayout = LayoutChildren[i];
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec);
+ continue;
+ }
+
int childDesiredHeight = childLayout.Owner.HeightSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
totalWeight += childWeight;
- bool useExcessSpace = (childLayout.Owner.WidthSpecification == 0 ) && (childWeight > 0);
- if( isExactly && useExcessSpace )
+ bool useExcessSpace = (childLayout.Owner.WidthSpecification == 0) && (childWeight > 0);
+ if (isExactly && useExcessSpace)
{
// Children to be laid out with excess space can be measured later
- _totalLength = Math.Max( _totalLength, (_totalLength + childMargin.Start + childMargin.End) );
+ _totalLength = Math.Max(_totalLength, (_totalLength + childMargin.Start + childMargin.End));
}
else
{
new LayoutLength(Padding.Top + Padding.Bottom),
new LayoutLength(childDesiredHeight));
- childLayout.Measure( childWidthMeasureSpec, childHeightMeasureSpec);
+ childLayout.Measure(childWidthMeasureSpec, childHeightMeasureSpec);
usedExcessSpace += childLayout.MeasuredWidth.Size.AsDecimal();
}
else
childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
}
- maxHeight = Math.Max( maxHeight, childHeight);
- allFillParent = ( allFillParent && childDesiredHeight == LayoutParamPolicies.MatchParent);
+ maxHeight = Math.Max(maxHeight, childHeight);
+ allFillParent = (allFillParent && childDesiredHeight == LayoutParamPolicies.MatchParent);
if (childWeight > 0)
{
- // Heights of weighted Views are invalid if we end up remeasuring, so store them separately.
- weightedMaxHeight = Math.Max( weightedMaxHeight, matchHeightLocally ? marginHeight : childHeight);
+ // Heights of weighted Views are invalid if we end up remeasuring, so store them separately.
+ weightedMaxHeight = Math.Max(weightedMaxHeight, matchHeightLocally ? marginHeight : childHeight);
}
else
{
- alternativeMaxHeight = Math.Max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight );
+ alternativeMaxHeight = Math.Max(alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight);
}
} // foreach
float widthSize = _totalLength;
- widthSize = Math.Max( widthSize, SuggestedMinimumWidth.AsDecimal());
- MeasuredSize widthSizeAndState = ResolveSizeAndState( new LayoutLength(widthSize + Padding.Start + Padding.End), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
+ widthSize = Math.Max(widthSize, SuggestedMinimumWidth.AsDecimal());
+ MeasuredSize widthSizeAndState = ResolveSizeAndState(new LayoutLength(widthSize + Padding.Start + Padding.End), widthMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
widthSize = widthSizeAndState.Size.AsDecimal();
// 2nd phase:
// 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 = widthSize - _totalLength + usedExcessSpace - (Padding.Start + Padding.End);
- if( remainingExcess != 0 && totalWeight > 0 )
+ if (remainingExcess != 0 && totalWeight > 0)
{
float remainingWeight = totalWeight;
maxHeight = 0;
_totalLength = 0;
int numberOfChildren = LayoutChildren.Count;
- for( int i = 0; i < numberOfChildren; ++i )
+ for (int i = 0; i < numberOfChildren; ++i)
{
LayoutItem childLayout = LayoutChildren[i];
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ continue;
+ }
float desiredChildHeight = childLayout.Owner.HeightSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
- if( childWeight > 0 )
+ if (childWeight > 0)
{
MeasureWeightedChild(childLayout, remainingExcess, remainingWeight, childWeight,
widthMeasureSpec, heightMeasureSpec, childState,
- Orientation.Horizontal );
+ Orientation.Horizontal);
}
float length = childLayout.MeasuredWidth.Size.AsDecimal() + childMargin.Start + childMargin.End;
float cellPadding = i < numberOfChildren - 1 ? CellPadding.Width : 0;
- if( isExactly )
+ if (isExactly)
{
_totalLength += length;
}
else
{
float totalLength = _totalLength;
- _totalLength = Math.Max( _totalLength, _totalLength + length + cellPadding );
+ _totalLength = Math.Max(_totalLength, _totalLength + length + cellPadding);
}
bool matchHeightLocally = (heightMode != MeasureSpecification.ModeType.Exactly) && (desiredChildHeight == LayoutParamPolicies.MatchParent);
float marginHeight = childMargin.Top + childMargin.Bottom;
float childHeight = childLayout.MeasuredHeight.Size.AsDecimal() + marginHeight;
- maxHeight = Math.Max( maxHeight, childHeight );
- alternativeMaxHeight = Math.Max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight );
+ maxHeight = Math.Max(maxHeight, childHeight);
+ alternativeMaxHeight = Math.Max(alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight);
allFillParent = (allFillParent && desiredChildHeight == LayoutParamPolicies.MatchParent);
} // for loop
}
else
{
// No excess space or no weighted children
- alternativeMaxHeight = Math.Max( alternativeMaxHeight, weightedMaxHeight );
+ alternativeMaxHeight = Math.Max(alternativeMaxHeight, weightedMaxHeight);
}
if (!allFillParent && heightMode != MeasureSpecification.ModeType.Exactly)
// Padding should be concerned when specification is Wrapcontent.
- maxHeight += (Owner.HeightSpecification == LayoutParamPolicies.WrapContent)?(Padding.Top + Padding.Bottom):0;
- maxHeight = Math.Max( maxHeight, SuggestedMinimumHeight.AsRoundedValue() );
+ maxHeight += (Owner.HeightSpecification == LayoutParamPolicies.WrapContent) ? (Padding.Top + Padding.Bottom) : 0;
+ maxHeight = Math.Max(maxHeight, SuggestedMinimumHeight.AsRoundedValue());
widthSizeAndState.State = childState.widthState;
SetMeasuredDimensions(widthSizeAndState,
- ResolveSizeAndState( new LayoutLength(maxHeight), heightMeasureSpec, childState.heightState ));
+ ResolveSizeAndState(new LayoutLength(maxHeight), heightMeasureSpec, childState.heightState));
if (matchHeight)
{
}
} // MeasureHorizontal
- private void MeasureVertical( MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec )
+ private void MeasureVertical(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
var widthMode = widthMeasureSpec.Mode;
var heightMode = heightMeasureSpec.Mode;
- bool isExactly = ( heightMode == MeasureSpecification.ModeType.Exactly);
+ bool isExactly = (heightMode == MeasureSpecification.ModeType.Exactly);
bool matchWidth = false;
bool allFillParent = true;
float maxWidth = 0.0f;
// Reset total length
_totalLength = 0.0f;
- float usedExcessSpace =0.0f;
+ float usedExcessSpace = 0.0f;
HeightAndWidthState childState = new HeightAndWidthState(MeasuredSize.StateType.MeasuredSizeOK,
MeasuredSize.StateType.MeasuredSizeOK);
for (int i = 0; i < LayoutChildren.Count; i++)
{
LayoutItem childLayout = LayoutChildren[i];
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ MeasureChildWithoutPadding(childLayout, widthMeasureSpec, heightMeasureSpec);
+ continue;
+ }
+
int childDesiredWidth = childLayout.Owner.WidthSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
totalWeight += childWeight;
bool useExcessSpace = (childLayout.Owner.HeightSpecification == 0) && (childWeight > 0);
- if( isExactly && useExcessSpace )
+ if (isExactly && useExcessSpace)
{
- _totalLength = Math.Max( _totalLength, (_totalLength + childMargin.Top + childMargin.Bottom) );
+ _totalLength = Math.Max(_totalLength, (_totalLength + childMargin.Top + childMargin.Bottom));
}
else
{
- if( useExcessSpace )
+ if (useExcessSpace)
{
// The heightMode is either Unspecified or AtMost, and
// this child is only laid out using excess space. Measure
}
bool matchWidthLocally = false;
- if( widthMode != MeasureSpecification.ModeType.Exactly && childDesiredWidth == LayoutParamPolicies.MatchParent)
+ if (widthMode != MeasureSpecification.ModeType.Exactly && childDesiredWidth == LayoutParamPolicies.MatchParent)
{
// Will have to re-measure at least this child when we know exact height.
matchWidth = true;
childState.heightState = MeasuredSize.StateType.MeasuredSizeTooSmall;
}
- maxWidth = Math.Max( maxWidth, childWidth);
- allFillParent = ( allFillParent && childDesiredWidth == LayoutParamPolicies.MatchParent);
+ maxWidth = Math.Max(maxWidth, childWidth);
+ allFillParent = (allFillParent && childDesiredWidth == LayoutParamPolicies.MatchParent);
if (childWeight > 0)
{
// Widths of weighted Views are bogus if we end up remeasuring, so keep them separate.
- weightedMaxWidth = Math.Max( weightedMaxWidth, matchWidthLocally ? marginWidth : childWidth);
+ weightedMaxWidth = Math.Max(weightedMaxWidth, matchWidthLocally ? marginWidth : childWidth);
}
else
{
- alternativeMaxWidth = Math.Max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth);
+ alternativeMaxWidth = Math.Max(alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth);
}
} // foreach
float heightSize = _totalLength;
- heightSize = Math.Max( heightSize, SuggestedMinimumHeight.AsDecimal());
- MeasuredSize heightSizeAndState = ResolveSizeAndState( new LayoutLength(heightSize + Padding.Top + Padding.Bottom), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK );
+ heightSize = Math.Max(heightSize, SuggestedMinimumHeight.AsDecimal());
+ MeasuredSize heightSizeAndState = ResolveSizeAndState(new LayoutLength(heightSize + Padding.Top + Padding.Bottom), heightMeasureSpec, MeasuredSize.StateType.MeasuredSizeOK);
heightSize = heightSizeAndState.Size.AsDecimal();
// 2nd phase:
// 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 - _totalLength + usedExcessSpace - (Padding.Top + Padding.Bottom);
- if( remainingExcess != 0 && totalWeight > 0.0f )
+ if (remainingExcess != 0 && totalWeight > 0.0f)
{
float remainingWeight = totalWeight;
maxWidth = 0;
_totalLength = 0;
int numberOfChildren = LayoutChildren.Count;
- for( int i = 0; i < numberOfChildren; ++i )
+ for (int i = 0; i < numberOfChildren; ++i)
{
LayoutItem childLayout = LayoutChildren[i];
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ continue;
+ }
float desiredChildWidth = childLayout.Owner.WidthSpecification;
float childWeight = childLayout.Owner.Weight;
Extents childMargin = childLayout.Margin;
- if( childWeight > 0 )
+ if (childWeight > 0)
{
MeasureWeightedChild(childLayout, remainingExcess, remainingWeight, childWeight,
widthMeasureSpec, heightMeasureSpec, childState,
float length = childLayout.MeasuredHeight.Size.AsDecimal() + childMargin.Top + childMargin.Bottom;
float cellPadding = i < numberOfChildren - 1 ? CellPadding.Height : 0;
- if( isExactly )
+ if (isExactly)
{
_totalLength += length;
}
else
{
float totalLength = _totalLength;
- _totalLength = Math.Max( _totalLength, _totalLength + length + cellPadding );
+ _totalLength = Math.Max(_totalLength, _totalLength + length + cellPadding);
}
bool matchWidthLocally = (widthMode != MeasureSpecification.ModeType.Exactly) && (desiredChildWidth == LayoutParamPolicies.MatchParent);
float marginWidth = childMargin.Start + childMargin.End;
float childWidth = childLayout.MeasuredWidth.Size.AsDecimal() + marginWidth;
- maxWidth = Math.Max( maxWidth, childWidth );
- alternativeMaxWidth = Math.Max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
+ maxWidth = Math.Max(maxWidth, childWidth);
+ alternativeMaxWidth = Math.Max(alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth);
allFillParent = (allFillParent && desiredChildWidth == LayoutParamPolicies.MatchParent);
} // for loop
}
else
{
- alternativeMaxWidth = Math.Max( alternativeMaxWidth, weightedMaxWidth );
+ alternativeMaxWidth = Math.Max(alternativeMaxWidth, weightedMaxWidth);
}
if (!allFillParent && widthMode != MeasureSpecification.ModeType.Exactly)
maxWidth = alternativeMaxWidth;
}
- maxWidth += (Owner.WidthSpecification == LayoutParamPolicies.WrapContent)?(Padding.Start + Padding.End):0;
- maxWidth = Math.Max( maxWidth, SuggestedMinimumWidth.AsRoundedValue());
+ maxWidth += (Owner.WidthSpecification == LayoutParamPolicies.WrapContent) ? (Padding.Start + Padding.End) : 0;
+ maxWidth = Math.Max(maxWidth, SuggestedMinimumWidth.AsRoundedValue());
heightSizeAndState.State = childState.heightState;
- SetMeasuredDimensions( ResolveSizeAndState( new LayoutLength(maxWidth), widthMeasureSpec, childState.widthState ),
- heightSizeAndState );
+ SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(maxWidth), widthMeasureSpec, childState.widthState),
+ heightSizeAndState);
if (matchWidth)
{
- ForceUniformWidth(heightMeasureSpec );
+ ForceUniformWidth(heightMeasureSpec);
}
} // MeasureVertical
LayoutLength height = new LayoutLength(bottom - top);
// Space available for child
- LayoutLength childSpace = new LayoutLength( height - Padding.Top - Padding.Bottom);
+ LayoutLength childSpace = new LayoutLength(height - Padding.Top - Padding.Bottom);
int count = LayoutChildren.Count;
// In case of RTL map BEGIN alignment to the right edge
if (isLayoutRtl)
{
- childLeft = new LayoutLength(Padding.Start + right.AsDecimal() - left.AsDecimal() - _totalLength);
+ childLeft = new LayoutLength(Padding.Start + right.AsDecimal() - left.AsDecimal() - _totalLength);
}
else
{
dir = -1;
}
- for( int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
int childIndex = start + dir * i;
// Get a reference to the childLayout at the given index
LayoutItem childLayout = LayoutChildren[childIndex];
- if( childLayout != null )
+ if (childLayout != null)
{
- LayoutLength childWidth = childLayout.MeasuredWidth.Size;
- LayoutLength childHeight = childLayout.MeasuredHeight.Size;
- Extents childMargin = childLayout.Margin;
-
- switch ( LinearAlignment )
+ if (childLayout.Owner.ExcludeLayouting)
{
- case Alignment.Bottom:
- childTop = new LayoutLength(height - Padding.Bottom - childHeight - childMargin.Bottom);
- break;
- case Alignment.CenterVertical:
- case Alignment.Center: // FALLTHROUGH
- childTop = new LayoutLength(Padding.Top + ( ( childSpace - childHeight ).AsDecimal() / 2.0f ) + childMargin.Top - childMargin.Bottom);
- break;
- case Alignment.Top: // FALLTHROUGH default
- default:
- childTop = new LayoutLength(Padding.Top + childMargin.Top);
- break;
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+ Extents childMargin = childLayout.Margin;
+
+ switch (LinearAlignment)
+ {
+ case Alignment.Bottom:
+ childTop = new LayoutLength(height - Padding.Bottom - childHeight - childMargin.Bottom);
+ break;
+ case Alignment.CenterVertical:
+ case Alignment.Center: // FALLTHROUGH
+ childTop = new LayoutLength(Padding.Top + ((childSpace - childHeight).AsDecimal() / 2.0f) + childMargin.Top - childMargin.Bottom);
+ break;
+ case Alignment.Top: // FALLTHROUGH default
+ default:
+ childTop = new LayoutLength(Padding.Top + childMargin.Top);
+ break;
+ }
+ childLeft += childMargin.Start;
+ childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+ childLeft += childWidth + childMargin.End + ((i < count - 1) ? CellPadding.Width : 0);
}
- childLeft += childMargin.Start;
- childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
- childLeft += childWidth + childMargin.End + ((i < count - 1) ? CellPadding.Width : 0);
}
}
} // LayoutHorizontally
LayoutLength width = new LayoutLength(right - left);
// Space available for child
- LayoutLength childSpace = new LayoutLength( width - Padding.Start - Padding.End);
+ LayoutLength childSpace = new LayoutLength(width - Padding.Start - Padding.End);
int count = LayoutChildren.Count;
switch (LinearAlignment)
{
- case Alignment.Bottom:
- // totalLength contains the padding already
- childTop = new LayoutLength( Padding.Top + bottom.AsDecimal() - top.AsDecimal() - _totalLength);
- break;
- case Alignment.CenterVertical: // FALL THROUGH
- case Alignment.Center:
- // totalLength contains the padding already
- childTop = new LayoutLength(Padding.Top + ( bottom.AsDecimal() - top.AsDecimal() - _totalLength ) / 2.0f);
- break;
- case Alignment.Top: // FALL THROUGH (default)
- default:
- // totalLength contains the padding already
- childTop = new LayoutLength( Padding.Top );
- break;
+ case Alignment.Bottom:
+ // totalLength contains the padding already
+ childTop = new LayoutLength(Padding.Top + bottom.AsDecimal() - top.AsDecimal() - _totalLength);
+ break;
+ case Alignment.CenterVertical: // FALL THROUGH
+ case Alignment.Center:
+ // totalLength contains the padding already
+ childTop = new LayoutLength(Padding.Top + (bottom.AsDecimal() - top.AsDecimal() - _totalLength) / 2.0f);
+ break;
+ case Alignment.Top: // FALL THROUGH (default)
+ default:
+ // totalLength contains the padding already
+ childTop = new LayoutLength(Padding.Top);
+ break;
}
- for( int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
LayoutItem childLayout = LayoutChildren[i];
- if( childLayout != null )
+ if (childLayout != null)
{
- LayoutLength childWidth = childLayout.MeasuredWidth.Size;
- LayoutLength childHeight = childLayout.MeasuredHeight.Size;
- Extents childMargin = childLayout.Margin;
-
- childTop += childMargin.Top;
- switch ( LinearAlignment )
+ if (childLayout.Owner.ExcludeLayouting)
{
- case Alignment.Begin:
- default:
- {
- childLeft = new LayoutLength(Padding.Start + childMargin.Start);
- break;
- }
- case Alignment.End:
- {
- childLeft = new LayoutLength(width - Padding.End - childWidth - childMargin.End);
- break;
- }
- case Alignment.CenterHorizontal:
- case Alignment.Center: // FALL THROUGH
- {
- childLeft = new LayoutLength(Padding.Start + (( childSpace - childWidth ).AsDecimal() / 2.0f) + childMargin.Start - childMargin.End);
- break;
- }
+ LayoutLength childWidth = childLayout.MeasuredWidth.Size;
+ LayoutLength childHeight = childLayout.MeasuredHeight.Size;
+ Extents childMargin = childLayout.Margin;
+
+ childTop += childMargin.Top;
+ switch (LinearAlignment)
+ {
+ case Alignment.Begin:
+ default:
+ {
+ childLeft = new LayoutLength(Padding.Start + childMargin.Start);
+ break;
+ }
+ case Alignment.End:
+ {
+ childLeft = new LayoutLength(width - Padding.End - childWidth - childMargin.End);
+ break;
+ }
+ case Alignment.CenterHorizontal:
+ case Alignment.Center: // FALL THROUGH
+ {
+ childLeft = new LayoutLength(Padding.Start + ((childSpace - childWidth).AsDecimal() / 2.0f) + childMargin.Start - childMargin.End);
+ break;
+ }
+ }
+ childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+ childTop += childHeight + childMargin.Bottom + ((i < count - 1) ? CellPadding.Height : 0);
}
- childLayout.Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
- childTop += childHeight + childMargin.Bottom + ((i < count - 1) ? CellPadding.Height : 0);
}
}
} // LayoutVertical
private void ForceUniformHeight(MeasureSpecification widthMeasureSpec)
{
- // 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);
- foreach (LayoutItem childLayout in LayoutChildren)
- {
- int desiredChildHeight = childLayout.Owner.HeightSpecification;
- int desiredChildWidth = childLayout.Owner.WidthSpecification;
-
- if (desiredChildHeight == LayoutParamPolicies.MatchParent)
- {
- // Temporarily force children to reuse their original measured width
- int originalWidth = desiredChildWidth;
- childLayout.Owner.WidthSpecification = (int)childLayout.MeasuredWidth.Size.AsRoundedValue();
- // Remeasure with new dimensions
- MeasureChildWithMargins( childLayout, widthMeasureSpec, new LayoutLength(0),
- uniformMeasureSpec, new LayoutLength(0) );
- // Restore width specification
- childLayout.Owner.WidthSpecification = originalWidth;
- }
- }
+ // 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);
+ foreach (LayoutItem childLayout in LayoutChildren)
+ {
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ continue;
+ }
+ int desiredChildHeight = childLayout.Owner.HeightSpecification;
+ int desiredChildWidth = childLayout.Owner.WidthSpecification;
+
+ if (desiredChildHeight == LayoutParamPolicies.MatchParent)
+ {
+ // Temporarily force children to reuse their original measured width
+ int originalWidth = desiredChildWidth;
+ childLayout.Owner.WidthSpecification = (int)childLayout.MeasuredWidth.Size.AsRoundedValue();
+ // Remeasure with new dimensions
+ MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0),
+ uniformMeasureSpec, new LayoutLength(0));
+ // Restore width specification
+ childLayout.Owner.WidthSpecification = originalWidth;
+ }
+ }
}
private void ForceUniformWidth(MeasureSpecification heightMeasureSpec)
{
// Pretend that the linear layout has an exact size.
- MeasureSpecification uniformMeasureSpec = new MeasureSpecification( MeasuredWidth.Size, MeasureSpecification.ModeType.Exactly);
+ MeasureSpecification uniformMeasureSpec = new MeasureSpecification(MeasuredWidth.Size, MeasureSpecification.ModeType.Exactly);
foreach (LayoutItem childLayout in LayoutChildren)
{
+ if (!childLayout.Owner.ExcludeLayouting)
+ {
+ continue;
+ }
+
int desiredChildWidth = childLayout.Owner.WidthSpecification;
int desiredChildHeight = childLayout.Owner.WidthSpecification;
- if (desiredChildWidth == LayoutParamPolicies.MatchParent)
+ if (desiredChildWidth == LayoutParamPolicies.MatchParent)
{
// Temporarily force children to reuse their original measured height
int originalHeight = desiredChildHeight;
- childLayout.Owner.HeightSpecification = (int)childLayout.MeasuredHeight.Size.AsRoundedValue();
+ childLayout.Owner.HeightSpecification = (int)childLayout.MeasuredHeight.Size.AsRoundedValue();
// Remeasure with new dimensions
- MeasureChildWithMargins( childLayout, uniformMeasureSpec, new LayoutLength(0),
+ MeasureChildWithMargins(childLayout, uniformMeasureSpec, new LayoutLength(0),
heightMeasureSpec, new LayoutLength(0));
// Restore height specification
childLayout.Owner.HeightSpecification = originalHeight;