[NUI] Delete Tizen.NUI.Components build warnings (#2674)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
index ec6a25b..c566f66 100755 (executable)
@@ -19,31 +19,51 @@ using System.ComponentModel;
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Binding;
 using Tizen.NUI.Components.Extension;
+using Tizen.NUI.Accessibility;
 
 namespace Tizen.NUI.Components
 {
     /// <summary>
+    /// ClickedEventArgs is a class to record button click event arguments which will sent to user.
+    /// </summary>
+    /// <since_tizen> 8 </since_tizen>
+    public class ClickedEventArgs : EventArgs
+    {
+    }
+
+    /// <summary>
+    /// SelectedChangedEventArgs is a class to record item selected arguments which will sent to user.
+    /// </summary>
+    /// <since_tizen> 8 </since_tizen>
+    public class SelectedChangedEventArgs : EventArgs
+    {
+        /// <summary> Selected state </summary>
+        /// <since_tizen> 8 </since_tizen>
+        public bool IsSelected { get; set; }
+    }
+
+    /// <summary>
     /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
     /// Button may contain text or an icon.
     /// </summary>
     /// <since_tizen> 6 </since_tizen>
-    public class Button : Control
+    public partial class Button : Control
     {
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Button)bindable;
-            if (newValue != null)
+            var newIconOrientation = (IconOrientation?)newValue;
+            if (instance.iconRelativeOrientation != newIconOrientation)
             {
-                instance.privateIconRelativeOrientation = (IconOrientation?)newValue;
+                instance.iconRelativeOrientation = newIconOrientation;
+                instance.UpdateUIContent();
             }
         },
-        defaultValueCreator: (bindable) =>
-        {
-            var instance = (Button)bindable;
-            return instance.privateIconRelativeOrientation;
-        });
+        defaultValueCreator: (bindable) => ((Button)bindable).iconRelativeOrientation
+        );
+
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
@@ -51,14 +71,21 @@ namespace Tizen.NUI.Components
             var instance = (Button)bindable;
             if (newValue != null)
             {
-                instance.privateIsEnabled = (bool)newValue;
+                bool newEnabled = (bool)newValue;
+                if (instance.isEnabled != newEnabled)
+                {
+                    instance.isEnabled = newEnabled;
+
+                    if (instance.buttonStyle != null)
+                    {
+                        instance.buttonStyle.IsEnabled = newEnabled;
+                    }
+
+                    instance.UpdateState();
+                }
             }
         },
-        defaultValueCreator: (bindable) =>
-        {
-            var instance = (Button)bindable;
-            return instance.privateIsEnabled;
-        });
+        defaultValueCreator: (bindable) => ((Button)bindable).isEnabled);
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
@@ -66,13 +93,27 @@ namespace Tizen.NUI.Components
             var instance = (Button)bindable;
             if (newValue != null)
             {
-                instance.privateIsSelected = (bool)newValue;
+                bool newSelected = (bool)newValue;
+                if (instance.isSelected != newSelected)
+                {
+                    instance.isSelected = newSelected;
+
+                    if (instance.buttonStyle != null)
+                    {
+                        instance.buttonStyle.IsSelected = newSelected;
+                    }
+
+                    if (instance.isSelectable)
+                    {
+                        instance.UpdateState();
+                    }
+                }
             }
         },
         defaultValueCreator: (bindable) =>
         {
             var instance = (Button)bindable;
-            return instance.privateIsSelected;
+            return instance.isSelectable && instance.isSelected;
         });
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -81,121 +122,48 @@ namespace Tizen.NUI.Components
             var instance = (Button)bindable;
             if (newValue != null)
             {
-                instance.privateIsSelectable = (bool)newValue;
+                bool newSelectable = (bool)newValue;
+                if (instance.isSelectable != newSelectable)
+                {
+                    instance.isSelectable = newSelectable;
+
+                    if (instance.buttonStyle != null)
+                    {
+                        instance.buttonStyle.IsSelectable = newSelectable;
+                    }
+
+                    instance.UpdateState();
+                }
             }
         },
-        defaultValueCreator: (bindable) =>
-        {
-            var instance = (Button)bindable;
-            return instance.privateIsSelectable;
-        });
+        defaultValueCreator: (bindable) => ((Button)bindable).isSelectable);
+
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Button)bindable;
-            if (null != newValue && null != instance.Style?.IconPadding)
-            {
-                instance.Style.IconPadding.CopyFrom((Extents)newValue);
-                instance.UpdateUIContent();
-            }
+            instance.iconPadding = (Extents)((Extents)newValue).Clone();
+            instance.UpdateUIContent();
         },
