From 802490826fbcf3bea2cbec6984e57e8fece05d1d Mon Sep 17 00:00:00 2001 From: neostom432 <31119276+neostom432@users.noreply.github.com> Date: Thu, 9 Jul 2020 18:18:07 +0900 Subject: [PATCH] [NUI] Skip adding cell padding to last LinearLayout item (#1815) Cell padding shouldn't be added to last item. Skip addition at last item. --- src/Tizen.NUI/src/public/Layouting/LinearLayout.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs b/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs index 8020bbe..5d246e0 100755 --- a/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs +++ b/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs @@ -286,8 +286,9 @@ namespace Tizen.NUI // Weighted children are not measured at this phase. // Available space for weighted children will be calculated in the phase 2 based on totalLength value. // Max height of children is stored. - foreach( LayoutItem childLayout in LayoutChildren ) + for (int i = 0; i < LayoutChildren.Count; i++) { + LayoutItem childLayout = LayoutChildren[i]; int childDesiredHeight = childLayout.Owner.HeightSpecification; float childWeight = childLayout.Owner.Weight; Extents childMargin = childLayout.Margin; @@ -339,7 +340,7 @@ namespace Tizen.NUI } else { - _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + CellPadding.Width); + _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + (i < LayoutChildren.Count - 1 ? CellPadding.Width : 0)); } } @@ -487,8 +488,9 @@ namespace Tizen.NUI // to accumulate total used space in _totalLength. // Weighted children are not measured in this phase. // Available space for weighted children will be calculated in the phase 2 based on _totalLength value. - foreach( LayoutItem childLayout in LayoutChildren ) + for (int i = 0; i < LayoutChildren.Count; i++) { + LayoutItem childLayout = LayoutChildren[i]; int childDesiredWidth = childLayout.Owner.WidthSpecification; float childWeight = childLayout.Owner.Weight; Extents childMargin = childLayout.Margin; @@ -540,7 +542,7 @@ namespace Tizen.NUI } else { - _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + CellPadding.Height); + _totalLength = Math.Max(_totalLength, _totalLength + length.AsDecimal() + (i < LayoutChildren.Count - 1 ? CellPadding.Height : 0)); } } @@ -744,7 +746,7 @@ namespace Tizen.NUI } childLeft += childMargin.Start; childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight); - childLeft += childWidth + childMargin.End + CellPadding.Width; + childLeft += childWidth + childMargin.End + ((i < count - 1) ? CellPadding.Width : 0); } } } // LayoutHorizontally @@ -811,7 +813,7 @@ namespace Tizen.NUI } } childLayout.Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight ); - childTop += childHeight + childMargin.Bottom + CellPadding.Height; + childTop += childHeight + childMargin.Bottom + ((i < count - 1) ? CellPadding.Height : 0); } } } // LayoutVertical -- 2.7.4