[NUI] Fix text padding issue
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 29 Dec 2023 06:06:24 +0000 (15:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 9 Jan 2024 09:23:06 +0000 (18:23 +0900)
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 <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs

index cf4ec09fe4c9639d07fe095b04a14aef65204932..5dcf4537c70db2b96fb6eb91a1883ade777eae2b 100755 (executable)
@@ -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)
             {
index 5d156bff7f0b991c3f846bed48b4e9b36f4df2d1..69ee9c10870f02552fe97cbc465fe91eebd0235d 100755 (executable)
@@ -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)
             {
index 1bd236e69554eb1e7828988e07ca09db3b003267..513088f89f18cb521bf02a9dba617cff0e0768b6 100755 (executable)
@@ -33,7 +33,7 @@ namespace Tizen.NUI.BaseComponents
     /// <since_tizen> 3 </since_tizen>
     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();
         }
 
         /// <summary>
index 947edadd09d97a188acb4eea9fb3c92dd3253fe2..3423ab05f7c93a458ca0946f07ca154051c40516 100755 (executable)
@@ -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;