From 59f51d34e52da39c203b35757143625c07b3945a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bart=C5=82omiej=20Grzelewski?= Date: Fri, 2 Apr 2021 03:42:00 +0200 Subject: [PATCH] [NUI][AT-SPI] Highlight bindings (#2752) Highlight bindings for accessibility. Co-authored-by: Seoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com> --- .../src/internal/Interop/Interop.ControlDevel.cs | 12 +++++ .../src/public/Accessibility/Accessibility.cs | 52 ++++++++++++++++++++++ src/Tizen.NUI/src/public/BaseComponents/View.cs | 5 ++- .../src/public/BaseComponents/ViewAccessibility.cs | 9 ++++ 4 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs index 3b1db59..62cf13e 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs @@ -203,6 +203,18 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_Bridge_Remove_Popup")] public static extern void DaliAccessibilityBridgeRemovePopup(global::System.Runtime.InteropServices.HandleRef arg1); + [EditorBrowsable(EditorBrowsableState.Never)] + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_Accessible_GetCurrentlyHighlightedActor")] + public static extern global::System.IntPtr DaliAccessibilityAccessibleGetCurrentlyHighlightedActor(); + + [EditorBrowsable(EditorBrowsableState.Never)] + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_Accessible_GetHighlightActor")] + public static extern global::System.IntPtr DaliAccessibilityAccessibleGetHighlightActor(); + + [EditorBrowsable(EditorBrowsableState.Never)] + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_Accessible_SetHighlightActor")] + public static extern void DaliAccessibilityAccessibleSetHighlightActor(global::System.Runtime.InteropServices.HandleRef arg1); + // SetAccessibilityConstructor // Keep this structure layout binary compatible with the respective C++ structure! diff --git a/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs b/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs index 5c0392e..fa82f9d 100755 --- a/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs +++ b/src/Tizen.NUI/src/public/Accessibility/Accessibility.cs @@ -108,6 +108,58 @@ namespace Tizen.NUI.Accessibility Interop.Accessibility.PauseResume(View.getCPtr(dummy), pause); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + + /// + /// Get View that is used to highlight widget. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public View GetHighlightFrameView() + { + var ptr = Interop.ControlDevel.DaliAccessibilityAccessibleGetHighlightActor(); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + if (ptr == IntPtr.Zero) + return null; + return new View(ptr, true); + } + + /// + /// Set view that will be used to highlight widget. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetHighlightFrameView(View view) + { + Interop.ControlDevel.DaliAccessibilityAccessibleSetHighlightActor(View.getCPtr(view)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Get highligted View. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public View GetCurrentlyHighlightedView() + { + var ptr = Interop.ControlDevel.DaliAccessibilityAccessibleGetCurrentlyHighlightedActor(); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + if (ptr == IntPtr.Zero) + return null; + return new View(ptr, true); + } + + /// + /// Clear highlight. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public bool ClearCurrentlyHighlightedView() + { + using (View view = GetCurrentlyHighlightedView()) + { + return view.ClearAccessibilityHighlight(); + } + } #endregion Method diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 5885b5d..d761c21 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -497,7 +497,10 @@ namespace Tizen.NUI.BaseComponents { get { - return Accessibility.AccessibilityManager.Instance.GetCurrentFocusView() == this; + using (View view = Accessibility.Accessibility.Instance.GetCurrentlyHighlightedView()) + { + return view == this; + } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs index e9d2d59..e0c2440 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs @@ -241,9 +241,18 @@ namespace Tizen.NUI.BaseComponents // ****************** Accessibility Relations ******************* // /////////////////////////////////////////////////////////////////// + /// + /// Creates relation between objects. + /// + /// Object which will be in relation. + /// Relation type. + /// You must pass valid object. NULL could not be in relation. [EditorBrowsable(EditorBrowsableState.Never)] public void AppendAccessibilityRelation(View second, RelationType relation) { + if (second is null) + throw new ArgumentNullException(nameof(second)); + Interop.ControlDevel.DaliToolkitDevelControlAppendAccessibilityRelation(SwigCPtr, second.SwigCPtr, (int)relation); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); -- 2.7.4