From 1dbbfc06a5abe326cc71dc69b961ff9a5809322d Mon Sep 17 00:00:00 2001 From: "minho.sun" Date: Mon, 20 Feb 2017 16:24:39 +0900 Subject: [PATCH] Change adding focus indicator logic Make sure KeyboardFocusManager add focus indicator according to mIsFocusIndicatorEnabled. Change-Id: I2283deab370597a437819d57e3b90d806ae4011c Signed-off-by: minho.sun --- .../dali-toolkit/utc-Dali-KeyboardFocusManager.cpp | 12 +++++++ .../focus-manager/keyboard-focus-manager-impl.cpp | 40 ++-------------------- .../focus-manager/keyboard-focus-manager-impl.h | 10 ------ 3 files changed, 14 insertions(+), 48 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp index a480204..2c395b2 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp @@ -609,6 +609,10 @@ int UtcDaliKeyboardFocusManagerSignalFocusedActorActivated(void) Integration::KeyEvent returnEvent("Return", "", 0, 0, 0, Integration::KeyEvent::Up); + // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager + // It makes mIsFocusIndicatorEnabled true + application.ProcessEvent(returnEvent); + // Create the first button and add it to the stage PushButton firstPushButton = PushButton::New(); firstPushButton.SetKeyboardFocusable(true); @@ -664,6 +668,10 @@ int UtcDaliKeyboardFocusManagerSignalFocusGroupChanged(void) Integration::KeyEvent tabEvent("Tab", "", 0, 0, 0, Integration::KeyEvent::Down); Integration::KeyEvent shiftTabEvent("Tab", "", 0, 1, 0, Integration::KeyEvent::Down); + // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager + // It makes mIsFocusIndicatorEnabled true + application.ProcessEvent(tabEvent); + // Send the tab event to change focus group in the forward direction application.ProcessEvent(tabEvent); DALI_TEST_CHECK(focusGroupChangedCallback.mSignalVerified); @@ -787,6 +795,10 @@ int UtcDaliKeyboardFocusManagerChangeFocusDirectionByKeyEvents(void) Integration::KeyEvent pageUpEvent("Prior", "", 0, 0, 0, Integration::KeyEvent::Down); Integration::KeyEvent pageDownEvent("Next", "", 0, 0, 0, Integration::KeyEvent::Down); + // Press Any key to notice physical keyboard event is comming to KeyboardFocusManager + // It makes mIsFocusIndicatorEnabled true + application.ProcessEvent(leftEvent); + // Create a 2x2 table view and try to move focus inside it TableView tableView = TableView::New( 2, 2 ); Stage::GetCurrent().Add(tableView); 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 989997b..28d305d 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -118,17 +118,14 @@ KeyboardFocusManager::KeyboardFocusManager() mCurrentFocusActor( 0 ), mFocusIndicatorActor(), mFocusGroupLoopEnabled( false ), - mIsKeyboardFocusEnabled( false ), mIsFocusIndicatorEnabled( false ), mIsWaitingKeyboardFocusChangeCommit( false ), mFocusHistory(), mSlotDelegate( this ) { - OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get()); - + // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorEnabled. Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch ); - PhysicalKeyboard::Get().StatusChangedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnPhysicalKeyboardStatusChanged); } KeyboardFocusManager::~KeyboardFocusManager() @@ -156,9 +153,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID ) // Check whether the actor is in the stage and is keyboard focusable. if( actor && actor.IsKeyboardFocusable() ) { - mIsFocusIndicatorEnabled = true; - // Draw the focus indicator upon the focused actor when PhysicalKeyboard is attached - if( mIsKeyboardFocusEnabled ) + if( mIsFocusIndicatorEnabled ) { actor.Add( GetFocusIndicatorActor() ); } @@ -529,39 +524,8 @@ Actor KeyboardFocusManager::GetFocusIndicatorActor() return mFocusIndicatorActor; } -void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard) -{ - mIsKeyboardFocusEnabled = keyboard.IsAttached(); - - if(mIsKeyboardFocusEnabled) - { - // Show indicator when keyboard focus turned on if there is focused actor. - Actor actor = GetCurrentFocusActor(); - if(actor) - { - actor.Add( GetFocusIndicatorActor() ); - } - mIsFocusIndicatorEnabled = true; - } - else - { - // Hide indicator when keyboard focus turned off - Actor actor = GetCurrentFocusActor(); - if( actor && mFocusIndicatorActor ) - { - actor.Remove( mFocusIndicatorActor ); - } - mIsFocusIndicatorEnabled = false; - } -} - void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { - if(!mIsKeyboardFocusEnabled) - { - return; - } - AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get(); bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled(); 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 1ece0b1..fd46678 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h @@ -19,8 +19,6 @@ */ // EXTERNAL INCLUDES -#include -#include #include // INTERNAL INCLUDES @@ -228,12 +226,6 @@ private: */ void OnTouch( const TouchData& touch ); - /** - * Change the keyboard focus status when keyboard focus feature turned on or off. - * @return Whether the status is changed or not. - */ - void OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard); - private: // Undefined @@ -254,8 +246,6 @@ private: bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group - bool mIsKeyboardFocusEnabled:1; ///< Whether keyboard focus feature turned on/off - bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when keyboard focus feature enabled and navigation keys or 'Tab' key pressed. bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet. -- 2.7.4