[NUI] Fix MenuItem to add TextLabel and Icon always
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 17 May 2022 08:47:40 +0000 (17:47 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Fri, 27 May 2022 06:15:42 +0000 (15:15 +0900)
Previously, MenuItem added TextLabel and Icon only if their properties
were set properly.
e.g. Icon is added only if IconURL is set properly.

Now, MenuItem adds TextLabel and Icon regardless of their properties
like Button does.
Because TextLabel and Icon are MenuItem's default feature so they
should always be added to MenuItem.

Icon's default size in theme is removed until Button has a proper way
to support default Icon size.

src/Tizen.NUI.Components/Controls/MenuItem.cs
src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs

index 7edb83d..b41e2e9 100755 (executable)
@@ -29,8 +29,6 @@ namespace Tizen.NUI.Components
     {
         private bool selectedAgain = false;
 
-        private bool styleApplied = false;
-
         /// <summary>
         /// Creates a new instance of MenuItem.
         /// </summary>
@@ -66,31 +64,6 @@ namespace Tizen.NUI.Components
             base.Dispose(type);
         }
 
-        /// <summary>
-        /// Applies style to MenuItem.
-        /// </summary>
-        /// <param name="viewStyle">The style to apply.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public override void ApplyStyle(ViewStyle viewStyle)
-        {
-            styleApplied = false;
-
-            base.ApplyStyle(viewStyle);
-
-            styleApplied = true;
-
-            //Calculate position based on Achor's position.
-            LayoutItems();
-        }
-
-        /// <inheritdoc/>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public override void OnRelayout(Vector2 size, RelayoutContainer container)
-        {
-            base.OnRelayout(size, container);
-            LayoutItems();
-        }
-
         /// <inheritdoc/>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public override bool OnKey(Key key)
@@ -176,53 +149,6 @@ namespace Tizen.NUI.Components
             }
         }
 
-        /// <inheritdoc/>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override void LayoutItems()
-        {
-            if (styleApplied == false)
-            {
-                return;
-            }
-
-            bool isEmptyIcon = false;
-            bool isEmptyText = false;
-
-            if (String.IsNullOrEmpty(Icon.ResourceUrl))
-            {
-                isEmptyIcon = true;
-            }
-
-            if (String.IsNullOrEmpty(TextLabel.Text))
-            {
-                isEmptyText = true;
-            }
-
-            if (isEmptyIcon)
-            {
-                if (Children.Contains(Icon))
-                {
-                    Remove(Icon);
-                }
-            }
-            else if (Children.Contains(Icon) == false)
-            {
-                Add(Icon);
-            }
-
-            if (isEmptyText)
-            {
-                if (Children.Contains(TextLabel))
-                {
-                    Remove(TextLabel);
-                }
-            }
-            else if (Children.Contains(TextLabel) == false)
-            {
-                Add(TextLabel);
-            }
-        }
-
         private void Initialize()
         {
             Layout = new LinearLayout()
index c3ee27f..c693271 100755 (executable)
@@ -772,7 +772,6 @@ namespace Tizen.NUI.Components
                 },
                 Icon = new ImageViewStyle()
                 {
-                    Size = new Size(32, 32),
                     Color = new Selector<Color>()
                     {
                         Normal = new Color("#090E21"),