Merge "OnActivated() change for Accessibility and KeyboardFocus" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 30 Jun 2015 09:12:32 +0000 (02:12 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 30 Jun 2015 09:12:33 +0000 (02:12 -0700)
14 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp
automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/buttons/button-impl.h
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h
dali-toolkit/public-api/controls/control.h
dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp
dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h

index 20a5041..79668ff 100644 (file)
@@ -112,7 +112,7 @@ DummyControlImplOverride::~DummyControlImplOverride() { }
 
 
 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
-void DummyControlImplOverride::OnActivated() { activatedCalled = true; }
+bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
 {
   themeChangeCalled = change == StyleChange::THEME_CHANGE;
index ddfdcba..6db3f8b 100644 (file)
@@ -102,7 +102,7 @@ private:
 private: // From Internal::Control
 
   virtual void OnInitialize();
-  virtual void OnActivated();
+  virtual bool OnAccessibilityActivated();
   virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
   virtual void OnPinch(const PinchGesture& pinch);
   virtual void OnPan(const PanGesture& pan);
index f3aa937..daac903 100644 (file)
@@ -922,7 +922,7 @@ int UtcDaliControlImplOnAccessibilityActivatedP(void)
   DALI_TEST_CHECK( handle );
 
   Property::Map attributes;
-  DALI_TEST_EQUALS( false, handle.DoAction("control-activated", attributes), TEST_LOCATION );
+  DALI_TEST_EQUALS( false, handle.DoAction("accessibility-activated", attributes), TEST_LOCATION );
 
   END_TEST;
 }
index e902ec0..95a6eb5 100644 (file)
@@ -594,7 +594,7 @@ int UtcDaliKeyboardFocusManagerSignalFocusedActorActivated(void)
 
   bool focusedActorActivatedSignalVerified = false;
   FocusedActorActivatedCallback focusedActorActivatedCallback(focusedActorActivatedSignalVerified);
-  manager.FocusedActorActivatedSignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
+  manager.FocusedActorEnterKeySignal().Connect( &focusedActorActivatedCallback, &FocusedActorActivatedCallback::Callback );
 
   Integration::KeyEvent returnEvent("Return", "", 0, 0, 0, Integration::KeyEvent::Up);
 
index b2428d9..e37e319 100644 (file)
@@ -485,7 +485,7 @@ private:
   bool DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped);
 
   /**
-   * Activate the actor. If the actor is control, call OnActivated virtual function.
+   * Activate the actor. If the actor is control, call OnAccessibilityActivated virtual function.
    * This function will emit FocusedActorActivatedSignal.
    * @param actor The actor to activate
    */
index 2877ed3..a1eb3cf 100644 (file)
@@ -905,7 +905,7 @@ Actor& Button::GetDisabledBackgroundImage()
   return mDisabledBackgroundContent;
 }
 
-  bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
 {
   bool ret = false;
 
@@ -917,14 +917,13 @@ Actor& Button::GetDisabledBackgroundImage()
 
   if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
   {
-    GetImplementation( button ).DoClickAction( attributes );
-    ret = true;
+    ret = GetImplementation( button ).DoClickAction( attributes );
   }
 
   return ret;
 }
 
-  void Button::DoClickAction( const Property::Map& attributes )
+bool Button::DoClickAction( const Property::Map& attributes )
 {
   // Prevents the button signals from doing a recursive loop by sending an action
   // and re-emitting the signals.
@@ -935,7 +934,11 @@ Actor& Button::GetDisabledBackgroundImage()
     mState = ButtonDown;
     OnButtonUp();
     mClickActionPerforming = false;
+
+    return true;
   }
+
+  return false;
 }
 
 void Button::UpdatePaintTransitionState()
@@ -1206,11 +1209,18 @@ void Button::OnInitialize()
   self.SetKeyboardFocusable( true );
 }
 
-void Button::OnActivated()
+bool Button::OnAccessibilityActivated()
+{
+  return OnKeyboardEnter();
+}
+
+bool Button::OnKeyboardEnter()
 {
-  // When the button is activated, it performs the click action
+  // When the enter key is pressed, or button is activated, the click action is performed.
   Property::Map attributes;
-  DoClickAction( attributes );
+  bool ret = DoClickAction( attributes );
+
+  return ret;
 }
 
 void Button::OnControlStageDisconnection()
