From: Bowon Ryu Date: Tue, 1 Apr 2025 09:45:38 +0000 (+0900) Subject: [NUI] Fix height calculation of TextLabelLayout X-Git-Tag: submit/tizen_9.0/20250612.150947~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8427e866e2d81b78a250f556efac2faf8410a46;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix height calculation of TextLabelLayout When the label's HeightSpecification is wrap content, the result of GetHeightForWidth() is used to calculate the text height. The previous behavior simply used NaturalSize, so it could not guarantee the behavior of the case below. ``` var label = new TextLabel { Text = "Something long long text...", WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = LayoutParamPolicies.WrapContent, MaximumSize = new Size(400, 400), Padding = new Extents(25, 25, 10, 10), MultiLine = true, }; ``` Signed-off-by: Bowon Ryu --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 6adbc05a5..8db064485 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -45,7 +45,8 @@ namespace Tizen.NUI.BaseComponents { if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly) { - totalHeight = Owner.GetHeightForWidth(totalWidth); + var padding = Owner.Padding; + totalHeight = Owner.GetHeightForWidth(totalWidth - (padding.Start + padding.End)); heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly); } } @@ -65,8 +66,11 @@ namespace Tizen.NUI.BaseComponents else { float width = naturalSize != null ? naturalSize.Width : 0; - float height = naturalSize != null ? naturalSize.Height : 0; + // Since priority of MinimumSize is higher than MaximumSize in DALi, here follows it. totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width)); + + var padding = Owner.Padding; + float height = Owner.GetHeightForWidth(totalWidth - (padding.Start + padding.End)); totalHeight = Math.Min(Math.Max(height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height)); heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);