[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / accessibility-manager / accessibility-manager-impl.h
index e37e319..b55d448 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__
-#define __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H
+#define DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 // EXTERNAL INCLUDES
 #include <string>
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
-#include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
+#include <vector>
 #include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
-#include <dali/public-api/adaptor-framework/tts-player.h>
+#include <dali-toolkit/devel-api/accessibility-manager/accessibility-manager.h>
 
 namespace Dali
 {
@@ -44,46 +40,19 @@ class AccessibilityManager;
 /**
  * @copydoc Toolkit::AccessibilityManager
  */
-class AccessibilityManager : public Dali::BaseObject, Dali::AccessibilityActionHandler, Dali::AccessibilityGestureHandler, public Dali::ConnectionTracker
+class AccessibilityManager : public Dali::BaseObject, public Dali::ConnectionTracker
 {
 public:
 
   typedef Dali::Toolkit::AccessibilityManager::AccessibilityActionSignalType       AccessibilityActionSignalType;
   typedef Dali::Toolkit::AccessibilityManager::AccessibilityActionScrollSignalType AccessibilityActionScrollSignalType;
 
-  struct ActorAdditionalInfo
-  {
-    ActorAdditionalInfo()
-    : mFocusOrder(0)
-    {
-    }
-
-    unsigned int mFocusOrder; ///< The focus order of the actor. It is undefined by default.
-
-    std::string mAccessibilityAttributes[Toolkit::AccessibilityManager::ACCESSIBILITY_ATTRIBUTE_NUM]; ///< The array of attribute texts
-  };
-
-  typedef std::pair<unsigned int, unsigned int>        FocusIDPair;
-  typedef std::map<unsigned int, unsigned int>         FocusIDContainer;
-  typedef FocusIDContainer::iterator                   FocusIDIter;
-  typedef FocusIDContainer::const_iterator             FocusIDConstIter;
-
-  typedef std::pair<unsigned int, ActorAdditionalInfo> IDAdditionalInfoPair;
-  typedef std::map<unsigned int, ActorAdditionalInfo>  IDAdditionalInfoContainer;
-  typedef IDAdditionalInfoContainer::iterator          IDAdditionalInfoIter;
-  typedef IDAdditionalInfoContainer::const_iterator    IDAdditionalInfoConstIter;
-
   /**
    * Construct a new AccessibilityManager.
    */
   AccessibilityManager();
 
   /**
-   * Initialise the AccessibilityManager
-   */
-  void Initialise();
-
-  /**
    * @copydoc Toolkit::AccessibilityManager::SetAccessibilityAttribute
    */
   void SetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityManager::AccessibilityAttribute type, const std::string& text);
@@ -174,6 +143,16 @@ public:
   bool GetGroupMode() const;
 
   /**
+   * @copydoc Toolkit::AccessibilityManager::GetFocusGroup
+   */
+  Actor GetFocusGroup(Actor actor);
+
+  /**
+   * @copydoc Toolkit::AccessibilityManager::GetReadPosition
+   */
+  Vector2 GetReadPosition() const;
+
+  /**
    * @copydoc Toolkit::AccessibilityManager::SetWrapMode
    */
   void SetWrapMode(bool wrapped);
@@ -193,11 +172,6 @@ public:
    */
   Actor GetFocusIndicatorActor();
 
-  /**
-   * @copydoc Toolkit::AccessibilityManager::GetFocusGroup
-   */
-  Actor GetFocusGroup(Actor actor);
-
 public:
 
   /**
@@ -215,17 +189,6 @@ public:
    */
   Toolkit::AccessibilityManager::FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
 
-  /**
-   * Connects a callback function with the object's signals.
-   * @param[in] object The object providing the signal.
-   * @param[in] tracker Used to disconnect the signal.
-   * @param[in] signalName The signal to connect to.
-   * @param[in] functor A newly allocated FunctorDelegate.
-   * @return True if the signal was connected.
-   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
-   */
-  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
 public:  // Signals
 
   /**
@@ -413,14 +376,6 @@ public:  // Signals
   }
 
   /**
-   * @copydoc Dali::Toolkit::AccessibilityManager::ActionReadIndicatorInformationSignal
-   */
-  AccessibilityActionSignalType& ActionReadIndicatorInformationSignal()
-  {
-    return mActionReadIndicatorInformationSignal;
-  }
-
-  /**
    * @copydoc Dali::Toolkit::AccessibilityManager::ActionReadPauseResumeSignal
    */
   AccessibilityActionSignalType& ActionReadPauseResumeSignal()
@@ -453,252 +408,6 @@ protected:
 
 private:
 
-  /**
-   * Get the additional information (e.g. focus order and description) of the given actor.
-   * @param actorID The ID of the actor to be queried
-   * @return The additional information of the actor
-   */
-  ActorAdditionalInfo GetActorAdditionalInfo(const unsigned int actorID) const;
-
-  /**
-   * Synchronize the actor's additional information to reflect its latest focus order
-   * @param actorID The ID of the actor
-   * @param order The focus order of the actor
-   * @return The additional information of the actor
-   */
-  void SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order);
-
-  /**
-   * Move the focus to the specified actor and send notification for the focus change.
-   * @param actorID The ID of the actor to be queried
-   * @return Whether the focus is successful or not
-   */
-  bool DoSetCurrentFocusActor(const unsigned int actorID);
-
-  /**
-   * Move the focus to the next actor in the focus chain towards the specified direction.
-   * @param focusIDIter The iterator pointing to the current focused actor
-   * @param forward Whether the focus movement is forward or not. The focus movement will be backward if this is false.
-   * @param wrapped Whether the focus shoule be moved wrapped around or not
-   * @return Whether the focus is successful or not
-   */
-  bool DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped);
-
-  /**
-   * Activate the actor. If the actor is control, call OnAccessibilityActivated virtual function.
-   * This function will emit FocusedActorActivatedSignal.
-   * @param actor The actor to activate
-   */
-  void DoActivate(Actor actor);
-
-  /**
-   * Create the default indicator actor to highlight the focused actor.
-   */
-  void CreateDefaultFocusIndicatorActor();
-
-  /**
-   * Set whether the actor is focusable or not. A focusable property will be registered for
-   * the actor if not yet.
-   * @param actor The actor to be focused
-   * @param focusable Whether the actor is focusable or not
-   */
-  void SetFocusable(Actor actor, bool focusable);
-
-  /**
-   * Handle the accessibility pan gesture.
-   * @param[in]  panEvent  The pan event to be handled.
-   * @return whether the gesture is handled successfully or not.
-   */
-  virtual bool HandlePanGesture(const Integration::PanGestureEvent& panEvent);
-
-  /**
-   * Change the accessibility status when Accessibility feature(screen-reader) turned on or off.
-   * @return whether the status is changed or not.
-   */
-  virtual bool ChangeAccessibilityStatus();
-
-  /**
-   * Clear the accessibility focus from the current focused actor.
-   * @return whether the focus is cleared or not.
-   */
-  virtual bool ClearAccessibilityFocus();
-
-  /**
-   * Perform the accessibility action associated with a scroll event.
-   * @param touchEvent The touch point (and time) of the event.
-   * @return whether the focus is cleared or not.
-   */
-  virtual bool AccessibilityActionScroll( Dali::TouchEvent& touchEvent );
-
-  /**
-   * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up).
-   * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionPrevious(bool allowEndFeedback);
-
-  /**
-   * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down).
-   * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionNext(bool allowEndFeedback);
-
-  /**
-   * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left).
-   * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback);
-
-  /**
-   * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right).
-   * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadNext(bool allowEndFeedback);
-
-  /**
-   * Perform the accessibility action to focus and read the actor (by one finger tap or move).
-   * @param allowReadAgain true if the action read again the same object (i.e. read action)
-   *                       false if the action just read when the focus object is changed (i.e. over action)
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionRead(bool allowReadAgain);
-
-  /**
-   * Perform the accessibility action to activate the current focused actor (by one finger double tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionActivate();
-
-  /**
-   * Perform the accessibility action to change the value when the current focused actor is a slider
-   * (by double finger down and move up and right).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionUp();
-
-  /**
-   * Perform the accessibility action to change the value when the current focused actor is a slider
-   * (by double finger down and move down and left).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionDown();
-
-  /**
-   * Perform the accessibility action to navigate back (by two fingers circle draw).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionBack();
-
-  /**
-   * Perform the accessibility action to scroll up the list and focus on the first item on the list
-   * after the scrolling and read the item (by two finger swipe up).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionScrollUp();
-
-  /**
-   * Perform the accessibility action to scroll down the list and focus on the first item on the list
-   * after the scrolling and read the item (by two finger swipe down).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionScrollDown();
-
-  /**
-   * Perform the accessibility action to scroll left to the previous page (by two finger swipe left).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionPageLeft();
-
-  /**
-   * Perform the accessibility action to scroll right to the next page (by two finger swipe right).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionPageRight();
-
-  /**
-   * Perform the accessibility action to scroll up to the previous page (by one finger swipe left and right).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionPageUp();
-
-  /**
-   * Perform the accessibility action to scroll down to the next page (by one finger swipe right and left).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionPageDown();
-
-  /**
-   * Perform the accessibility action to move the focus to the first item on the screen
-   * (by one finger swipe up and down).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionMoveToFirst();
-
-  /**
-   * Perform the accessibility action to move the focus to the last item on the screen
-   * (by one finger swipe down and up).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionMoveToLast();
-
-  /**
-   * Perform the accessibility action to move the focus to the first item on the top
-   * and read from the top item continously (by three fingers single tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadFromTop();
-
-  /**
-   * Perform the accessibility action to move the focus to and read from the next item
-   * continously (by three fingers double tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadFromNext();
-
-  /**
-   * Perform the accessibility action to move the focus to do the zooming (by one finger triple tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionZoom();
-
-  /**
-   * Perform the accessibility action to read the information in the indicator (by two fingers triple tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadIndicatorInformation();
-
-  /**
-   * Perform the accessibility action to pause/resume the current read out (by two fingers single tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionReadPauseResume();
-
-  /**
-   * Perform the accessibility action to start/stop the current action (by two fingers double tap).
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionStartStop();
-
-  /**
-   * Perform the accessibility action to mouse move (by one finger tap & hold and move).
-   * @param touchEvent touch event structure
-   * @return whether the accessibility action is performed or not.
-   */
-  virtual bool AccessibilityActionTouch(const TouchEvent& touchEvent);
-
-  /**
-   * This function is connected to the TtsPlayer StateChangeSignal.
-   * It is called when the TTS players state changes.
-   * @param previousState The previous state of the TTS player (for comparison)
-   * @param currentState  The current state of the TTS player
-   */
-  void TtsStateChanged( const Dali::TtsPlayer::State previousState, const Dali::TtsPlayer::State currentState );
-
-private:
-
   // Undefined
   AccessibilityManager(const AccessibilityManager&);
 
