[NUI][AT-SPI] Add Accessibility.Enabled and .Disabled signals
authorArtur Świgoń <a.swigon@samsung.com>
Wed, 10 Nov 2021 11:07:30 +0000 (12:07 +0100)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Wed, 12 Jan 2022 08:40:18 +0000 (17:40 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs
src/Tizen.NUI/src/public/Accessibility/Accessibility.cs

index 93a837a6aca4e451e6436709f2b6565bbd0c8acb..9311088614a49f7cbbe8899a2b4f5f46e3975c82 100755 (executable)
@@ -51,6 +51,12 @@ namespace Tizen.NUI
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_IsEnabled")]
             [return: MarshalAs(UnmanagedType.U1)]
             public static extern bool IsEnabled();
+
+            [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+            public delegate void EnabledDisabledSignalHandler();
+
+            [DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_RegisterEnabledDisabledSignalHandler")]
+            public static extern void RegisterEnabledDisabledSignalHandler(EnabledDisabledSignalHandler enabledSignalHandler, EnabledDisabledSignalHandler disabledSignalHandler);
         }
     }
 }
index 32db1406561542b52f4368dadfd10eaaf915e9e1..0cf3a20e4908a93680cfaa07ec641dd0211be502 100755 (executable)
@@ -38,11 +38,29 @@ namespace Tizen.NUI.Accessibility
             dummy = new View();
             dummy.Name = "dali-atspi-singleton";
         }
+
+        static Accessibility()
+        {
+            enabledSignalHandler = () =>
+            {
+                Enabled?.Invoke(typeof(Accessibility), EventArgs.Empty);
+            };
+
+            disabledSignalHandler = () =>
+            {
+                Disabled?.Invoke(typeof(Accessibility), EventArgs.Empty);
+            };
+
+            Interop.Accessibility.RegisterEnabledDisabledSignalHandler(enabledSignalHandler, disabledSignalHandler);
+        }
+
         /// <summary>
         /// destructor. This is HiddenAPI. recommended not to use in public.
         /// </summary>
         ~Accessibility()
         {
+            Interop.Accessibility.RegisterEnabledDisabledSignalHandler(null, null);
+
             Tizen.Log.Debug("NUI", $"Accessibility is destroyed\n");
         }
         #endregion Constructor, Destructor, Dispose
@@ -285,6 +303,21 @@ namespace Tizen.NUI.Accessibility
             add => sayFinishedEventHandler += value;
             remove => sayFinishedEventHandler -= value;
         }
+
+        /// <summary>
+        /// Triggered whenever the value of IsEnabled would change from false to true
+        /// </summary>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static event EventHandler Enabled;
+
+        /// <summary>
+        /// Triggered whenever the value of IsEnabled would change from true to false
+        /// </summary>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static event EventHandler Disabled;
+
         #endregion Event, Enum, Struct, ETC
 
 
@@ -320,6 +353,10 @@ namespace Tizen.NUI.Accessibility
 
         private SayFinishedEventCallbackType callback = null;
 
+        private static Interop.Accessibility.EnabledDisabledSignalHandler enabledSignalHandler = null;
+
+        private static Interop.Accessibility.EnabledDisabledSignalHandler disabledSignalHandler = null;
+
         private void SayFinishedEventCallback(int result)
         {
             NUILog.Debug($"sayFinishedEventCallback(res={result}) called!");