-        defaultValueCreator: (bindable) =>
-        {
-            var instance = (Button)bindable;
-            return instance.Style?.IconPadding;
-        });
+        defaultValueCreator: (bindable) => ((Button)bindable).iconPadding);
+
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Button)bindable;
-            if (null != newValue && null != instance.Style?.TextPadding)
-            {
-                instance.Style.TextPadding.CopyFrom((Extents)newValue);
-                instance.UpdateUIContent();
-            }
+            instance.textPadding = (Extents)((Extents)newValue).Clone();
+            instance.UpdateUIContent();
         },
-        defaultValueCreator: (bindable) =>
-        {
-            var instance = (Button)bindable;
-            return instance.Style?.TextPadding;
-        });
-
-        private EventHandler<StateChangedEventArgs> stateChangeHander;
+        defaultValueCreator: (bindable) => ((Button)bindable).textPadding);
 
+        private IconOrientation? iconRelativeOrientation;
         private bool isSelected = false;
+        private bool isSelectable = false;
         private bool isEnabled = true;
-        private bool isPressed = false;
-
-        /// <summary>
-        /// Button's overlay image part.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected ImageView ButtonOverlayImage { get; set; }
-
-        /// <summary>
-        /// Button's text part.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected TextLabel ButtonText { get; set; }
-
-        /// <summary>
-        /// Button's icon part.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected ImageView ButtonIcon { get; set; }
-
-        /// <summary>
-        /// The last touch information triggering selected state change.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected Touch SelectionChangedByTouch { get; set; }
-
-        /// <summary>
-        /// The ButtonExtension instance that is injected by ButtonStyle.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected ButtonExtension Extension { get; set; }
-
-        /// <summary>
-        /// Creates Button's text part.
-        /// </summary>
-        /// <return>The created Button's text part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual TextLabel CreateText()
-        {
-            return new TextLabel();
-        }
-
-        /// <summary>
-        /// Creates Button's icon part.
-        /// </summary>
-        /// <return>The created Button's icon part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual ImageView CreateIcon()
-        {
-            return new ImageView();
-        }
-
-        /// <summary>
-        /// Creates Button's overlay image part.
-        /// </summary>
-        /// <return>The created Button's overlay image part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual ImageView CreateOverlayImage()
-        {
-            return new ImageView();
-        }
-
-        /// <summary>
-        /// Called when the Button is Clicked by a user
-        /// </summary>
-        /// <param name="eventArgs">The click information.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void OnClick(ClickEventArgs eventArgs)
-        {
-        }
+        private Extents iconPadding;
+        private Extents textPadding;
 
         static Button() { }
 
@@ -232,22 +200,32 @@ namespace Tizen.NUI.Components
         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
+        [Obsolete("Deprecated in API8; Will be removed in API10. Please use Clicked event instead.")]
         public event EventHandler<ClickEventArgs> ClickEvent;
+
+        /// <summary>
+        /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
+        /// </summary>
+        /// <since_tizen> 8 </since_tizen>
+        public event EventHandler<ClickedEventArgs> Clicked;
+
         /// <summary>
         /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
+        [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEvent")]
         public event EventHandler<StateChangedEventArgs> StateChangedEvent
         {
             add
             {
-                stateChangeHander += value;
+                stateChangeHandler += value;
             }
             remove
             {
-                stateChangeHander -= value;
+                stateChangeHandler -= value;
             }
         }
+
         /// <summary>
         /// Icon orientation.
         /// </summary>
@@ -277,55 +255,141 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
-        /// Style of the button.
+        /// Button's icon part.
         /// </summary>
         /// <since_tizen> 8 </since_tizen>
-        public new ButtonStyle Style => ViewStyle as ButtonStyle;
+        public ImageView Icon
+        {
+            get
+            {
+                if (null == buttonIcon)
+                {
+                    buttonIcon = CreateIcon();
+                    if (null != Extension)
+                    {
+                        buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
+                    }
+                    if (null != buttonIcon)
+                    {
+                        Add(buttonIcon);
+                        buttonIcon.Relayout += OnIconRelayout;
+                    }
+                }
+                return buttonIcon;
+            }
+            internal set
+            {
+                buttonIcon = value;
+            }
+        }
 
         /// <summary>
-        /// The text of Button.
+        /// Button's overlay image part.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        public string Text
+        /// <since_tizen> 8 </since_tizen>
+        public ImageView OverlayImage
         {
             get
             {
-                return Style?.Text?.Text?.GetValue(ControlState);
+                if (null == overlayImage)
+                {
+                    overlayImage = CreateOverlayImage();
+                    if (null != Extension)
+                    {
+                        overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
+                    }
+                    if (null != overlayImage)
+                    {
+                        Add(overlayImage);
+                    }
+                }
+                return overlayImage;
             }
-            set
+            internal set
             {
-                if (null != Style?.Text)
+                overlayImage = value;
+            }
+        }
+
+        /// <summary>
+        /// Button's text part.
+        /// </summary>
+        /// <since_tizen> 8 </since_tizen>
+        public TextLabel TextLabel
+        {
+            get
+            {
+                if (null == buttonText)
                 {
-                    Style.Text.Text = value;
+                    buttonText = CreateText();
+                    if (null != Extension)
+                    {
+                        buttonText = Extension.OnCreateText(this, buttonText);
+                    }
+                    if (null != buttonText)
+                    {
+                        Add(buttonText);
+                    }
                 }
+                return buttonText;
+            }
+            internal set
+            {
+                buttonText = value;
+                AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Label, buttonText.Text);
             }
         }
 
         /// <summary>