index 02b1360..e4d49d7 100644 (file)
@@ -279,8 +279,9 @@ private:
   /**
    * Perform the click action to click the button.
    * @param[in] attributes The attributes to perfrom this action.
+   * @return true if this control can perform action.
    */
-  void DoClickAction( const Property::Map& attributes );
+  bool DoClickAction( const Property::Map& attributes );
 
   /**
    * This method is called after the button initialization.
@@ -454,9 +455,14 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
-   * @copydoc Toolkit::Control::OnActivated()
+   * @copydoc Toolkit::Control::OnAccessibilityActivated()
    */
-  virtual void OnActivated();
+  virtual bool OnAccessibilityActivated();
+
+  /**
+   * @copydoc Toolkit::Control::OnKeyboardEnter()
+   */
+  virtual bool OnKeyboardEnter();
 
   /**
    * Callback received when the button is disconnected from the stage.
index e1693ad..0c37f7c 100644 (file)
@@ -81,7 +81,7 @@ DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::KeyboardFocusManager, Dali::BaseHa
 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboard-pre-focus-change",        SIGNAL_PRE_FOCUS_CHANGE        )
 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboard-focus-changed",           SIGNAL_FOCUS_CHANGED           )
 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboard-focus-group-changed",     SIGNAL_FOCUS_GROUP_CHANGED     )
-DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboard-focused-actor-activated", SIGNAL_FOCUSED_ACTOR_ACTIVATED )
+DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboard-focused-actor-enter-key", SIGNAL_FOCUSED_ACTOR_ENTER_KEY )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -339,21 +339,21 @@ bool KeyboardFocusManager::DoMoveFocusToNextFocusGroup(bool forward)
   return succeed;
 }
 
-void KeyboardFocusManager::DoActivate(Actor actor)
+void KeyboardFocusManager::DoKeyboardEnter(Actor actor)
 {
-  if(actor)
+  if( actor )
   {
-    Toolkit::Control control = Toolkit::Control::DownCast(actor);
-    if(control)
+    Toolkit::Control control = Toolkit::Control::DownCast( actor );
+    if( control )
     {
-      // Notify the control that it is activated
-      GetImplementation( control ).AccessibilityActivate();
+      // Notify the control that enter has been pressed on it.
+      GetImplementation( control ).KeyboardEnter();
     }
 
-    // Send notification for the activation of focused actor
-    if( !mFocusedActorActivatedSignal.Empty() )
+    // Send a notification for the actor.
+    if( !mFocusedActorEnterKeySignal.Empty() )
     {
-      mFocusedActorActivatedSignal.Emit(actor);
+      mFocusedActorEnterKeySignal.Emit( actor );
     }
   }
 }
@@ -655,9 +655,9 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       }
       else
       {
-        // Activate the focused actor
+        // The focused actor has enter pressed on it
         Actor actor;
-        if(!isAccessibilityEnabled)
+        if( !isAccessibilityEnabled )
         {
           actor = GetCurrentFocusActor();
         }
@@ -666,9 +666,9 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
           actor = accessibilityManager.GetCurrentFocusActor();
         }
 
-        if(actor)
+        if( actor )
         {
-          DoActivate(actor);
+          DoKeyboardEnter( actor );
         }
       }
 
@@ -714,9 +714,9 @@ Toolkit::KeyboardFocusManager::FocusGroupChangedSignalType& KeyboardFocusManager
   return mFocusGroupChangedSignal;
 }
 
-Toolkit::KeyboardFocusManager::FocusedActorActivatedSignalType& KeyboardFocusManager::FocusedActorActivatedSignal()
+Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignalType& KeyboardFocusManager::FocusedActorEnterKeySignal()
 {
-  return mFocusedActorActivatedSignal;
+  return mFocusedActorEnterKeySignal;
 }
 
 bool KeyboardFocusManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
@@ -738,9 +738,9 @@ bool KeyboardFocusManager::DoConnectSignal( BaseObject* object, ConnectionTracke
   {
     manager->FocusGroupChangedSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ACTIVATED ) )
+  else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ENTER_KEY ) )
   {
-    manager->FocusedActorActivatedSignal().Connect( tracker, functor );
+    manager->FocusedActorEnterKeySignal().Connect( tracker, functor );
   }
   else
   {
index bc456c2..de3770f 100644 (file)
@@ -125,9 +125,9 @@ public:
   Toolkit::KeyboardFocusManager::FocusGroupChangedSignalType& FocusGroupChangedSignal();
 
   /**
-   * @copydoc Toolkit::KeyboardFocusManager::FocusedActorActivatedSignal()
+   * @copydoc Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignal()
    */
