[NUI] Skip adding cell padding to last LinearLayout item (#1815)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Thu, 9 Jul 2020 09:18:07 +0000 (18:18 +0900)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2020 09:18:07 +0000 (18:18 +0900)
Cell padding shouldn't be added to last item.
Skip addition at last item.

src/Tizen.NUI/src/public/Layouting/LinearLayout.cs

index 8020bbe..5d246e0 100755 (executable)
@@ -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