-        /// Flag to decide Button can be selected or not.
+        /// Return a copied Style instance of Button
+        /// </summary>
+        /// <remarks>
+        /// It returns copied Style instance and changing it does not effect to the Button.
+        /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+        /// </remarks>
+        /// <since_tizen> 8 </since_tizen>
+        public new ButtonStyle Style
+        {
+            get
+            {
+                var result = (ButtonStyle)ViewStyle.Clone();
+                result.CopyPropertiesFromView(this);
+                result.Text.CopyPropertiesFromView(TextLabel);
+                result.Icon.CopyPropertiesFromView(Icon);
+                result.Overlay.CopyPropertiesFromView(OverlayImage);
+                return result;
+            }
+        }
+
+        /// <summary>
+        /// The text of Button.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
-        public bool IsSelectable
+        public string Text
         {
             get
             {
-                return (bool)GetValue(IsSelectableProperty);
+                return TextLabel.Text;
             }
             set
             {
-                SetValue(IsSelectableProperty, value);
+                TextLabel.Text = value;
             }
         }
 
-        private bool privateIsSelectable
+        /// <summary>
+        /// Flag to decide Button can be selected or not.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public bool IsSelectable
         {
             get
             {
-                return Style?.IsSelectable ?? false;
+                return (bool)GetValue(IsSelectableProperty);
             }
             set
             {
-                Style.IsSelectable = value;
+                SetValue(IsSelectableProperty, value);
             }
         }
 
@@ -337,14 +401,11 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Text?.TranslatableText?.All;
+                return TextLabel.TranslatableText;
             }
             set
             {
-                if (null != Style?.Text)
-                {
-                    Style.Text.TranslatableText = value;
-                }
+                TextLabel.TranslatableText = value;
             }
         }
 
@@ -356,14 +417,11 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Text?.PointSize?.All ?? 0;
+                return TextLabel.PointSize;
             }
             set
             {
-                if (null != Style?.Text)
-                {
-                    Style.Text.PointSize = value;
-                }
+                TextLabel.PointSize = value;
             }
         }
 
@@ -375,16 +433,14 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Text?.FontFamily.All;
+                return TextLabel.FontFamily;
             }
             set
             {
-                if (null != Style?.Text)
-                {
-                    Style.Text.FontFamily = value;
-                }
+                TextLabel.FontFamily = value;
             }
         }
+
         /// <summary>
         /// Text color in Button.
         /// </summary>
@@ -393,16 +449,14 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Text?.TextColor?.All;
+                return TextLabel.TextColor;
             }
             set
             {
-                if (null != Style?.Text)
-                {
-                    Style.Text.TextColor = value;
-                }
+                TextLabel.TextColor = value;
             }
         }
+
         /// <summary>
         /// Text horizontal alignment in Button.
         /// </summary>
@@ -411,16 +465,14 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
+                return TextLabel.HorizontalAlignment;
             }
             set
             {
-                if (null != Style?.Text)
-                {
-                    Style.Text.HorizontalAlignment = value;
-                }
+                TextLabel.HorizontalAlignment = value;
             }
         }
+
         /// <summary>
         /// Icon image's resource url in Button.
         /// </summary>
@@ -429,99 +481,121 @@ namespace Tizen.NUI.Components
         {
             get
             {
-                return Style?.Icon?.ResourceUrl?.All;
+                return Icon.ResourceUrl;
             }
             set
             {
-                if (null != Style?.Icon)
-                {
-                    Style.Icon.ResourceUrl = value;
-                }
+                Icon.ResourceUrl = value;
             }
         }
 
-        private StringSelector textSelector = new StringSelector();
         /// <summary>
         /// Text string selector in Button.
+        /// Getter returns copied selector value if exist, null otherwise.
+        /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         public StringSelector TextSelector
         {
-            get
-            {
-                return textSelector;
-            }
+            get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
             set
             {
-                textSelector.Clone(value);
+                if (value == null || buttonText == null)
+                {
+                    throw new NullReferenceException("Button.TextSelector is null");
+                }
+                else
+                {
+                    buttonText.SetValue(TextLabel.TextSelectorProperty, value);
+                }
             }
         }
 