-  Toolkit::KeyboardFocusManager::FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
+  Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignalType& FocusedActorEnterKeySignal();
 
   /**
    * Connects a callback function with the object's signals.
@@ -183,11 +183,11 @@ private:
   bool DoMoveFocusToNextFocusGroup(bool forward);
 
   /**
-   * Activate the actor. If the actor is control, call OnActivated virtual function.
-   * This function will emit FocusedActorActivatedSignal.
-   * @param actor The actor to activate
+   * Enter has been pressed on the actor. If the actor is control, call the OnKeybaordEnter virtual function.
+   * This function will emit FocusedActorEnterKeySignal.
+   * @param actor The actor to notify
    */
-  void DoActivate(Actor actor);
+  void DoKeyboardEnter( Actor actor );
 
   /**
    * Create the default indicator actor to highlight the focused actor.
@@ -243,7 +243,7 @@ private:
   Toolkit::KeyboardFocusManager::PreFocusChangeSignalType mPreFocusChangeSignal; ///< The signal to notify the focus will be changed
   Toolkit::KeyboardFocusManager::FocusChangedSignalType mFocusChangedSignal; ///< The signal to notify the focus change
   Toolkit::KeyboardFocusManager::FocusGroupChangedSignalType mFocusGroupChangedSignal; ///< The signal to notify the focus group change
-  Toolkit::KeyboardFocusManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; ///< The signal to notify the activation of focused actor
+  Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignalType mFocusedActorEnterKeySignal; ///< The signal to notify that enter has been pressed on the focused actor
 
   unsigned int mCurrentFocusActor; ///< The actor ID of current focused actor
 
index bbc98b4..271a5ce 100644 (file)
@@ -64,12 +64,12 @@ BaseHandle Create()
  * @param[in] attributes The attributes with which to perfrom this action.
  * @return true if action has been accepted by this control
  */
-const char* ACTION_CONTROL_ACTIVATED = "control-activated";
+const char* ACTION_ACCESSIBILITY_ACTIVATED = "accessibility-activated";
 static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
 {
   bool ret = false;
 
-  if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
+  if( object && ( 0 == strcmp( actionName.c_str(), ACTION_ACCESSIBILITY_ACTIVATED ) ) )
   {
     Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
     if( control )
@@ -158,7 +158,7 @@ SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnect
 SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
 SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
 
-TypeAction registerAction( typeRegistration, ACTION_CONTROL_ACTIVATED, &DoAction );
+TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &DoAction );
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -767,11 +767,22 @@ void Control::AccessibilityActivate()
   OnAccessibilityActivated();
 }
 
+void Control::KeyboardEnter()
+{
+  // Inform deriving classes
+  OnKeyboardEnter();
+}
+
 bool Control::OnAccessibilityActivated()
 {
   return false; // Accessibility activation is not handled by default
 }
 
