From 4515dc8bba95f092b4ea18d4ef3810fbb53898e3 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 29 Dec 2023 15:06:24 +0900 Subject: [PATCH] [NUI] Fix text padding issue This patch solves the problem that text with padding does not work in nui layout. For text components, the control's padding is used to calculatie size in native, so it should not be set to zero value. This avoids setting padding to zero when it comes to text layout. Signed-off-by: Bowon Ryu --- src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs | 2 +- src/Tizen.NUI/src/public/BaseComponents/TextField.cs | 2 +- src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs | 4 ++-- src/Tizen.NUI/src/public/BaseComponents/View.cs | 8 +++++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index cf4ec09fe..5dcf4537c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -2827,7 +2827,7 @@ namespace Tizen.NUI.BaseComponents GrabHandleColor = new Color(r, g, b, a); } - private class TextEditorLayout : LayoutItem + internal class TextEditorLayout : LayoutItem { protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec) { diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 5d156bff7..69ee9c108 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -2832,7 +2832,7 @@ namespace Tizen.NUI.BaseComponents GrabHandleColor = new Color(r, g, b, a); } - private class TextFieldLayout : LayoutItem + internal class TextFieldLayout : LayoutItem { protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec) { diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 1bd236e69..513088f89 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -33,7 +33,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public partial class TextLabel : View { - private class TextLayout : LayoutItem + internal class TextLabelLayout : LayoutItem { protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec) { @@ -1765,7 +1765,7 @@ namespace Tizen.NUI.BaseComponents internal override LayoutItem CreateDefaultLayout() { - return new TextLayout(); + return new TextLabelLayout(); } /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 947edadd0..3423ab05f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -3008,7 +3008,13 @@ namespace Tizen.NUI.BaseComponents setMargin = true; } - if (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0) + // The calculation of the native size of the text component requires padding. + // Don't overwrite the zero padding. + bool isTextLayout = (value is Tizen.NUI.BaseComponents.TextLabel.TextLabelLayout) || + (value is Tizen.NUI.BaseComponents.TextField.TextFieldLayout) || + (value is Tizen.NUI.BaseComponents.TextEditor.TextEditorLayout); + + if (!isTextLayout && (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0)) { // If View already has a padding set then store it in Layout instead. value.Padding = padding; -- 2.34.1