From bd6feb33910416217f8eab72d492414eb4562e6a Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Wed, 10 Nov 2021 21:59:12 +0900 Subject: [PATCH] [NUI] Fix WrapContent View's LinearLayout size calculation When a View's Specification was WrapContent, the View's LinearLayout did not consider its child size correctly. This caused that the View's Size became 0 incorrectly. To resolve the above, LinearLayout always considers its child size and the LinearLayout uses its child size when it calculates its own size. --- src/Tizen.NUI/src/public/Layouting/LinearLayout.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs b/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs index 9115e3f..99a7444 100755 --- a/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs +++ b/src/Tizen.NUI/src/public/Layouting/LinearLayout.cs @@ -426,6 +426,7 @@ namespace Tizen.NUI int childDesiredHeight = childLayout.Owner.HeightSpecification; float childWeight = childLayout.Owner.Weight; Extents childMargin = childLayout.Margin; + float childMarginHeight = childMargin.Top + childMargin.Bottom; bool useRemainingWidth = (childDesiredWidth == 0) && (childWeight > 0); bool needToMeasure = false; @@ -486,6 +487,16 @@ namespace Tizen.NUI if (needToMeasure == true) { MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0)); + + float childMeasuredHeight = childLayout.MeasuredHeight.Size.AsDecimal(); + if (childMeasuredHeight < 0) + { + maxHeight = Math.Max(maxHeight, childMarginHeight); + } + else + { + maxHeight = Math.Max(maxHeight, childMeasuredHeight + childMarginHeight); + } } if ((childWeight > 0) && ((childDesiredWidth == LayoutParamPolicies.MatchParent) || (childDesiredWidth == 0))) @@ -678,6 +689,7 @@ namespace Tizen.NUI int childDesiredHeight = childLayout.Owner.HeightSpecification; float childWeight = childLayout.Owner.Weight; Extents childMargin = childLayout.Margin; + float childMarginWidth = childMargin.Start + childMargin.End; bool useRemainingHeight = (childDesiredHeight == 0) && (childWeight > 0); bool needToMeasure = false; @@ -738,6 +750,16 @@ namespace Tizen.NUI if (needToMeasure == true) { MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0)); + + float childMeasuredWidth = childLayout.MeasuredWidth.Size.AsDecimal(); + if (childMeasuredWidth < 0) + { + maxWidth = Math.Max(maxWidth, childMarginWidth); + } + else + { + maxWidth = Math.Max(maxWidth, childMeasuredWidth + childMarginWidth); + } } if ((childWeight > 0) && ((childDesiredHeight == LayoutParamPolicies.MatchParent) || (childDesiredHeight == 0))) -- 2.7.4