+bool Control::OnKeyboardEnter()
+{
+  return false; // Keyboard enter is not handled by default
+}
+
 bool Control::OnAccessibilityPan(PanGesture gesture)
 {
   return false; // Accessibility pan gesture is not handled by default
index ce793f3..1c3c35d 100644 (file)
@@ -222,13 +222,16 @@ public:
    */
   bool IsKeyboardFocusGroup();
 
-  // Called by Focus Manager
-
   /**
-   * @brief Called by the accessibility focus manager and keyboard focus manager to activate the Control
+   * @brief Called by the AccessibilityManager to activate the Control.
    */
   DALI_INTERNAL void AccessibilityActivate();
 
+  /**
+   * @brief Called by the KeyboardFocusManager.
+   */
+  DALI_INTERNAL void KeyboardEnter();
+
   // Signals
 
   /**
@@ -510,6 +513,14 @@ public: // API for derived classes to override
    */
   virtual void OnKeyboardFocusChangeCommitted( Actor commitedFocusableActor );
 
+  /**
+   * @brief This method is called when the control has enter pressed on it.
+   *
+   * Derived classes should override this to perform custom actions.
+   * @return true if this control supported this action.
+   */
+  virtual bool OnKeyboardEnter();
+
   // Gestures
 
   /**
index e7511a1..1e4d74d 100644 (file)
@@ -59,9 +59,9 @@ class Control;
  * | long-pressed           | @ref GetLongPressGestureDetector().DetectedSignal() |
  *
  * Actions
- * | %Action Name      | %Control method called                              |
- * |-------------------|-----------------------------------------------------|
- * | control-activated | %OnActivated()                                      |
+ * | %Action Name            | %Control method called                             |
+ * |-------------------------|----------------------------------------------------|
+ * | accessibility-activated | %OnAccessibilityActivated()                        |
  */
 class DALI_IMPORT_API Control : public CustomActor
 {
index 2e0ffbe..a816ca2 100644 (file)
@@ -122,9 +122,9 @@ KeyboardFocusManager::FocusGroupChangedSignalType& KeyboardFocusManager::FocusGr
   return GetImpl(*this).FocusGroupChangedSignal();
 }
 
-KeyboardFocusManager::FocusedActorActivatedSignalType& KeyboardFocusManager::FocusedActorActivatedSignal()
+KeyboardFocusManager::FocusedActorEnterKeySignalType& KeyboardFocusManager::FocusedActorEnterKeySignal()
 {
-  return GetImpl(*this).FocusedActorActivatedSignal();
+  return GetImpl(*this).FocusedActorEnterKeySignal();
 }
 
 } // namespace Toolkit
index 6afcd6b..3383a47 100644 (file)
@@ -47,7 +47,7 @@ class KeyboardFocusManager;
  * | keyboard-pre-focus-change        | @ref PreFocusChangeSignal()        |
  * | keyboard-focus-changed           | @ref FocusChangedSignal()          |
  * | keyboard-focus-group-changed     | @ref FocusGroupChangedSignal()     |
- * | keyboard-focused-actor-activated | @ref FocusedActorActivatedSignal() |
+ * | keyboard-focused-actor-enter-key | @ref FocusedActorEnterKeySignal()  |
  */
 class DALI_IMPORT_API KeyboardFocusManager : public BaseHandle
 {
@@ -63,8 +63,8 @@ public:
   /// @brief Focus group changed signal
   typedef Signal< void ( Actor, bool ) > FocusGroupChangedSignalType;
 
-  /// @brief Focused actor activated signal
-  typedef Signal< void ( Actor ) > FocusedActorActivatedSignalType;
+  /// @brief Focused actor has the enter key pressed signal
+  typedef Signal< void ( Actor ) > FocusedActorEnterKeySignalType;
 
   /**
    * @brief Create a KeyboardFocusManager handle; this can be initialised with KeyboardFocusManager::New().
@@ -251,16 +251,16 @@ public: // Signals
   FocusGroupChangedSignalType& FocusGroupChangedSignal();
 
   /**
-   * @brief This signal is emitted when the current focused actor is activated.
+   * @brief This signal is emitted when the current focused actor has the enter key pressed on it.
    *
    * A callback of the following type may be connected:
    * @code
-   *   void YourCallbackName(Actor activatedActor);
+   *   void YourCallbackName(Actor enterPressedActor);
    * @endcode
    * @pre The Object has been initialized.
    * @return The signal to connect to.
    */
-  FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
+  FocusedActorEnterKeySignalType& FocusedActorEnterKeySignal();
 
   // Not intended for application developers