[NUI] Fix MatchParent child position with LinearLayout Center Alignment
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 14 Sep 2021 11:15:56 +0000 (20:15 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 27 Sep 2021 08:27:23 +0000 (17:27 +0900)
Previously, LinearLayout calculated MatchParent children's positions
incorrectly when the LinearAlignment was Center.
Because the MatchParent children's sizes were not added to the sum of
all children's sizes.

Now, the MatchParent children's sizes are added to the sum of all
children's sizes and it leads that MatchParent children's positions are
calculated correctly when the LinearAlignment is Center.

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

index 31e80f1..0f51f08 100755 (executable)
@@ -343,6 +343,14 @@ namespace Tizen.NUI
             float remainingWidth = widthSize - totalLength;
             float totalWeightLength = 0.0f;
 
+            // Up to now, only WrapContent children's sizes are added to the totalLength.
+            // Since the totalLength is used in OnLayout as the sum of all children's sizes,
+            // the layout size is assigned to the totalLength if MatchParent child exists.
+            if (childrenMatchParentCount > 0)
+            {
+                totalLength = widthSize;
+            }
+
             // 2ND PHASE:
             //
             // We measure all children whose width specification policy is MatchParent without weight.
@@ -588,6 +596,14 @@ namespace Tizen.NUI
             float remainingHeight = heightSize - totalLength;
             float totalWeightLength = 0.0f;
 
+            // Up to now, only WrapContent children's sizes are added to the totalLength.
+            // Since the totalLength is used in OnLayout as the sum of all children's sizes,
+            // the layout size is assigned to the totalLength if MatchParent child exists.
+            if (childrenMatchParentCount > 0)
+            {
+                totalLength = heightSize;
+            }
+
             // 2ND PHASE:
             //
             // We measure all children whose height specification policy is MatchParent without weight.