[NUI][AT-SPI] text: add "GetRangeExtents" interface
authorShinwoo Kim <cinoo.kim@samsung.com>
Wed, 2 Mar 2022 14:10:50 +0000 (23:10 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 10 Mar 2022 08:03:31 +0000 (17:03 +0900)
This interface will be used for getting MBR(Minimum Bounding Rectangle)
with following usage on the AT client side.

  cc = atspi_text_get_character_count(text, NULL);
  rect = atspi_text_get_range_extents(text, 0, cc, ATSPI_COORD_TYPE_WINDOW, NULL);

src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs
src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs
src/Tizen.NUI/src/public/BaseComponents/ViewAccessibilityEnum.cs
src/Tizen.NUI/src/public/BaseComponents/ViewAccessibilityWrappers.cs

index 29499c5..d143e48 100755 (executable)
@@ -389,6 +389,11 @@ namespace Tizen.NUI
                 public delegate uint AccessibilityGetInterfaces(IntPtr self);
                 [EditorBrowsable(EditorBrowsableState.Never)]
                 public AccessibilityGetInterfaces GetInterfaces; // 36
+
+                [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+                public delegate IntPtr AccessibilityGetRangeExtents(IntPtr self, int startOffset, int endOffset, int coordType);
+                [EditorBrowsable(EditorBrowsableState.Never)]
+                public AccessibilityGetRangeExtents GetRangeExtents; // 37
             }
 
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Toolkit_DevelControl_SetAccessibilityConstructor_NUI")]
index 876c8e0..defaeb8 100755 (executable)
@@ -658,6 +658,12 @@ namespace Tizen.NUI.BaseComponents
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual Rectangle AccessibilityGetRangeExtents(int startOffset, int endOffset, AccessibilityCoordinateType coordType)
+        {
+            return new Rectangle(0, 0, 0, 0);
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
         protected virtual bool AccessibilityCopyText(int startPosition, int endPosition)
         {
             return false;
index 31a19e6..cec25b6 100755 (executable)
@@ -1456,4 +1456,23 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         Paragraph,
     }
+
+    /// <summary>
+    /// Accessibility coordinate type describing if coordinates are relative to screen or window
+    /// </summary>
+    /// <seealso cref="View.AccessibilityGetRangeExtents" />
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum AccessibilityCoordinateType
+    {
+        /// <summary>
+        /// Specifies xy coordinates relative to the screen.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        Screen,
+        /// <summary>
+        /// Specifies xy coordinates relative to the component's top-level window.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        Window,
+    }
 }
index 6dfe09c..a298f58 100644 (file)
@@ -61,6 +61,11 @@ namespace Tizen.NUI.BaseComponents
             return Interop.ControlDevel.DaliAccessibilityNewRange(range.StartOffset, range.EndOffset, range.Content);
         }
 
+        private static IntPtr DuplicateAccessibilityRectangle(Rectangle rect)
+        {
+            return Interop.Rectangle.NewRectangle(rect.X, rect.Y, rect.Width, rect.Height);
+        }
+
         //
         // Accessible interface
         //
@@ -283,6 +288,7 @@ namespace Tizen.NUI.BaseComponents
 
             ad.GetCharacterCount = AccessibilityGetCharacterCountWrapper;
             ad.GetCursorOffset   = AccessibilityGetCursorOffsetWrapper;
+            ad.GetRangeExtents   = AccessibilityGetRangeExtentsWrapper;
             ad.GetSelection      = AccessibilityGetSelectionWrapper;
             ad.GetText           = AccessibilityGetTextWrapper;
             ad.GetTextAtOffset   = AccessibilityGetTextAtOffsetWrapper;
@@ -301,6 +307,13 @@ namespace Tizen.NUI.BaseComponents
             return GetViewFromRefObject(self).AccessibilityGetCursorOffset();
         }
 
+        private static IntPtr AccessibilityGetRangeExtentsWrapper(IntPtr self, int startOffset, int endOffset, int coordType)
+        {
+            using Rectangle rect = GetViewFromRefObject(self).AccessibilityGetRangeExtents(startOffset, endOffset, (AccessibilityCoordinateType)coordType);
+
+            return DuplicateAccessibilityRectangle(rect);
+        }
+
         private static IntPtr AccessibilityGetSelectionWrapper(IntPtr self, int selectionNumber)
         {
             AccessibilityRange range = GetViewFromRefObject(self).AccessibilityGetSelection(selectionNumber);