[NUI] Fix Button Theme not to set fixed size
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Wed, 15 Feb 2023 11:02:05 +0000 (20:02 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Thu, 16 Feb 2023 01:59:18 +0000 (10:59 +0900)
To increase Button width based on the Button's text, Button Theme sets
MinimumSize instead of fixed Size.

src/Tizen.NUI.Components/Controls/Button.Internal.cs
src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs

index 071f7f2..ea06e8f 100644 (file)
@@ -435,11 +435,11 @@ namespace Tizen.NUI.Components
 
                     if (iconRelativeOrientation == IconOrientation.Left || iconRelativeOrientation == IconOrientation.Right)
                     {
-                        lengthWithoutText += (itemSpacing?.Width ?? 0) + iconMargin.Start + iconMargin.End + textMargin.Start + textMargin.End;
+                        lengthWithoutText += (itemSpacing?.Width ?? 0) + iconMargin.Start + iconMargin.End + textMargin.Start + textMargin.End + Padding.Start + Padding.End;
                     }
                     else
                     {
-                        lengthWithoutText += (itemSpacing?.Height ?? 0) + iconMargin.Top + iconMargin.Bottom + textMargin.Top + textMargin.Bottom;
+                        lengthWithoutText += (itemSpacing?.Height ?? 0) + iconMargin.Top + iconMargin.Bottom + textMargin.Top + textMargin.Bottom + Padding.Top + Padding.Bottom;
                     }
                 }
             }
index a73f021..e9adaad 100755 (executable)
@@ -39,7 +39,8 @@ namespace Tizen.NUI.Components
             // Button base style
             theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
             {
-                Size = new Size(252, 48),
+                MinimumSize = new Size(252, 48),
+                Padding = new Extents(32, 32, 8, 8),
                 ItemSpacing = new Size2D(8, 8),
                 CornerRadius = 12.0f,
                 ItemHorizontalAlignment = HorizontalAlignment.Center,
@@ -62,7 +63,8 @@ namespace Tizen.NUI.Components
             // Outlined Button style
             theme.AddStyleWithoutClone("Tizen.NUI.Components.Button.Outlined", new ButtonStyle()
             {
-                Size = new Size(252, 48),
+                MinimumSize = new Size(252, 48),
+                Padding = new Extents(32, 32, 8, 8),
                 ItemSpacing = new Size2D(8, 8),
                 CornerRadius = 12.0f,
                 BorderlineWidth = 2.0f,
@@ -94,7 +96,6 @@ namespace Tizen.NUI.Components
             // TextOnly Button style
             theme.AddStyleWithoutClone("Tizen.NUI.Components.Button.TextOnly", new ButtonStyle()
             {
-                SizeHeight = 48,
                 MinimumSize = new Size(120, 48),
                 Padding = new Extents(32, 32, 8, 8),
                 ItemHorizontalAlignment = HorizontalAlignment.Center,