-        private StringSelector translatableTextSelector = new StringSelector();
         /// <summary>
         /// Translateable text string selector in Button.
+        /// Getter returns copied selector value if exist, null otherwise.
         /// </summary>
+        /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
         /// <since_tizen> 6 </since_tizen>
         public StringSelector TranslatableTextSelector
         {
-            get
-            {
-                return translatableTextSelector;
-            }
+            get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
             set
             {
-                translatableTextSelector.Clone(value);
+                if (value == null || buttonText == null)
+                {
+                    throw new NullReferenceException("Button.TranslatableTextSelector is null");
+                }
+                else
+                {
+                    buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
+                }
             }
         }
 
-        private ColorSelector textColorSelector = new ColorSelector();
         /// <summary>
         /// Text color selector in Button.
+        /// Getter returns copied selector value if exist, null otherwise.
         /// </summary>
+        /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
         /// <since_tizen> 6 </since_tizen>
         public ColorSelector TextColorSelector
         {
-            get
-            {
-                return textColorSelector;
-            }
+            get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
             set
             {
-                textColorSelector.Clone(value);
+                if (value == null || buttonText == null)
+                {
+                    throw new NullReferenceException("Button.TextColorSelectorProperty is null");
+                }
+                else
+                {
+                    buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
+                }
             }
         }
 
-        private FloatSelector pointSizeSelector = new FloatSelector();
         /// <summary>
         /// Text font size selector in Button.
+        /// Getter returns copied selector value if exist, null otherwise.
         /// </summary>
+        /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
         /// <since_tizen> 6 </since_tizen>
         public FloatSelector PointSizeSelector
         {
-            get
-            {
-                return pointSizeSelector;
-            }
+            get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
             set
             {
-                pointSizeSelector.Clone(value);
+                if (value == null || buttonText == null)
+                {
+                    throw new NullReferenceException("Button.PointSizeSelector is null");
+                }
+                else
+                {
+                    buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
+                }
             }
         }
 
-        private StringSelector iconURLSelector = new StringSelector();
         /// <summary>
         /// Icon image's resource url selector in Button.
+        /// Getter returns copied selector value if exist, null otherwise.
         /// </summary>
+        /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
         /// <since_tizen> 6 </since_tizen>
         public StringSelector IconURLSelector
         {
-            get
-            {
-                return iconURLSelector;
-            }
+            get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
             set
             {
-                iconURLSelector.Clone(value);
+                if (value == null || buttonIcon == null)
+                {
+                    throw new NullReferenceException("Button.IconURLSelector is null");
+                }
+                else
+                {
+                    buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
+                }
             }
         }
 
@@ -540,21 +614,6 @@ namespace Tizen.NUI.Components
                 SetValue(IsSelectedProperty, value);
             }
         }
-        private bool privateIsSelected
-        {
-            get
-            {
-                return isSelected;
-            }
-            set
-            {
-                isSelected = value;
-
-                UpdateState(SelectionChangedByTouch);
-
-                SelectionChangedByTouch = null;
-            }
-        }
 
         /// <summary>
         /// Flag to decide enable or disable in Button.
@@ -571,51 +630,22 @@ namespace Tizen.NUI.Components
                 SetValue(IsEnabledProperty, value);
             }
         }
-        private bool privateIsEnabled
-        {
-            get
-            {
-                return isEnabled;
-            }
-            set
-            {
-                isEnabled = value;
-                UpdateState();
-            }
-        }
 
         /// <summary>
         /// Icon relative orientation in Button, work only when show icon and text.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 8 </since_tizen>
         public IconOrientation? IconRelativeOrientation
         {
             get
             {
-                return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
+                return (IconOrientation?)GetValue(IconRelativeOrientationProperty) ?? IconOrientation.Left;
             }
             set
             {
                 SetValue(IconRelativeOrientationProperty, value);
             }
         }
-        private IconOrientation? privateIconRelativeOrientation
-        {
-            get
-            {
-                return Style?.IconRelativeOrientation;
-            }
-            set
-            {
-                if(Style != null && Style.IconRelativeOrientation != value)
-                {
-                    Style.IconRelativeOrientation = value;
-                    UpdateUIContent();
-                }
-            }
-        }
 
         /// <summary>
         /// Icon padding in Button, work only when show icon and text.
@@ -623,7 +653,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public Extents IconPadding
         {
-            get => (Extents)GetValue(IconPaddingProperty);
+            get => (Extents)GetValue(IconPaddingProperty) ?? new Extents();
             set => SetValue(IconPaddingProperty, value);
         }
 
