X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ffocus-manager%2Fkeyboard-focus-manager-impl.cpp;h=5225c46cb31f3a6f7463796da7791d3dfce8a78d;hp=57fe0767cac47d71a6bb6bd1faefd47cf2485ccf;hb=386634b00f264e667074fa7d956c81bc72233c62;hpb=aa906fd49430568986b95c51bd29f3a58c33272f 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 57fe076..5225c46 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,8 @@ #include #include #include +#include +#include namespace Dali { @@ -114,10 +117,10 @@ KeyboardFocusManager::KeyboardFocusManager() mFocusChangedSignal(), mFocusGroupChangedSignal(), mFocusedActorEnterKeySignal(), - mCurrentFocusActor( 0 ), + mCurrentFocusActor(), mFocusIndicatorActor(), + mIsFocusIndicatorEnabled( -1 ), mFocusGroupLoopEnabled( false ), - mIsFocusIndicatorEnabled( false ), mIsWaitingKeyboardFocusChangeCommit( false ), mFocusHistory(), mSlotDelegate( this ), @@ -132,10 +135,25 @@ KeyboardFocusManager::~KeyboardFocusManager() { } +void KeyboardFocusManager::GetConfigurationFromStyleManger() +{ + Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get(); + if( styleManager ) + { + Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager ); + mIsFocusIndicatorEnabled = static_cast(config["alwaysShowFocus"].Get()); + } +} + bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor ) { DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" ); + if( mIsFocusIndicatorEnabled == -1 ) + { + GetConfigurationFromStyleManger(); + } + return DoSetCurrentFocusActor( actor ); } @@ -143,16 +161,27 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor ) { bool success = false; + Actor currentFocusedActor = GetCurrentFocusActor(); + + // If developer set focus on same actor, doing nothing + if( actor == currentFocusedActor ) + { + if( !actor ) + { + return false; + } + return true; + } + // Check whether the actor is in the stage and is keyboard focusable. - if( actor && actor.IsKeyboardFocusable() ) + if( actor && actor.IsKeyboardFocusable() && actor.OnStage() ) { if( mIsFocusIndicatorEnabled ) { actor.Add( GetFocusIndicatorActor() ); } - // Send notification for the change of focus actor - Actor currentFocusedActor = GetCurrentFocusActor(); + // Send notification for the change of focus actor if( !mFocusChangedSignal.Empty() ) { mFocusChangedSignal.Emit(currentFocusedActor, actor); @@ -169,7 +198,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor ) DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__); // Save the current focused actor - mCurrentFocusActor = actor.GetId(); + mCurrentFocusActor = actor; Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor); if( newlyFocusedControl ) @@ -201,8 +230,15 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor ) Actor KeyboardFocusManager::GetCurrentFocusActor() { - Actor rootActor = Stage::GetCurrent().GetRootLayer(); - return rootActor.FindChildById(mCurrentFocusActor); + Actor actor = mCurrentFocusActor.GetHandle(); + if( actor && ! actor.OnStage() ) + { + // If the actor has been removed from the stage, then it should not be focused + + actor.Reset(); + mCurrentFocusActor.Reset(); + } + return actor; } Actor KeyboardFocusManager::GetCurrentFocusGroup() @@ -504,8 +540,8 @@ void KeyboardFocusManager::ClearFocus() } } - mCurrentFocusActor = 0; - mIsFocusIndicatorEnabled = false; + mCurrentFocusActor.Reset(); + mIsFocusIndicatorEnabled = 0; } void KeyboardFocusManager::SetFocusGroupLoop(bool enabled) @@ -605,6 +641,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) std::string keyName = event.keyPressedName; + if( mIsFocusIndicatorEnabled == -1 ) + { + GetConfigurationFromStyleManger(); + } + bool isFocusStartableKey = false; if(event.state == KeyEvent::Down) @@ -616,7 +657,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -639,7 +680,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -660,7 +701,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -675,7 +716,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -690,7 +731,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -705,7 +746,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -720,7 +761,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else { @@ -736,7 +777,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } isFocusStartableKey = true; @@ -747,7 +788,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } isFocusStartableKey = true; @@ -767,7 +808,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled) { // Show focus indicator - mIsFocusIndicatorEnabled = true; + mIsFocusIndicatorEnabled = 1; } else {