[NUI] Fix to add and update TabButton's sub components correctly
[platform/core/csapi/tizenfx.git] / 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);
-        }
     }
 }