[NUI] Fix AbsoluteLayout not to apply margin/padding for using pivot
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Mon, 17 Mar 2025 06:55:47 +0000 (15:55 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 18 Mar 2025 06:08:52 +0000 (15:08 +0900)
AbsoluteLayout OnLayout calculated child size and position incorrectly
for using pivot cases.
This PR fixes AbsoluteLayout OnLayout not to apply margin and padding
for using pivot cases.

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

index ca5b98077f866ad573bb48505559692c5a20e7fd..39ebb85b6410410aff1abdd6c228e730e0c6fecb 100755 (executable)
@@ -275,34 +275,21 @@ namespace Tizen.NUI
                 LayoutLength childLeft;
                 LayoutLength childTop;
 
-                var isBoundsSet = childLayout.Owner.GetAttached<LayoutParams>() != null;
-                var rect = GetLayoutBounds(childLayout.Owner);
-                var flags = GetLayoutFlags(childLayout.Owner);
-                var isXProportional = flags.HasFlag(AbsoluteLayoutFlags.XProportional);
-                var isYProportional = flags.HasFlag(AbsoluteLayoutFlags.YProportional);
-
                 // If child view positions with using pivot point, then padding and margin are not used.
                 if (childLayout.Owner.PositionUsesPivotPoint)
                 {
-                    var childX = MeasurePosition(isBoundsSet, childLayout.Owner.PositionX, rect.X, isXProportional,
-                                MeasuredWidth.Size.AsDecimal() - (Padding.Start + Padding.End),
-                                childWidth.AsDecimal() + (childMargin.Start + childMargin.End),
-                                Padding.Start, childMargin.Start);
-
-                    var childY = MeasurePosition(isBoundsSet, childLayout.Owner.PositionY, rect.Y, isYProportional,
-                                MeasuredHeight.Size.AsDecimal() - (Padding.Top + Padding.Bottom),
-                                childHeight.AsDecimal() + (childMargin.Top + childMargin.Bottom),
-                                Padding.Top, childMargin.Bottom);
-
-                    childLeft = new LayoutLength(childX);
-                    childTop = new LayoutLength(childY);
-
-                    childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
+                    childLeft = new LayoutLength(childLayout.Owner.PositionX);
+                    childTop = new LayoutLength(childLayout.Owner.PositionY);
+                    childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight, true);
                 }
                 else
                 {
-                    // Determine the width and height needed by the children using their given position and size.
-                    // Children could overlap so find the right most child.
+                    var isBoundsSet = childLayout.Owner.GetAttached<LayoutParams>() != null;
+                    var rect = GetLayoutBounds(childLayout.Owner);
+                    var flags = GetLayoutFlags(childLayout.Owner);
+                    var isXProportional = flags.HasFlag(AbsoluteLayoutFlags.XProportional);
+                    var isYProportional = flags.HasFlag(AbsoluteLayoutFlags.YProportional);
+
                     var childX = MeasurePosition(isBoundsSet, childLayout.Owner.PositionX, rect.X, isXProportional,
                                 MeasuredWidth.Size.AsDecimal() - (Padding.Start + Padding.End),
                                 childWidth.AsDecimal() + (childMargin.Start + childMargin.End),
@@ -316,15 +303,7 @@ namespace Tizen.NUI
                     childLeft = new LayoutLength(childX);
                     childTop = new LayoutLength(childY);
 
-                    // If child view positions with using pivot point, then padding and margin are not used.
-                    if (childLayout.Owner.PositionUsesPivotPoint)
-                    {
-                        childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight, true);
-                    }
-                    else
-                    {
-                        childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
-                    }
+                    childLayout.Layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
                 }
             }
         }