@@ -706,6 +415,8 @@ private:
 
 private:
 
+  std::vector<Actor> mFocusOrder;
+
   Toolkit::AccessibilityManager::FocusChangedSignalType mFocusChangedSignal; ///< The signal to notify the focus change
   Toolkit::AccessibilityManager::FocusOvershotSignalType mFocusOvershotSignal; ///< The signal to notify the focus overshooted
   Toolkit::AccessibilityManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; ///< The signal to notify the activation of focused actor
@@ -738,24 +449,6 @@ private:
   AccessibilityActionSignalType       mActionReadPauseResumeSignal;
   AccessibilityActionSignalType       mActionStartStopSignal;
   AccessibilityActionScrollSignalType mActionScrollSignal;
-
-  FocusIDContainer mFocusIDContainer;       ///< The container to look up actor ID by focus order
-  IDAdditionalInfoContainer mIDAdditionalInfoContainer; ///< The container to look up additional information by actor ID
-  FocusIDPair mCurrentFocusActor;           ///< The focus order and actor ID of current focused actor
-  Actor mCurrentGesturedActor;              ///< The actor that will handle the gesture
-  Actor mFocusIndicatorActor;               ///< The focus indicator actor shared by all the focusable actors for highlight
-  Vector2 mPreviousPosition;                ///< The previous pan position; useful for calculating velocity for Gesture::Finished events
-  unsigned int mRecursiveFocusMoveCounter;  ///< The counter to count the number of recursive focus movement attempted before the focus movement is successful.
-
-  bool mIsWrapped:1;                        ///< Whether the focus movement is wrapped around or not
-  bool mIsFocusWithinGroup:1;               ///< Whether the focus movement is limited to the current focus group or not
-  bool mIsEndcapFeedbackEnabled:1;          ///< Whether the endcap feedback need to be played when the focus leaves the end or vice versa
-  bool mIsEndcapFeedbackPlayed:1;           ///< Whether the endcap feedback was played or not
-  bool mIsAccessibilityTtsEnabled:1;        ///< Whether accessibility feature(screen-reader) turned on/off
-  bool mTtsCreated:1;                       ///< Whether the TTS Player has been accessed
-  bool mIsFocusIndicatorEnabled:1;          ///< Whether indicator should be shown / hidden. It could be enabled when TTS enabled or 'Tab' key operated.
-  bool mContinuousPlayMode:1;               ///< Keeps track of whether or not we are in continuous play mode
-
 };
 
 } // namespace Internal
@@ -782,4 +475,4 @@ inline const Internal::AccessibilityManager& GetImpl(const Dali::Toolkit::Access
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__
+#endif // DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H