@@ -633,42 +663,12 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public Extents TextPadding
         {
-            get => (Extents) GetValue(TextPaddingProperty);
+            get => (Extents)GetValue(TextPaddingProperty) ?? new Extents();
             set => SetValue(TextPaddingProperty, value);
         }
 
-        /// <summary>
-        /// Dispose Button and all children on it.
-        /// </summary>
-        /// <param name="type">Dispose type.</param>
-        /// <since_tizen> 6 </since_tizen>
-        protected override void Dispose(DisposeTypes type)
-        {
-            if (disposed)
-            {
-                return;
-            }
-
-            if (type == DisposeTypes.Explicit)
-            {
-                Extension?.OnDispose(this);
-
-                if (ButtonIcon != null)
-                {
-                    Utility.Dispose(ButtonIcon);
-                }
-                if (ButtonText != null)
-                {
-                    Utility.Dispose(ButtonText);
-                }
-                if (ButtonOverlayImage != null)
-                {
-                    Utility.Dispose(ButtonOverlayImage);
-                }
-            }
+        private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
 
-            base.Dispose(type);
-        }
         /// <summary>
         /// Called after a key event is received by the view that has had its focus set.
         /// </summary>
@@ -677,7 +677,11 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public override bool OnKey(Key key)
         {
-            if (null == key) return false;
+            if (!IsEnabled || null == key)
+            {
+                return false;
+            }
+
             if (key.State == Key.StateType.Down)
             {
                 if (key.KeyPressedName == "Return")
@@ -690,11 +694,11 @@ namespace Tizen.NUI.Components
             {
                 if (key.KeyPressedName == "Return")
                 {
-                    bool clicked = isPressed && isEnabled;
+                    bool clicked = isPressed && IsEnabled;
 
                     isPressed = false;
 
-                    if (Style.IsSelectable != null && Style.IsSelectable == true)
+                    if (IsSelectable)
                     {
                         IsSelected = !IsSelected;
                     }
@@ -705,8 +709,8 @@ namespace Tizen.NUI.Components
 
                     if (clicked)
                     {
-                        ClickEventArgs eventArgs = new ClickEventArgs();
-                        OnClickInternal(eventArgs);
+                        ClickedEventArgs eventArgs = new ClickedEventArgs();
+                        OnClickedInternal(eventArgs);
                     }
                 }
             }
@@ -716,9 +720,7 @@ namespace Tizen.NUI.Components
         /// <summary>
         /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 8 </since_tizen>
         public override void OnFocusGained()
         {
             base.OnFocusGained();
@@ -728,9 +730,7 @@ namespace Tizen.NUI.Components
         /// <summary>
         /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
         /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 8 </since_tizen>
         public override void OnFocusLost()
         {
             base.OnFocusLost();
@@ -743,51 +743,12 @@ namespace Tizen.NUI.Components
         /// </summary>
         /// <param name="touch">The touch event.</param>
         /// <returns>True if the event should be consumed.</returns>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 8 </since_tizen>
+        [Obsolete("Deprecated in API8; Will be removed in API10. Please use OnClicked instead.")]
+#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
         public override bool OnTouch(Touch touch)
+#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
         {
-            if (null == touch) return false;
-            PointStateType state = touch.GetState(0);
-
-            switch(state)
-            {
-                case PointStateType.Down:
-                    isPressed = true;
-                    UpdateState(touch);
-                    return true;
-                case PointStateType.Interrupted:
-                    isPressed = false;
-                    UpdateState();
-                    return true;
-                case PointStateType.Up:
-                {
-                    bool clicked = isPressed && isEnabled;
-
-                    isPressed = false;
-
-                    if (Style.IsSelectable != null && Style.IsSelectable == true)
-                    {
-                        SelectionChangedByTouch = touch;
-                        IsSelected = !IsSelected;
-                    }
-                    else
-                    {
-                        UpdateState(touch);
-                    }
-
-                    if (clicked)
-                    {
-                        ClickEventArgs eventArgs = new ClickEventArgs();
-                        OnClickInternal(eventArgs);
-                    }
-
-                    return true;
-                }
-                default:
-                    break;
-            }
             return base.OnTouch(touch);
         }
 
@@ -798,427 +759,62 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         public override void ApplyStyle(ViewStyle viewStyle)
         {
-            base.ApplyStyle(viewStyle);
+            styleApplied = false;
 
-            ButtonStyle buttonStyle = viewStyle as ButtonStyle;
+            base.ApplyStyle(viewStyle);
 
             if (null != buttonStyle)
             {
-                ButtonOverlayImage?.ApplyStyle(buttonStyle.Overlay);
-                ButtonText?.ApplyStyle(buttonStyle.Text);
-                ButtonIcon?.ApplyStyle(buttonStyle.Icon);
-            }
-        }
-
-        /// <summary>
-        /// Get Button style.
-        /// </summary>
-        /// <returns>The default button style.</returns>
-        /// <since_tizen> 8 </since_tizen>
-        protected override ViewStyle GetViewStyle()
-        {
-            return new ButtonStyle();
-        }
-
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override void OnUpdate()
-        {
-            base.OnUpdate();
-            UpdateUIContent();
-
-            Extension?.OnRelayout(this);
-        }
-
-        /// <summary>
-        /// Update Button State.
-        /// </summary>
-        /// <param name="touchInfo">The touch information in case the state has changed by touching.</param>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected void UpdateState(Touch touchInfo = null)
-        {
-            ControlStates sourceState = ControlState;
-            ControlStates targetState;
-
-            if(isEnabled)
-            {
-                targetState = isPressed ? ControlStates.Pressed : (IsFocused ? (IsSelected ? ControlStates.SelectedFocused : ControlStates.Focused) : (IsSelected ? ControlStates.Selected : ControlStates.Normal));
-            }
-            else
-            {
-                targetState = IsSelected ? ControlStates.DisabledSelected : (IsFocused ? ControlStates.DisabledFocused : ControlStates.Disabled);
-            }
-
-            if (SetControlState(targetState, touchInfo))
-            {
-                OnUpdate();
-
-                StateChangedEventArgs e = new StateChangedEventArgs
+                Extension = buttonStyle.CreateExtension();
+                if (buttonStyle.Overlay != null)
                 {
-                    PreviousState = sourceState,
-                    CurrentState = targetState
-                };
-                stateChangeHander?.Invoke(this, e);
-
-                Extension?.OnControlStateChanged(this, sourceState, touchInfo);
-            }
-        }
-
-        /// <summary>
-        /// It is hijack by using protected, style copy problem when class inherited from Button.
-        /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        private void Initialize()
-        {
-            var style = (ButtonStyle)Style;
-
-            Extension = style.CreateExtension();
-
-            CreateComponents();
-
-            if (ButtonOverlayImage != null)
-            {
-                Add(ButtonOverlayImage);
-                ButtonOverlayImage.ApplyStyle(style.Overlay);
-            }
-
-            if (ButtonIcon != null)
-            {
-                Add(ButtonIcon);
-                ButtonIcon.ApplyStyle(style.Icon);
-                ButtonIcon.Relayout += OnIconRelayout;
-            }
-
-            if (null != ButtonText)
-            {
-                Add(ButtonText);
-                ButtonText.ApplyStyle(style.Text);
-            }
-
-            UpdateState();
-
-            LayoutDirectionChanged += OnLayoutDirectionChanged;
-        }
-
-        private void CreateComponents()
-        {
-            ButtonOverlayImage = CreateOverlayImage();
-            ButtonIcon = CreateIcon();
-            ButtonText = CreateText();
-
-            if (Extension == null)
-            {
-                return;
-            }
+                    OverlayImage?.ApplyStyle(buttonStyle.Overlay);
+                }
 
-            // Update component with extension
-            ButtonOverlayImage = Extension.OnCreateOverlayImage(this, ButtonOverlayImage);
-            ButtonIcon = Extension.OnCreateIcon(this, ButtonIcon);
-            ButtonText = Extension.OnCreateText(this, ButtonText);
-        }
+                if (buttonStyle.Text != null)
+                {
+                    TextLabel?.ApplyStyle(buttonStyle.Text);
+                }
 
-        /// <summary>
-        /// Measure text, it can be override.
-        /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void MeasureText()
-        {
-            if (Style.IconRelativeOrientation == null || ButtonIcon == null || ButtonText == null)
-            {
-                return;
+                if (buttonStyle.Icon != null)
+                {
+                    Icon?.ApplyStyle(buttonStyle.Icon);
+                }
             }
-            ButtonText.WidthResizePolicy = ResizePolicyType.Fixed;
-            ButtonText.HeightResizePolicy = ResizePolicyType.Fixed;
-            int textPaddingStart = Style.TextPadding.Start;
-            int textPaddingEnd = Style.TextPadding.End;
-            int textPaddingTop = Style.TextPadding.Top;
-            int textPaddingBottom = Style.TextPadding.Bottom;
 
-            int iconPaddingStart = Style.IconPadding.Start;
-            int iconPaddingEnd = Style.IconPadding.End;
-            int iconPaddingTop = Style.IconPadding.Top;
-            int iconPaddingBottom = Style.IconPadding.Bottom;
-
-            if (IconRelativeOrientation == IconOrientation.Top || IconRelativeOrientation == IconOrientation.Bottom)
-            {
-                ButtonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd;
-                ButtonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom - iconPaddingTop - iconPaddingBottom - ButtonIcon.SizeHeight;
-            }
-            else
-            {
-                ButtonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd - iconPaddingStart - iconPaddingEnd - ButtonIcon.SizeWidth;
-                ButtonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom;
-            }
-        }
-        /// <summary>
-        /// Layout child, it can be override.
-        /// </summary>
-        /// <since_tizen> 6 </since_tizen>
-        /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected virtual void LayoutChild()
-        {
-            if (Style.IconRelativeOrientation == null || ButtonIcon == null || ButtonText == null)
-            {
-                return;
-            }
-
-            var buttonIcon = ButtonIcon;
-            var buttonText = ButtonText;
-
-            int textPaddingStart = Style.TextPadding.Start;
-            int textPaddingEnd = Style.TextPadding.End;
-            int textPaddingTop = Style.TextPadding.Top;
-            int textPaddingBottom = Style.TextPadding.Bottom;
-
-            int iconPaddingStart = Style.IconPadding.Start;
-            int iconPaddingEnd = Style.IconPadding.End;
-            int iconPaddingTop = Style.IconPadding.Top;
-            int iconPaddingBottom = Style.IconPadding.Bottom;
-
-            switch (IconRelativeOrientation)
-            {
-                case IconOrientation.Top:
-                    buttonIcon.PositionUsesPivotPoint = true;
-                    buttonIcon.ParentOrigin = NUI.ParentOrigin.TopCenter;
-                    buttonIcon.PivotPoint = NUI.PivotPoint.TopCenter;
-                    buttonIcon.Position2D = new Position2D(0, iconPaddingTop);
-
-                    buttonText.PositionUsesPivotPoint = true;
-                    buttonText.ParentOrigin = NUI.ParentOrigin.BottomCenter;
-                    buttonText.PivotPoint = NUI.PivotPoint.BottomCenter;
-                    buttonText.Position2D = new Position2D(0, -textPaddingBottom);
-                    break;
-                case IconOrientation.Bottom:
-                    buttonIcon.PositionUsesPivotPoint = true;
-                    buttonIcon.ParentOrigin = NUI.ParentOrigin.BottomCenter;
-                    buttonIcon.PivotPoint = NUI.PivotPoint.BottomCenter;
-                    buttonIcon.Position2D = new Position2D(0, -iconPaddingBottom);
-
-                    buttonText.PositionUsesPivotPoint = true;
-                    buttonText.ParentOrigin = NUI.ParentOrigin.TopCenter;
-                    buttonText.PivotPoint = NUI.PivotPoint.TopCenter;
-                    buttonText.Position2D = new Position2D(0, textPaddingTop);
-                    break;
-                case IconOrientation.Left:
-                    if (LayoutDirection == ViewLayoutDirectionType.LTR)
-                    {
-                        buttonIcon.PositionUsesPivotPoint = true;
-                        buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft;
-                        buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft;
-                        buttonIcon.Position2D = new Position2D(iconPaddingStart, 0);
-
-                        buttonText.PositionUsesPivotPoint = true;
-                        buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight;
-                        buttonText.PivotPoint = NUI.PivotPoint.CenterRight;
-                        buttonText.Position2D = new Position2D(-textPaddingEnd, 0);
-                    }
-                    else
-                    {
-                        buttonIcon.PositionUsesPivotPoint = true;
-                        buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight;
-                        buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight;
-                        buttonIcon.Position2D = new Position2D(-iconPaddingStart, 0);
-
-                        buttonText.PositionUsesPivotPoint = true;
-                        buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft;
-                        buttonText.PivotPoint = NUI.PivotPoint.CenterLeft;
-                        buttonText.Position2D = new Position2D(textPaddingEnd, 0);
-                    }
-
-                    break;
-                case IconOrientation.Right:
-                    if (LayoutDirection == ViewLayoutDirectionType.RTL)
-                    {
-                        buttonIcon.PositionUsesPivotPoint = true;
-                        buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterLeft;
-                        buttonIcon.PivotPoint = NUI.PivotPoint.CenterLeft;
-                        buttonIcon.Position2D = new Position2D(iconPaddingEnd, 0);
-
-                        buttonText.PositionUsesPivotPoint = true;
-                        buttonText.ParentOrigin = NUI.ParentOrigin.CenterRight;
-                        buttonText.PivotPoint = NUI.PivotPoint.CenterRight;
-                        buttonText.Position2D = new Position2D(-textPaddingStart, 0);
-                    }
-                    else
-                    {
-                        buttonIcon.PositionUsesPivotPoint = true;
-                        buttonIcon.ParentOrigin = NUI.ParentOrigin.CenterRight;
-                        buttonIcon.PivotPoint = NUI.PivotPoint.CenterRight;
-                        buttonIcon.Position2D = new Position2D(-iconPaddingEnd, 0);
-
-                        buttonText.PositionUsesPivotPoint = true;
-                        buttonText.ParentOrigin = NUI.ParentOrigin.CenterLeft;
-                        buttonText.PivotPoint = NUI.PivotPoint.CenterLeft;
-                        buttonText.Position2D = new Position2D(textPaddingStart, 0);
-                    }
-                    break;
-                default:
-                    break;
-            }
-            if (string.IsNullOrEmpty(buttonText.Text))
-            {
-                buttonIcon.ParentOrigin = NUI.ParentOrigin.Center;
-                buttonIcon.PivotPoint = NUI.PivotPoint.Center;
-            }
-        }
-        /// <summary>
-        /// Theme change callback when theme is changed, this callback will be trigger.
-        /// </summary>
-        /// <param name="sender">The sender</param>
-        /// <param name="e">The event data</param>
-        /// <since_tizen> 8 </since_tizen>
-        protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
-        {
-            ButtonStyle buttonStyle = StyleManager.Instance.GetViewStyle(style) as ButtonStyle;
-            if (buttonStyle != null)
-            {
-                Style.CopyFrom(buttonStyle);
-                UpdateUIContent();
-            }
-        }
-
-        private void UpdateUIContent()
-        {
-            MeasureText();
-            LayoutChild();
-
-            Sensitive = isEnabled;
-        }
-
-        private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e)
-        {
-            MeasureText();
-            LayoutChild();
-        }
-
-        private void OnClickInternal(ClickEventArgs eventArgs)
-        {
-            OnClick(eventArgs);
-            Extension?.OnClick(this, eventArgs);
-            ClickEvent?.Invoke(this, eventArgs);
-        }
-
-        private void OnIconRelayout(object sender, EventArgs e)
-        {
-            MeasureText();
-            LayoutChild();
+            styleApplied = true;
         }
 
         /// <summary>
         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
+        [Obsolete("Deprecated in API8; Will be removed in API10. Please use ClickedEventArgs instead.")]
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
         public class ClickEventArgs : EventArgs
         {
         }
+
         /// <summary>
         /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
+        [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEventArgs")]
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
         public class StateChangedEventArgs : EventArgs
         {
             /// <summary> previous state of Button </summary>
             /// <since_tizen> 6 </since_tizen>
+            /// It will be removed in API10
+            [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
+            [Obsolete("Deprecated in API8; Will be removed in API10")]
             public ControlStates PreviousState;
             /// <summary> current state of Button </summary>
             /// <since_tizen> 6 </since_tizen>
+            /// It will be removed in API10
+            [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
+            [Obsolete("Deprecated in API8; Will be removed in API10")]
             public ControlStates CurrentState;
         }
-
-        /// <summary>
-        /// A Selector class that describes Buttons state by actions.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public class ActionSelector<T>
-        {
-            /// <summary>
-            /// Value used when the Button is created.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnCreate { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is selected.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnSelect { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is unselected.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnUnselect { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is disabled.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnDisable { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is disabled in selected state.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnDisableSelected { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is pressed.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnPress { get; set; }
-
-            /// <summary>
-            /// Value used when the Button is pressed in selected state.
-            /// </summary>
-            [EditorBrowsable(EditorBrowsableState.Never)]
-            public T OnPressSelected { get; set; }
-        }
-
-        /// <summary>
-        /// Get current text part to the attached ButtonExtension.
-        /// </summary>
-        /// <remarks>
-        /// It returns null if the passed extension is invaild.
-        /// </remarks>
-        /// <param name="extension">The extension instance that is currently attached to this Button.</param>
-        /// <return>The button's text part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public TextLabel GetCurrentText(ButtonExtension extension)
-        {
-            return (extension == Extension) ? ButtonText : null;
-        }
-
-        /// <summary>
-        /// Get current icon part to the attached ButtonExtension.
-        /// </summary>
-        /// <remarks>
-        /// It returns null if the passed extension is invaild.
-        /// </remarks>
-        /// <param name="extension">The extension instance that is currently attached to this Button.</param>
-        /// <return>The button's icon part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public ImageView GetCurrentIcon(ButtonExtension extension)
-        {
-            return (extension == Extension) ? ButtonIcon : null;
-        }
-
-        /// <summary>
-        /// Get current overlay image part to the attached ButtonExtension.
-        /// </summary>
-        /// <remarks>
-        /// It returns null if the passed extension is invaild.
-        /// </remarks>
-        /// <param name="extension">The extension instance that is currently attached to this Button.</param>
-        /// <return>The button's overlay image part.</return>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public ImageView GetCurrentOverlayImage(ButtonExtension extension)
-        {
-            return (extension == Extension) ? ButtonOverlayImage : null;
-        }
     }
 }