[AT-SPI] enhance SHOWING state decision logic
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / accessible-impl.h
index feffe75..aa5084a 100644 (file)
@@ -19,6 +19,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/accessibility-impl.h>
 #include <dali/devel-api/adaptor-framework/accessibility.h>
+#include <dali/public-api/object/weak-handle.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
@@ -45,9 +46,43 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
                                          public virtual Dali::Accessibility::Collection,
                                          public virtual Dali::Accessibility::Action
 {
-  Dali::Actor self;
-  bool        modal = false, root = false;
+protected:
+  Vector2                       mLastPosition{0.0f, 0.0f};
+  Dali::WeakHandle<Dali::Actor> mSelf;
+  Dali::WeakHandle<Dali::Actor> mCurrentHighlightActor;
+  bool mIsModal = false;
+  bool mIsRoot = false;
 
+  Dali::Actor Self()
+  {
+    auto handle = mSelf.GetHandle();
+
+    // Control::Impl holds a std::unique_ptr to the Accessible object,
+    // so that one does not outlive the other.
+    DALI_ASSERT_ALWAYS(handle);
+
+    return handle;
+  }
+
+  void ScrollToSelf();
+
+  /**
+   * @brief Register property notification to check highlighted object position
+   */
+  void RegisterPositionPropertyNotification();
+
+  /**
+   * @brief Remove property notification added by RegisterPropertyNotification
+   */
+  void UnregisterPositionPropertyNotification();
+
+  /**
+   * @brief Check if the actor is showing
+   * @return True if the actor is showing
+   */
+  bool IsShowing();
+
+public:
   AccessibleImpl(Dali::Actor self, Dali::Accessibility::Role role, bool modal = false);
 
   /**
@@ -96,6 +131,11 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
   Dali::Accessibility::Role GetRole() override;
 
   /**
+   * @copydoc Dali::Accessibility::Accessible::GetLocalizedRoleName()
+   */
+  std::string GetLocalizedRoleName() override;
+
+  /**
    * @copydoc Dali::Accessibility::Accessible::GetStates()
    */
   Dali::Accessibility::States GetStates() override;
@@ -108,7 +148,7 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
   /**
    * @copydoc Dali::Accessibility::Component::GetExtents()
    */
-  Dali::Rect<> GetExtents(Dali::Accessibility::CoordType ctype) override;
+  Dali::Rect<> GetExtents(Accessibility::CoordinateType type) override;
 
   /**
    * @copydoc Dali::Accessibility::Component::GetLayer()
@@ -192,14 +232,9 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
 
   /**
    * @brief Makes sure that a given child of this container (e.g. ItemView) is visible
+   * @return false if scrolling is not supported or child is already visible
    */
-  virtual void EnsureChildVisible(Actor child);
-
-  /**
-   * @brief Makes sure this actor is visible (when moving the highlight frame to an
-   * actor that is scrolled out of the viewport)
-   */
-  virtual void EnsureSelfVisible();
+  virtual bool ScrollToChild(Actor child);
 
   /**
    * @brief Returns the index of the property that represents this actor's name
@@ -210,6 +245,18 @@ struct DALI_TOOLKIT_API AccessibleImpl : public virtual Dali::Accessibility::Acc
    * @brief Returns the index of the property that represents this actor's description
    */
   virtual Dali::Property::Index GetDescriptionPropertyIndex();
+
+  /**
+   * @brief Sets last object position
+   * @param[in] position Last object position
+   */
+  void SetLastPosition(Vector2 position);
+
+  /**
+   * @brief Gets last object position
+   * @return The Last object position
+   */
+  Vector2 GetLastPosition() const;
 };
 
 } // namespace Dali::Toolkit::DevelControl