[NUI][AT-SPI] Default accessibility support for Tizen.NUI.Components.Progress (#2852)
authorm-bialota <74924447+m-bialota@users.noreply.github.com>
Wed, 28 Apr 2021 01:58:11 +0000 (03:58 +0200)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 21 May 2021 07:37:43 +0000 (16:37 +0900)
[NUI][AT-SPI] Basic accessibility support for Tizen.NUI.Components.Progress

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

index d67b524..0b6bb78 100755 (executable)
@@ -152,6 +152,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public Progress() : base()
         {
+            Initialize();
         }
 
         /// <summary>
@@ -161,6 +162,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         public Progress(string style) : base(style)
         {
+            Initialize();
         }
 
         /// <summary>
@@ -170,6 +172,49 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         public Progress(ProgressStyle progressStyle) : base(progressStyle)
         {
+            Initialize();
+        }
+
+        /// <summary>
+        /// Prevents from showing child widgets in AT-SPI tree.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override bool AccessibilityShouldReportZeroChildren()
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// Minimum value.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override double AccessibilityGetMinimum()
+        {
+            if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
+                return (double)MinValue;
+            else return 0.0;
+        }
+
+        /// <summary>
+        /// Current value.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override double AccessibilityGetCurrent()
+        {
+            if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
+                return (double)CurrentValue;
+            else return 0.0;
+        }
+
+        /// <summary>
+        /// Maximum value.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override double AccessibilityGetMaximum()
+        {
+            if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
+                return (double)MaxValue;
+            else return 0.0;
         }
 
         /// <summary>
@@ -342,6 +387,10 @@ namespace Tizen.NUI.Components
             set
             {
                 SetValue(CurrentValueProperty, value);
+                if (IsHighlighted)
+                {
+                    EmitAccessibilityEvent(ObjectPropertyChangeEvent.Value);
+                }
             }
         }
 
@@ -382,6 +431,7 @@ namespace Tizen.NUI.Components
         public override void OnInitialize()
         {
             base.OnInitialize();
+            SetAccessibilityConstructor(Role.ProgressBar, AccessibilityInterface.Value);
             // create necessary components
             InitializeTrack();
             InitializeBuffer();
@@ -563,6 +613,11 @@ namespace Tizen.NUI.Components
             }
         }
 
+        private void Initialize()
+        {
+            AccessibilityHighlightable = true;
+        }
+
         private void InitializeTrack()
         {
             if (null == trackImage)