[NUI] Fix to add and update TabButton's sub components correctly
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 11 May 2021 05:48:36 +0000 (14:48 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Tue, 11 May 2021 11:03:10 +0000 (20:03 +0900)
Button.LayoutItems() adds sub components and
Button.UpdateSizeAndSpacing() calculates sub components' sizes and
spacing.

Like Button, TabButton.LayoutItems() is separated into LayoutItems() and
UpdateSizeAndSpacing().

Button.OnUpdate() is not necessary for TabButton.

src/Tizen.NUI.Components/Controls/TabButton.cs

index 5db6e7a..aa10ea9 100755 (executable)
@@ -125,6 +125,14 @@ namespace Tizen.NUI.Components
 
         /// <inheritdoc/>
         [EditorBrowsable(EditorBrowsableState.Never)]
+        public override void OnRelayout(Vector2 size, RelayoutContainer container)
+        {
+            base.OnRelayout(size, container);
+            UpdateSizeAndSpacing();
+        }
+
+        /// <inheritdoc/>
+        [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void Dispose(DisposeTypes type)
         {
             if (disposed)
@@ -214,21 +222,8 @@ namespace Tizen.NUI.Components
 
         /// <inheritdoc/>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override void OnUpdate()
-        {
-            base.OnUpdate();
-            LayoutItems();
-        }
-
-        /// <inheritdoc/>
-        [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void LayoutItems()
         {
-            if (styleApplied == false)
-            {
-                return;
-            }
-
             if ((Icon == null) && (TextLabel == null))
             {
                 return;
@@ -245,6 +240,30 @@ namespace Tizen.NUI.Components
             {
                 Add(TextLabel);
             }
+        }
+
+        private void Initialize()
+        {
+            Layout = new AbsoluteLayout();
+
+            topLine = new View(tabButtonStyle?.TopLine);
+            Add(topLine);
+
+            bottomLine = new View(tabButtonStyle?.BottomLine);
+            Add(bottomLine);
+        }
+
+        private void UpdateSizeAndSpacing()
+        {
+            if (styleApplied == false)
+            {
+                return;
+            }
+
+            if ((Icon == null) && (TextLabel == null))
+            {
+                return;
+            }
 
             // FIXME: set Selector<Extents> to padding
             var padding = new Extents(40, 40, 24, 24);
@@ -333,16 +352,5 @@ namespace Tizen.NUI.Components
 
             padding?.Dispose();
         }
-
-        private void Initialize()
-        {
-            Layout = new AbsoluteLayout();
-
-            topLine = new View(tabButtonStyle?.TopLine);
-            Add(topLine);
-
-            bottomLine = new View(tabButtonStyle?.BottomLine);
-            Add(bottomLine);
-        }
     }
 }