From: Shinwoo Kim Date: Tue, 12 Apr 2022 08:40:47 +0000 (+0900) Subject: [NUI][AT-SPI] Window: add highlight signal X-Git-Tag: accepted/tizen/unified/20231205.024657~995 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77713c556129ab0d1eb6115f32a535c720cbde9b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI][AT-SPI] Window: add highlight signal The Window will highlight itself on NUI side. The GrabHighlight emits the Highlight signal. --- diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowAccessibilityHighlightSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowAccessibilityHighlightSignal.cs new file mode 100644 index 0000000..7ef5cb2 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.WindowAccessibilityHighlightSignal.cs @@ -0,0 +1,46 @@ +/* + * Copyright(c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; + +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class WindowAccessibilityHighlightSignal + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal")] + public static extern global::System.IntPtr GetSignal(global::System.Runtime.InteropServices.HandleRef window); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal_Empty")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool Empty(global::System.Runtime.InteropServices.HandleRef signalType); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal_GetConnectionCount")] + public static extern uint GetConnectionCount(global::System.Runtime.InteropServices.HandleRef signalType); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal_Connect")] + public static extern void Connect(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef callback); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal_Disconnect")] + public static extern void Disconnect(global::System.Runtime.InteropServices.HandleRef signalType, global::System.Runtime.InteropServices.HandleRef callback); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Accessibility_Highlight_Signal_delete")] + public static extern void DeleteSignal(global::System.Runtime.InteropServices.HandleRef signalType); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Window/WindowAccessibilityHighlightEvent.cs b/src/Tizen.NUI/src/internal/Window/WindowAccessibilityHighlightEvent.cs new file mode 100644 index 0000000..277d672 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Window/WindowAccessibilityHighlightEvent.cs @@ -0,0 +1,70 @@ +/* + * Copyright(c) 2022 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Tizen.NUI +{ + internal class WindowAccessibilityHighlightEvent : Disposable + { + internal WindowAccessibilityHighlightEvent(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + public WindowAccessibilityHighlightEvent(Window window) : this(Interop.WindowAccessibilityHighlightSignal.GetSignal(Window.getCPtr(window)), false) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.WindowAccessibilityHighlightSignal.DeleteSignal(swigCPtr); + } + + public bool Empty() + { + bool ret = Interop.WindowAccessibilityHighlightSignal.Empty(SwigCPtr); + + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetConnectionCount() + { + uint ret = Interop.WindowAccessibilityHighlightSignal.GetConnectionCount(SwigCPtr); + + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + Interop.WindowAccessibilityHighlightSignal.Connect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Disconnect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + Interop.WindowAccessibilityHighlightSignal.Disconnect(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + } +} diff --git a/src/Tizen.NUI/src/public/Window/WindowEvent.cs b/src/Tizen.NUI/src/public/Window/WindowEvent.cs index d2219b9..7e4d778 100755 --- a/src/Tizen.NUI/src/public/Window/WindowEvent.cs +++ b/src/Tizen.NUI/src/public/Window/WindowEvent.cs @@ -1295,6 +1295,79 @@ namespace Tizen.NUI } } + /// + /// AccessibilityHighlightArgs + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AccessibilityHighlightEventArgs : EventArgs + { + private bool accessibilityHighlight; + /// + /// accessibilityHighlight + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool AccessibilityHighlight + { + get => accessibilityHighlight; + set + { + accessibilityHighlight = value; + } + } + } + + private void OnAccessibilityHighlight(IntPtr window, bool highlight) + { + if (window == global::System.IntPtr.Zero) + { + NUILog.Error("[ERR] OnAccessibilityHighlight() window is null"); + return; + } + + AccessibilityHighlightEventArgs e = new AccessibilityHighlightEventArgs(); + e.AccessibilityHighlight = highlight; + if (AccessibilityHighlightEventHandler != null) + { + AccessibilityHighlightEventHandler.Invoke(this, e); + } + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void AccessibilityHighlightEventCallbackType(IntPtr window, bool highlight); + private AccessibilityHighlightEventCallbackType AccessibilityHighlightEventCallback; + private event EventHandler AccessibilityHighlightEventHandler; + private WindowAccessibilityHighlightEvent AccessibilityHighlightEventSignal; + /// + /// Emits the event when the window needs to grab or clear highlight. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler AccessibilityHighlight + { + add + { + if (AccessibilityHighlightEventHandler == null) + { + AccessibilityHighlightEventCallback = OnAccessibilityHighlight; + AccessibilityHighlightEventSignal = new WindowAccessibilityHighlightEvent(this); + AccessibilityHighlightEventSignal.Connect(AccessibilityHighlightEventCallback); + } + AccessibilityHighlightEventHandler += value; + } + remove + { + AccessibilityHighlightEventHandler -= value; + if (AccessibilityHighlightEventHandler == null) + { + if (AccessibilityHighlightEventSignal != null) + { + if (AccessibilityHighlightEventSignal.Empty() == false) + { + AccessibilityHighlightEventSignal.Disconnect(AccessibilityHighlightEventCallback); + } + } + } + } + } } } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AtspiSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AtspiSample.cs index 4240a28..5bfcf1a 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AtspiSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AtspiSample.cs @@ -42,6 +42,13 @@ namespace Tizen.NUI.Samples Tizen.Log.Error("NUITEST", "Cannot set to false\n"); return; } + + window.AccessibilityHighlight += OnWindowAccessibilityHighlight; + } + + private void OnWindowAccessibilityHighlight(object sender, Window.AccessibilityHighlightEventArgs e) + { + Tizen.Log.Info("NUITEST", "Accessibility Highlight: " + e.AccessibilityHighlight + "\n"); } public void Deactivate()