[AT-SPI] Window: add highlight signal 83/273683/5
authorShinwoo Kim <cinoo.kim@samsung.com>
Tue, 12 Apr 2022 08:23:31 +0000 (17:23 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 14 Apr 2022 11:59:57 +0000 (20:59 +0900)
The Window will highlight itself on NUI side.
The GrabHighlight emits the Highlight signal.

Change-Id: I2296685688056359afe5ce807d0b61deb280c091

dali/devel-api/adaptor-framework/accessibility.cpp
dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index dc9484a..ddc4f20 100644 (file)
@@ -355,12 +355,69 @@ public:
 
   bool GrabHighlight() override
   {
-    return false;
+    if(!IsUp())
+    {
+      return false;
+    }
+
+    // Only window accessible is able to grab and clear highlight
+    if(!mRoot)
+    {
+      return false;
+    }
+
+    auto self = Self();
+    auto oldHighlightedActor = GetCurrentlyHighlightedActor();
+    if(self == oldHighlightedActor)
+    {
+      return true;
+    }
+
+    // Clear the old highlight.
+    if(oldHighlightedActor)
+    {
+      auto oldHighlightedObject = Dali::Accessibility::Component::DownCast(Accessible::Get(oldHighlightedActor));
+      if(oldHighlightedObject)
+      {
+        oldHighlightedObject->ClearHighlight();
+      }
+    }
+
+    SetCurrentlyHighlightedActor(self);
+
+    auto window                                 = Dali::DevelWindow::Get(self);
+    Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+    windowImpl.EmitAccessibilityHighlightSignal(true);
+
+    return true;
   }
 
   bool ClearHighlight() override
   {
-    return false;
+    if(!IsUp())
+    {
+      return false;
+    }
+
+    // Only window accessible is able to grab and clear highlight
+    if(!mRoot)
+    {
+      return false;
+    }
+
+    auto self = Self();
+    if(self != GetCurrentlyHighlightedActor())
+    {
+      return false;
+    }
+
+    SetCurrentlyHighlightedActor({});
+
+    auto window                                 = Dali::DevelWindow::Get(self);
+    Dali::Internal::Adaptor::Window& windowImpl = Dali::GetImplementation(window);
+    windowImpl.EmitAccessibilityHighlightSignal(false);
+
+    return true;
   }
 
   Role GetRole() const override
index b9aa46c..34b609a 100644 (file)
@@ -106,6 +106,11 @@ AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window)
   return GetImplementation(window).AuxiliaryMessageSignal();
 }
 
+AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window)
+{
+  return GetImplementation(window).AccessibilityHighlightSignal();
+}
+
 void SetParent(Window window, Window parent)
 {
   GetImplementation(window).SetParent(parent);
index a4779f7..8f51d27 100644 (file)
@@ -53,6 +53,8 @@ typedef Signal<void()> KeyboardRepeatSettingsChangedSignalType; ///< Keyboard re
 
 typedef Signal<void(const std::string&, const std::string&, const Property::Array&)> AuxiliaryMessageSignalType; ///< Auxiliary message signal type
 
+typedef Signal<void(Window, bool)> AccessibilityHighlightSignalType; ///< Accessibility Highlight signal type
+
 /**
  * @brief Creates an initialized handle to a new Window.
  *
@@ -163,6 +165,25 @@ DALI_ADAPTOR_API KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettings
 DALI_ADAPTOR_API AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window);
 
 /**
+ * @brief This signal is emitted when the window needs to grab or clear accessibility highlight.
+ * The highlight indicates that it is an object to interact with the user regardless of focus.
+ * After setting the highlight on the object, you can do things that the object can do, such as
+ * giving or losing focus.
+ *
+ * This signal is emitted by Dali::Accessibility::Component::GrabHighlight
+ * and Dali::Accessibility::Component::ClearHighlight
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Window window, bool highlight );
+ * @endcode
+ *
+ * @param[in] window The window instance
+ * @return The signal to connect to
+ */
+DALI_ADAPTOR_API AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window);
+
+/**
  * @brief Sets parent window of the window.
  *
  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
index 794438d..1c99009 100644 (file)
@@ -357,6 +357,12 @@ void Window::SetPositionSizeWithOrientation(PositionSize positionSize, WindowOri
   mWindowBase->SetPositionSizeWithAngle(positionSize, angle);
 }
 
+void Window::EmitAccessibilityHighlightSignal(bool highlight)
+{
+  Dali::Window handle(this);
+  mAccessibilityHighlightSignal.Emit(handle, highlight);
+}
+
 void Window::SetAvailableAnlges(const std::vector<int>& angles)
 {
   if(angles.size() > 4)
index 282a3ca..ce91a7f 100644 (file)
@@ -65,6 +65,7 @@ public:
   typedef Dali::DevelWindow::TransitionEffectEventSignalType         TransitionEffectEventSignalType;
   typedef Dali::DevelWindow::KeyboardRepeatSettingsChangedSignalType KeyboardRepeatSettingsChangedSignalType;
   typedef Dali::DevelWindow::AuxiliaryMessageSignalType              AuxiliaryMessageSignalType;
+  typedef Dali::DevelWindow::AccessibilityHighlightSignalType        AccessibilityHighlightSignalType;
   typedef Signal<void()>                                             SignalType;
 
   /**
@@ -392,6 +393,16 @@ public:
    */
   void SetPositionSizeWithOrientation(PositionSize positionSize, WindowOrientation orientation);
 
+  /**
+   * @brief Emit the accessibility highlight signal.
+   * The highlight indicates that it is an object to interact with the user regardless of focus.
+   * After setting the highlight on the object, you can do things that the object can do, such as
+   * giving or losing focus.
+   *
+   * @param[in] highlight If window needs to grab or clear highlight.
+   */
+  void EmitAccessibilityHighlightSignal(bool highlight);
+
 public: // Dali::Internal::Adaptor::SceneHolder
   /**
    * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
@@ -683,6 +694,14 @@ public: // Signals
     return mAuxiliaryMessageSignal;
   }
 
+  /**
+   * @copydoc Dali::DevelWindow::AccessibilityHighlightSignal()
+   */
+  AccessibilityHighlightSignalType& AccessibilityHighlightSignal()
+  {
+    return mAccessibilityHighlightSignal;
+  }
+
 private:
   WindowRenderSurface* mWindowSurface; ///< The window rendering surface
   WindowBase*          mWindowBase;
@@ -718,6 +737,7 @@ private:
   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
+  AccessibilityHighlightSignalType        mAccessibilityHighlightSignal;
 };
 
 } // namespace Adaptor