From: Tom Robinson Date: Fri, 26 Jun 2015 16:48:44 +0000 (+0100) Subject: OnActivated() change for Accessibility and KeyboardFocus X-Git-Tag: dali_1.0.47~5^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=7f36ca9572ba3086167d5238a7aff909b56a50f4 OnActivated() change for Accessibility and KeyboardFocus Change-Id: I26d9cb629133763562aea652c98b670d8d44f2e5 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index 20a5041..79668ff 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -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; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h index ddfdcba..6db3f8b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h @@ -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); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index f3aa937..daac903 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -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; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index e902ec0..95a6eb5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -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); diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h index b2428d9..e37e319 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h @@ -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 */ diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 2877ed3..a1eb3cf 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -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() diff --git a/dali-toolkit/internal/controls/buttons/button-impl.h b/dali-toolkit/internal/controls/buttons/button-impl.h index 02b1360..e4d49d7 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.h +++ b/dali-toolkit/internal/controls/buttons/button-impl.h @@ -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. diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index e1693ad..0c37f7c 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -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 { diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h index bc456c2..de3770f 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h @@ -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 diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index bbc98b4..271a5ce 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -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 diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index ce793f3..1c3c35d 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -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 /** diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index e7511a1..1e4d74d 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -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 { diff --git a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp index 2e0ffbe..a816ca2 100644 --- a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp +++ b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.cpp @@ -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 diff --git a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h index 6afcd6b..3383a47 100644 --- a/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h +++ b/dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h @@ -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