[NUI][AT-SPI] Rename Accessibility.Enabled to .IsEnabled
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
index df811f3..6a8035f 100755 (executable)
@@ -83,7 +83,7 @@ namespace Tizen.NUI.Components
         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) =>
+        public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Button)bindable;
             if (newValue != null)
@@ -98,9 +98,9 @@ namespace Tizen.NUI.Components
                         instance.UpdateState();
                     }
 
-                    if (instance.IsHighlighted)
+                    if (Accessibility.Accessibility.IsEnabled && instance.IsHighlighted)
                     {
-                        instance.EmitAccessibilityStateChangedEvent(AccessibilityState.Checked, newSelected);
+                        instance.EmitAccessibilityStatesChangedEvent(AccessibilityStates.Checked, newSelected);
                     }
                 }
             }
@@ -158,8 +158,13 @@ namespace Tizen.NUI.Components
         internal static readonly BindableProperty ItemAlignmentProperty = BindableProperty.Create(nameof(ItemAlignment), typeof(LinearLayout.Alignment), typeof(Button), LinearLayout.Alignment.Center, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var instance = (Button)bindable;
-            instance.itemAlignment = (LinearLayout.Alignment)newValue;
-            instance.LayoutItems();
+            var newAlignment = (LinearLayout.Alignment)newValue;
+
+            if (instance.itemAlignment != newAlignment)
+            {
+                instance.itemAlignment = newAlignment;
+                instance.LayoutItems();
+            }
         },
         defaultValueCreator: (bindable) => ((Button)bindable).itemAlignment);
 
@@ -178,7 +183,7 @@ namespace Tizen.NUI.Components
         private bool isSelectable = false;
         private bool isEnabled = true;
         private Size2D itemSpacing;
-        private LinearLayout.Alignment itemAlignment;
+        private LinearLayout.Alignment itemAlignment = LinearLayout.Alignment.Center;
 
         static Button() { }
 
@@ -212,12 +217,12 @@ namespace Tizen.NUI.Components
         /// Calculates current states for the button<br />
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override AccessibilityStates AccessibilityCalculateStates()
+        protected override AccessibilityStates AccessibilityCalculateStates(ulong states)
         {
-            var states = base.AccessibilityCalculateStates();
-            states.Set(AccessibilityState.Checked, this.IsSelected);
-            states.Set(AccessibilityState.Enabled, this.IsEnabled);
-            return states;
+            var accessibilityStates = base.AccessibilityCalculateStates(states);
+            FlagSetter(ref accessibilityStates, AccessibilityStates.Checked, this.IsSelected);
+            FlagSetter(ref accessibilityStates, AccessibilityStates.Enabled, this.IsEnabled);
+            return accessibilityStates;
         }
 
         /// <summary>
@@ -335,7 +340,7 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
-        /// Return currently applied style.
+        /// The last applied style object copy.
         /// </summary>
         /// <remarks>
         /// Modifying contents in style may cause unexpected behaviour.
