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=bdfdded1d2b0f5bcd0d893249bef7332e6907be6;hp=74e89dc0c5f0cc420d9b03313eda0e5c020c08cc;hb=c8fc0c045a0d0d7103ec586f764f1c45b260b984;hpb=340a0bbd8c7e93bc7a8e7c25b7ff44bb0b0af196 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 74e89dc..bdfdded 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 #include @@ -145,7 +146,8 @@ void KeyboardFocusManager::OnAdaptorInit() { (*iter).KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); (*iter).TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch); - (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); + (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent); + (*iter).WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); Dali::Window window = DevelWindow::DownCast(*iter); if(window) { @@ -162,7 +164,8 @@ void KeyboardFocusManager::OnSceneHolderCreated(Dali::Integration::SceneHolder& { sceneHolder.KeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); sceneHolder.TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch); - sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); + sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent); + sceneHolder.WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); Dali::Window window = DevelWindow::DownCast(sceneHolder); if(window) { @@ -248,11 +251,6 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) actor.Add(GetFocusIndicatorActor()); } - // Send notification for the change of focus actor - if(!mFocusChangedSignal.Empty()) - { - mFocusChangedSignal.Emit(currentFocusedActor, actor); - } Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor); if(currentlyFocusedControl) @@ -262,8 +260,6 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) currentlyFocusedControl.ClearKeyInputFocus(); } - DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__); - // Save the current focused actor mCurrentFocusActor = actor; @@ -300,6 +296,11 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor(Actor actor) mFocusHistory.erase(beginPos); } + // Send notification for the change of focus actor + if(!mFocusChangedSignal.Empty()) + { + mFocusChangedSignal.Emit(currentFocusedActor, actor); + } DALI_LOG_INFO(gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__); success = true; } @@ -420,7 +421,7 @@ Toolkit::Control KeyboardFocusManager::GetParentLayoutControl(Actor actor) const return Toolkit::Control::DownCast(parent); } -bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction direction) +bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction direction, const std::string& deviceName) { Actor currentFocusActor = GetCurrentFocusActor(); @@ -470,6 +471,16 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction index = Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID; break; } + case Toolkit::Control::KeyboardFocus::CLOCKWISE: + { + index = Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID; + break; + } + case Toolkit::Control::KeyboardFocus::COUNTER_CLOCKWISE: + { + index = Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID; + break; + } default: break; } @@ -506,7 +517,7 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction if(mCustomAlgorithmInterface) { mIsWaitingKeyboardFocusChangeCommit = true; - nextFocusableActor = mCustomAlgorithmInterface->GetNextFocusableActor(currentFocusActor, Actor(), direction); + nextFocusableActor = mCustomAlgorithmInterface->GetNextFocusableActor(currentFocusActor, Actor(), direction, deviceName); mIsWaitingKeyboardFocusChangeCommit = false; } else if(!mPreFocusChangeSignal.Empty()) @@ -668,14 +679,10 @@ void KeyboardFocusManager::DoKeyboardEnter(Actor actor) void KeyboardFocusManager::ClearFocus() { + ClearFocusIndicator(); Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Remove(mFocusIndicatorActor); - } - // Send notification for the change of focus actor if(!mFocusChangedSignal.Empty()) { @@ -689,8 +696,19 @@ void KeyboardFocusManager::ClearFocus() currentlyFocusedControl.ClearKeyInputFocus(); } } - mCurrentFocusActor.Reset(); +} + +void KeyboardFocusManager::ClearFocusIndicator() +{ + Actor actor = GetCurrentFocusActor(); + if(actor) + { + if(mFocusIndicatorActor) + { + actor.Remove(mFocusIndicatorActor); + } + } mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE; } @@ -785,7 +803,8 @@ Actor KeyboardFocusManager::GetFocusIndicatorActor() void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { - std::string keyName = event.GetKeyName(); + const std::string& keyName = event.GetKeyName(); + const std::string& deviceName = event.GetDeviceName(); if(mIsFocusIndicatorShown == UNKNOWN) { @@ -806,7 +825,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards left - MoveFocus(Toolkit::Control::KeyboardFocus::LEFT); + MoveFocus(Toolkit::Control::KeyboardFocus::LEFT, deviceName); } isFocusStartableKey = true; @@ -821,7 +840,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards right - MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); + MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT, deviceName); } isFocusStartableKey = true; @@ -836,7 +855,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards up - MoveFocus(Toolkit::Control::KeyboardFocus::UP); + MoveFocus(Toolkit::Control::KeyboardFocus::UP, deviceName); } isFocusStartableKey = true; @@ -851,7 +870,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards down - MoveFocus(Toolkit::Control::KeyboardFocus::DOWN); + MoveFocus(Toolkit::Control::KeyboardFocus::DOWN, deviceName); } isFocusStartableKey = true; @@ -866,7 +885,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards the previous page - MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP); + MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP, deviceName); } isFocusStartableKey = true; @@ -881,7 +900,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) else { // Move the focus towards the next page - MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN); + MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN, deviceName); } isFocusStartableKey = true; @@ -900,7 +919,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) if(!DoMoveFocusToNextFocusGroup(!event.IsShiftModifier())) { // If the focus group is not changed, Move the focus towards forward, "Shift-Tap" key moves the focus towards backward. - MoveFocus(event.IsShiftModifier() ? Toolkit::Control::KeyboardFocus::BACKWARD : Toolkit::Control::KeyboardFocus::FORWARD); + MoveFocus(event.IsShiftModifier() ? Toolkit::Control::KeyboardFocus::BACKWARD : Toolkit::Control::KeyboardFocus::FORWARD, deviceName); } } @@ -973,7 +992,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { // No actor is focused but keyboard focus is activated by the key press // Let's try to move the initial focus - MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); + MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT, deviceName); } } } @@ -991,34 +1010,56 @@ void KeyboardFocusManager::OnTouch(const TouchEvent& touch) // We only do this on a Down event, otherwise the clear action may override a manually focused actor. if(((touch.GetPointCount() < 1) || (touch.GetState(0) == PointState::DOWN))) { - // If mClearFocusOnTouch is false, do not clear the focus even if user touch the screen. - if(mClearFocusOnTouch) + // If you touch the currently focused actor again, you don't need to do SetCurrentFocusActor again. + Actor hitActor = touch.GetHitActor(0); + if(hitActor && hitActor == GetCurrentFocusActor()) { - ClearFocus(); + return; } - // If KEYBOARD_FOCUSABLE and TOUCH_FOCUSABLE is true, set focus actor - Actor hitActor = touch.GetHitActor(0); if(hitActor && hitActor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && hitActor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE)) { + // If mClearFocusOnTouch is false, do not clear the focus + if(mClearFocusOnTouch) + { + ClearFocus(); + } SetCurrentFocusActor(hitActor); } + else + { + // If mClearFocusOnTouch is false, do not clear the focus indicator even if user touch the screen. + if(mClearFocusOnTouch) + { + ClearFocusIndicator(); + } + } + } +} + +void KeyboardFocusManager::OnWheelEvent(const WheelEvent& event) +{ + if(event.GetType() == Dali::WheelEvent::CUSTOM_WHEEL) + { + Toolkit::Control::KeyboardFocus::Direction direction = (event.GetDelta() > 0) ? Toolkit::Control::KeyboardFocus::CLOCKWISE : Toolkit::Control::KeyboardFocus::COUNTER_CLOCKWISE; + // Move the focus + MoveFocus(direction); } } -bool KeyboardFocusManager::OnWheelEvent(const WheelEvent& event) +bool KeyboardFocusManager::OnCustomWheelEvent(const WheelEvent& event) { bool consumed = false; Actor actor = GetCurrentFocusActor(); if(actor) { // Notify the actor about the wheel event - consumed = EmitWheelSignals(actor, event); + consumed = EmitCustomWheelSignals(actor, event); } return consumed; } -bool KeyboardFocusManager::EmitWheelSignals(Actor actor, const WheelEvent& event) +bool KeyboardFocusManager::EmitCustomWheelSignals(Actor actor, const WheelEvent& event) { bool consumed = false; @@ -1041,7 +1082,7 @@ bool KeyboardFocusManager::EmitWheelSignals(Actor actor, const WheelEvent& event if(parent && (parent == oldParent)) { - consumed = EmitWheelSignals(parent, event); + consumed = EmitCustomWheelSignals(parent, event); } } }