@@ -351,15 +356,27 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return GetValue(TextProperty) as string;
+            }
+            set
+            {
+                SetValue(TextProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private string InternalText
+        {
+            get
+            {
                 return TextLabel.Text;
             }
             set
             {
                 TextLabel.Text = value;
 
-                if (IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
+                if (Accessibility.Accessibility.IsEnabled && IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
                 {
-                    EmitAccessibilityEvent(ObjectPropertyChangeEvent.Name);
+                    EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Name);
                 }
             }
         }
@@ -388,6 +405,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return GetValue(TranslatableTextProperty) as string;
+            }
+            set
+            {
+                SetValue(TranslatableTextProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private string InternalTranslatableText
+        {
+            get
+            {
                 return TextLabel.TranslatableText;
             }
             set
@@ -404,6 +433,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return (float)GetValue(PointSizeProperty);
+            }
+            set
+            {
+                SetValue(PointSizeProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private float InternalPointSize
+        {
+            get
+            {
                 return TextLabel.PointSize;
             }
             set
@@ -420,6 +461,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return GetValue(FontFamilyProperty) as string;
+            }
+            set
+            {
+                SetValue(FontFamilyProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private string InternalFontFamily
+        {
+            get
+            {
                 return TextLabel.FontFamily;
             }
             set
@@ -436,6 +489,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return GetValue(TextColorProperty) as Color;
+            }
+            set
+            {
+                SetValue(TextColorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private Color InternalTextColor
+        {
+            get
+            {
                 return TextLabel.TextColor;
             }
             set
@@ -452,6 +517,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return (HorizontalAlignment)GetValue(TextAlignmentProperty);
+            }
+            set
+            {
+                SetValue(TextAlignmentProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private HorizontalAlignment InternalTextAlignment
+        {
+            get
+            {
                 return TextLabel.HorizontalAlignment;
             }
             set
@@ -468,6 +545,18 @@ namespace Tizen.NUI.Components
         {
             get
             {
+                return GetValue(IconURLProperty) as string;
+            }
+            set
+            {
+                SetValue(IconURLProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private string InternalIconURL
+        {
+            get
+            {
                 return Icon.ResourceUrl;
             }
             set
@@ -477,6 +566,28 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
+        /// Icon image's size in Button.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Size IconSize
+        {
+            get
+            {
+                return GetValue(IconSizeProperty) as Size;
+            }
+            set
+            {
+                SetValue(IconSizeProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private Size InternalIconSize
+        {
+            get => Icon.Size;
+            set => Icon.Size = value;
+        }
+
+        /// <summary>
         /// Text string selector in Button.
         /// Getter returns copied selector value if exist, null otherwise.
         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
@@ -484,7 +595,19 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public StringSelector TextSelector
         {
-            get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
+            get
+            {
+                return GetValue(TextSelectorProperty) as StringSelector;
+            }
+            set
+            {
+                SetValue(TextSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private StringSelector InternalTextSelector
+        {
+            get => buttonText?.TextSelector == null ? null : new StringSelector(buttonText.TextSelector);
             set
             {
                 if (value == null || buttonText == null)
@@ -493,7 +616,7 @@ namespace Tizen.NUI.Components
                 }
                 else
                 {
-                    buttonText.SetValue(TextLabel.TextSelectorProperty, value);
+                    buttonText.TextSelector = value;
                 }
             }
         }
@@ -506,7 +629,19 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public StringSelector TranslatableTextSelector
         {
-            get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
+            get
+            {
+                return GetValue(TranslatableTextSelectorProperty) as StringSelector;
+            }
+            set
+            {
+                SetValue(TranslatableTextSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private StringSelector InternalTranslatableTextSelector
+        {
+            get => (buttonText?.TranslatableTextSelector == null) ? null : new StringSelector(buttonText.TranslatableTextSelector);
             set
             {
                 if (value == null || buttonText == null)
@@ -515,7 +650,7 @@ namespace Tizen.NUI.Components
                 }
                 else
                 {
-                    buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
+                    buttonText.TranslatableTextSelector = value;
                 }
             }
         }
@@ -528,7 +663,19 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public ColorSelector TextColorSelector
         {
-            get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
+            get
+            {
+                return GetValue(TextColorSelectorProperty) as ColorSelector;
+            }
+            set
+            {
+                SetValue(TextColorSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private ColorSelector InternalTextColorSelector
+        {
+            get => buttonText?.TextColorSelector == null ? null : new ColorSelector(buttonText.TextColorSelector);
             set
             {
                 if (value == null || buttonText == null)
@@ -537,7 +684,7 @@ namespace Tizen.NUI.Components
                 }
                 else
                 {
-                    buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
+                    buttonText.TextColorSelector = value;
                 }
             }
         }
@@ -550,7 +697,19 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public FloatSelector PointSizeSelector
         {
-            get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
+            get
+            {
+                return GetValue(PointSizeSelectorProperty) as FloatSelector;
+            }
+            set
+            {
+                SetValue(PointSizeSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private FloatSelector InternalPointSizeSelector
+        {
+            get => buttonText?.PointSizeSelector == null ? null : new FloatSelector(buttonText.PointSizeSelector);
             set
             {
                 if (value == null || buttonText == null)
@@ -559,7 +718,7 @@ namespace Tizen.NUI.Components
                 }
                 else
                 {
-                    buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
+                    buttonText.PointSizeSelector = value;
                 }
             }
         }
@@ -572,7 +731,19 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public StringSelector IconURLSelector
         {
-            get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
+            get
+            {
+                return GetValue(IconURLSelectorProperty) as StringSelector;
+            }
+            set
+            {
+                SetValue(IconURLSelectorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+        private StringSelector InternalIconURLSelector
+        {
+            get => buttonIcon?.ResourceUrlSelector == null ? null : new StringSelector(buttonIcon.ResourceUrlSelector);
             set
             {
                 if (value == null || buttonIcon == null)
@@ -581,7 +752,7 @@ namespace Tizen.NUI.Components
                 }
                 else
                 {
-                    buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
+                    buttonIcon.ResourceUrlSelector = value;
                 }
             }
         }
@@ -657,7 +828,7 @@ namespace Tizen.NUI.Components
         /// <summary>
         /// The item (text or icon or both) alignment.
         /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 9 </since_tizen>
         public LinearLayout.Alignment ItemAlignment
         {
             get => (LinearLayout.Alignment)GetValue(ItemAlignmentProperty);
@@ -669,7 +840,7 @@ namespace Tizen.NUI.Components
         /// The value is applied when there exist icon and text both.
         /// The width value is used when the items are arranged horizontally. Otherwise, the height value is used.
         /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 9 </since_tizen>
         public Size2D ItemSpacing
         {
             get => (Size2D)GetValue(ItemSpacingProperty);
@@ -777,7 +948,7 @@ namespace Tizen.NUI.Components
                 Extension = buttonStyle.CreateExtension();
 
                 if (buttonStyle.Overlay != null)
-                {   
+                {
                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
                 }
 
@@ -794,6 +965,7 @@ namespace Tizen.NUI.Components
 
                 if (buttonStyle.Text != null)
                 {
+                    buttonText.ThemeChangeSensitive = false;
                     buttonText.ApplyStyle(buttonStyle.Text);
                 }