From: keonpyo.kong Date: Tue, 4 Jun 2013 08:23:00 +0000 (+0900) Subject: Apply Focused control each Form X-Git-Tag: submit/tizen_2.2/20130714.153149~630^2~18^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=627cd859e8ab7806bf9419b36650ade48a625ac4;p=framework%2Fosp%2Fuifw.git Apply Focused control each Form Change-Id: Ifa3c11f80585ae86ccceabb66ab73e6583f72d44 Signed-off-by: keonpyo.kong --- diff --git a/src/ui/FUi_Control.cpp b/src/ui/FUi_Control.cpp index 8b3748c..8c90a0d 100644 --- a/src/ui/FUi_Control.cpp +++ b/src/ui/FUi_Control.cpp @@ -61,6 +61,7 @@ using namespace Tizen::Base::Runtime; using namespace Tizen::Graphics; using namespace Tizen::Ui; using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; namespace { @@ -945,15 +946,6 @@ _Control::OnAncestorVisibleStateChanged(const _Control& control) pTouchManager->ResetTouchInfo(); } } - - if (IsVisible() == false) - { - _Control* pControl = GetFocused(); - if (pControl == this) - { - SetFocused(false); - } - } } void @@ -1555,11 +1547,13 @@ _Control::CallOnDetachingFromMainTree(_Control& control) _Window* pTop = control.GetRootWindow(); if (pTop) { - if ((&control) == pTop->GetFocusedControl()) + _Control* pControl = pTop->GetFocusControl(); + if ((&control) == pControl) { - pTop->SetFocusedControl(null); + pTop->SetFocusControl(null); } } + if (!__isPostOrderTraversal) { r = control.GetControlDelegate().OnDetachingFromMainTree(); @@ -2561,58 +2555,15 @@ _Control::IsFocused(void) const { ClearLastResult(); - if (!__focusSet) - { - return false; - } - - for (int i = 0; i < GetChildCount(); ++i) - { - _Control* pChild = GetChild(i); - - SysAssert(pChild); - if (pChild == null) - { - continue; - } - - if (pChild->__focusSet) - { - return false; - } - } - - return true; -} - -_Control* -_Control::GetFocused(void) const -{ - for (int i = GetChildCount() - 1; i >= 0; --i) - { - _Control* pChild = GetChild(i); - - SysAssert(pChild); - if (pChild == null) - { - continue; - } - - if (pChild->__focusSet == true) - { - return pChild->GetFocused(); - } - } + _Window* pTop = GetRootWindow(); + SysAssert(pTop); - if (__focusSet == true) + if (this == pTop->GetFocusControl()) { - return const_cast <_Control*>(this); - } - else - { - return null; + return true; } + return false; } result @@ -2632,16 +2583,14 @@ _Control::SetFocused(bool on) { _Window* pTop = GetRootWindow(); SysAssert(pTop); - pTop->SetFocusedControl(this); - pTop->SetFocusState(false); + pTop->SetFocusControl(this); _ControlManager* pControlMgr = _ControlManager::GetInstance(); SysAssert(pControlMgr); if (pTop->IsActivated() && pTop->IsFocusableDescendant(this)) { - pControlMgr->SetFocusedControl(*this); - SetFocusState(true); + pControlMgr->SetFocusControl(*this); } if (IsFailed(GetLastResult())) @@ -2653,11 +2602,10 @@ _Control::SetFocused(bool on) { _Window* pTop = GetRootWindow(); SysAssert(pTop); - pTop->SetFocusedControl(null); + pTop->SetFocusControl(null); _ControlManager* pControlMgr = _ControlManager::GetInstance(); SysAssert(pControlMgr); - pControlMgr->SetFocusedControl(*this, false); - SetFocusState(false); + pControlMgr->SetFocusControl(*this, false); if (IsFailed(GetLastResult())) { @@ -2668,43 +2616,6 @@ _Control::SetFocused(bool on) return E_SUCCESS; } -// [ToDo] Find the focused descendent and clear flags upwards. -void -_Control::SetFocusState(bool on) -{ - ClearLastResult(); - - if (on) - { - __focusSet = true; - _Control* pParent = GetParent(); - if (pParent) - { - pParent->SetFocusState(true); - } - } - else - { - __focusSet = false; - for (int i = 0; i < GetChildCount(); ++i) - { - _Control* pChild = GetChild(i); - - SysAssert(pChild); - if (pChild == null) - { - continue; - } - - if (pChild->__focusSet == true) - { - pChild->SetFocusState(false); - return; - } - } - } -} - result _Control::SetFont(const String& fontName) { @@ -2893,11 +2804,6 @@ _Control::SetEnableState(bool enabledState) const bool changed = (__enabledState != enabledState); if (changed) { - _Control* pControl = GetFocused(); - if (!enabledState && pControl) - { - pControl->SetFocused(false); - } __enabledState = enabledState; CallOnAncestorEnableStateChanged(); } @@ -3024,20 +2930,6 @@ _Control::SetVisibleState(bool visibleState) if (visibleState == false) { - _Window* pTop = GetRootWindow(); - if (pTop) - { - if ((this) == pTop->GetFocusedControl()) - { - pTop->SetFocusedControl(null); - } - } - - _Control* pControl = GetFocused(); - if (pControl == this) - { - SetFocused(false); - } int owneeCount = GetOwneeCount(); for (int i = 0; i < owneeCount; ++i) { @@ -3974,7 +3866,6 @@ _Control::_Control(void) , __visibleState(true) , __initVisibleState(false) , __clipToParent(true) - , __focusSet(false) , __multiTouchEnabled(false) , __dragEnabled(false) , __dropEnabled(false) diff --git a/src/ui/FUi_ControlImpl.cpp b/src/ui/FUi_ControlImpl.cpp index bf25396..0049430 100644 --- a/src/ui/FUi_ControlImpl.cpp +++ b/src/ui/FUi_ControlImpl.cpp @@ -54,6 +54,7 @@ #include "FUiAnim_VisualElement.h" #include "FUiAnim_VisualElementImpl.h" #include "FUiCtrl_Popup.h" +#include "FUi_Window.h" //#define _TC_PASS @@ -3587,9 +3588,14 @@ _ControlImpl::SetFocusable(bool focusable) __focusableChangable, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The control can't chage it's focusable property."); - SysTryReturn(NID_UI, - focusable || GetCore().GetFocused() != &this->GetCore(), E_INVALID_OPERATION, - E_INVALID_OPERATION, "[E_INVALID_OPERATION] This already focused control cannot be unfocusable."); + _Window* pTop = GetCore().GetRootWindow(); + if (pTop) + { + SysTryReturn(NID_UI, + focusable || pTop->GetFocusControl() != &this->GetCore(), E_INVALID_OPERATION, + E_INVALID_OPERATION, "[E_INVALID_OPERATION] This already focused control cannot be unfocusable."); + } + GetCore().SetFocusable(focusable); return E_SUCCESS; diff --git a/src/ui/FUi_ControlManager.cpp b/src/ui/FUi_ControlManager.cpp index f164c9a..2d8ffab 100644 --- a/src/ui/FUi_ControlManager.cpp +++ b/src/ui/FUi_ControlManager.cpp @@ -304,7 +304,7 @@ _ControlManager::_ControlManager(void) // [ToDo] exception check. , __logicalCoordinateSystem(0) , __logicalBaseScreenSize(BASE_SCREEN_SIZE_NONE) , __pSystemWindowList(null) - , __pFocusedControl(null) + , __pFocusControl(null) , __screenRotation(_CONTROL_ROTATION_0) , __orientationStatus(_CONTROL_ROTATION_0) , __orientation(_CONTROL_ORIENTATION_PORTRAIT) @@ -1106,11 +1106,11 @@ _ControlManager::OnWindowRotated(int rotation) } void -_ControlManager::SetFocusedControl(const _Control& control, bool on) +_ControlManager::SetFocusControl(const _Control& control, bool on) { if (on) { - if (__pFocusedControl == &control) + if (__pFocusControl == &control) { return; } @@ -1118,17 +1118,13 @@ _ControlManager::SetFocusedControl(const _Control& control, bool on) _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred."); - _Control *pPreviousFocusedControl = __pFocusedControl; + _Control *pPreviousFocusedControl = __pFocusControl; if (pPreviousFocusedControl) { // [review] make SetFocus() return result and use the returned result here. pEcoreEvas->SetFocus(*pPreviousFocusedControl, false); if (GetLastResult() == E_SUCCESS) { - if (pPreviousFocusedControl) - { - pPreviousFocusedControl->SetFocusState(false); - } _UiFocusEvent event(pPreviousFocusedControl->GetHandle(), FOCUS_LOST); _UiEventManager::GetInstance()->SendEvent(event); } @@ -1143,14 +1139,14 @@ _ControlManager::SetFocusedControl(const _Control& control, bool on) if (GetLastResult() == E_SUCCESS) { - __pFocusedControl = const_cast<_Control*>(&control); + __pFocusControl = const_cast<_Control*>(&control); _UiFocusEvent event(control.GetHandle(), FOCUS_GAINED); _UiEventManager::GetInstance()->SendEvent(event); } } else { - if (__pFocusedControl != &control) + if (__pFocusControl != &control) { return; } @@ -1158,13 +1154,13 @@ _ControlManager::SetFocusedControl(const _Control& control, bool on) _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas(); SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] System error occurred."); - if (__pFocusedControl) + if (__pFocusControl) { // [review] make SetFocus() return result and use the returned result here. - pEcoreEvas->SetFocus(*__pFocusedControl, false); + pEcoreEvas->SetFocus(*__pFocusControl, false); if (GetLastResult() == E_SUCCESS) { - _UiFocusEvent event(__pFocusedControl->GetHandle(), FOCUS_LOST); + _UiFocusEvent event(__pFocusControl->GetHandle(), FOCUS_LOST); _UiEventManager::GetInstance()->SendEvent(event); } } @@ -1176,12 +1172,11 @@ _ControlManager::SetFocusedControl(const _Control& control, bool on) pEcoreEvas->SetFocus(*pTopWindow, true); if (GetLastResult() == E_SUCCESS) { - pTopWindow->SetFocusState(true); _UiFocusEvent event(pTopWindow->GetHandle(), FOCUS_GAINED); _UiEventManager::GetInstance()->SendEvent(event); } - __pFocusedControl = static_cast<_Control*>(pTopWindow); + __pFocusControl = static_cast<_Control*>(pTopWindow); } } } @@ -1191,10 +1186,10 @@ _ControlManager::SetFocusedControl(const _Control& control, bool on) bool _ControlManager::TakeFocusFromControl(const _Control& control) { - if (__pFocusedControl == &control) + if (__pFocusControl == &control) { - _Control *pPreviousFocusedControl = __pFocusedControl; - __pFocusedControl = null; + _Control *pPreviousFocusedControl = __pFocusControl; + __pFocusControl = null; _UiFocusEvent event(pPreviousFocusedControl->GetHandle(), FOCUS_LOST); _UiEventManager::GetInstance()->SendEvent(event); @@ -1205,9 +1200,9 @@ _ControlManager::TakeFocusFromControl(const _Control& control) } _Control* -_ControlManager::GetFocusedControl(void) const +_ControlManager::GetFocusControl(void) const { - return __pFocusedControl; + return __pFocusControl; } void diff --git a/src/ui/FUi_EflUiEventManager.cpp b/src/ui/FUi_EflUiEventManager.cpp index 629ef37..7d255b3 100644 --- a/src/ui/FUi_EflUiEventManager.cpp +++ b/src/ui/FUi_EflUiEventManager.cpp @@ -54,6 +54,7 @@ using namespace Tizen::Ui::Animations; using namespace Tizen::Graphics; using namespace Tizen::Base::Collection; using namespace Tizen::Base; +using namespace Tizen::Ui::Controls; namespace { @@ -357,7 +358,7 @@ private: _ControlManager* pControlManager = _ControlManager::GetInstance(); SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); - pControl = pControlManager->GetFocusedControl(); + pControl = pControlManager->GetFocusControl(); if (!pControl) { @@ -369,7 +370,7 @@ private: _ControlManager* pControlManager = _ControlManager::GetInstance(); SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); - pControl = pControlManager->GetFocusedControl(); + pControl = pControlManager->GetFocusControl(); if (!pControl) { pControl = pControlManager->GetCurrentFrame(); @@ -1414,7 +1415,7 @@ OnKeyboardInserted(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo _UiEventManager* pEventManager = _UiEventManager::GetInstance(); SysTryReturn(NID_UI, pEventManager, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] System error occurred."); - _Control* pControl = _ControlManager::GetInstance()->GetFocusedControl(); + _Control* pControl = _ControlManager::GetInstance()->GetFocusControl(); SysTryReturn(NID_UI, pControl, ECORE_CALLBACK_PASS_ON, E_SYSTEM, "[E_SYSTEM] System error occurred."); bool isKeyboardOn = false; @@ -1488,7 +1489,8 @@ OnWindowFocusIn(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) NativeWindowHandle nativeWindowHandle = pWindow->GetNativeHandle(); if (pEv->win == nativeWindowHandle) { - pFocusedControl = pWindow->GetFocused(); + pFocusedControl = pWindow->GetFocusControl(); + if (pFocusedControl) { pFocusedControl->SetFocused(); @@ -1512,7 +1514,7 @@ OnWindowFocusOut(void* pData __UNUSED__, int type __UNUSED__, void* pEventInfo) _ControlManager* pControlManager = _ControlManager::GetInstance(); SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred."); - _Control* pFocusedControl = pControlManager->GetFocusedControl(); + _Control* pFocusedControl = pControlManager->GetFocusControl(); if (pFocusedControl) { _Window* pRootWindow = pFocusedControl->GetRootWindow(); diff --git a/src/ui/FUi_FocusManagerImpl.cpp b/src/ui/FUi_FocusManagerImpl.cpp index 7e48d83..3a9f32b 100644 --- a/src/ui/FUi_FocusManagerImpl.cpp +++ b/src/ui/FUi_FocusManagerImpl.cpp @@ -107,7 +107,7 @@ _FocusManagerImpl::ReleaseInstance(void) _ControlImpl* _FocusManagerImpl::GetCurrentFocusOwner(void) const { - _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl(); + _Control* pFocus = _ControlManager::GetInstance()->GetFocusControl(); if(pFocus == null) { return null; @@ -123,7 +123,7 @@ _FocusManagerImpl::GetCurrentFocusOwner(void) const _WindowImpl* _FocusManagerImpl::GetCurrentFocusedWindow(void) const { - _Control* pFocus = _ControlManager::GetInstance()->GetFocusedControl(); + _Control* pFocus = _ControlManager::GetInstance()->GetFocusControl(); if(pFocus == null) { return null; @@ -178,12 +178,23 @@ _FocusManagerImpl::IsFocusable(_Control* pControl) const void _FocusManagerImpl::StartFocusTraversal(_Control* pControl, FocusDirection focusDirection) { + _Window* pTop = pControl->GetRootWindow(); + if (pTop) + { + _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(); + if (pFocusTraversalControl) + { + pControl = pTop->GetFocusTraversalControl(); + pControl->SetFocused(); + } + } + bool focusMode = pControl->IsFocusModeStateEnabled(); if (focusMode == false && pControl->IsFocused()) { if (IsFocusable(pControl)) { - __pCurrentFocusUiControl = pControl; + pTop->SetFocusTraversalControl(pControl); pControl->DrawFocus(); pControl->SetFocusModeStateEnabled(true); return; @@ -212,19 +223,10 @@ _FocusManagerImpl::StartFocusTraversal(_Control* pControl, FocusDirection focusD } IListT<_Control*>* pFocusControlList = null; - _Window* pTop = pControl->GetRootWindow(); + if (pTop) { - _Frame* pFrame = dynamic_cast<_Frame*>(pTop); - if (pFrame) - { - _Form* pForm = pFrame->GetCurrentForm(); - pFocusControlList = pForm->GetFocusList(); - } - else - { - pFocusControlList = pTop->GetFocusList(); - } + pFocusControlList = pTop->GetFocusList(); } if (pFocusControlList) @@ -273,7 +275,7 @@ _FocusManagerImpl::StartFocusTraversal(_Control* pControl, FocusDirection focusD index ++; } - __pCurrentFocusUiControl = pNextFocusControl; + pTop->SetFocusTraversalControl(pNextFocusControl); if (pNextFocusControl && findNextFocusControl == true) { _Control* pParentControl = pNextFocusControl->GetParent(); @@ -312,13 +314,19 @@ _FocusManagerImpl::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo bool _FocusManagerImpl::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo) -{ - if (__pCurrentFocusUiControl) +{ + _Window* pTop = source.GetRootWindow(); + if (pTop) { - __pCurrentFocusUiControl->RemoveFocusRing(); - __pCurrentFocusUiControl->SetFocusModeStateEnabled(false); - __pCurrentFocusUiControl = null; + _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(); + if (pFocusTraversalControl) + { + pFocusTraversalControl->RemoveFocusRing(); + pFocusTraversalControl->SetFocusModeStateEnabled(false); + pTop->SetFocusTraversalControl(null); + } } + return false; } diff --git a/src/ui/FUi_UiBuilderControlTable.cpp b/src/ui/FUi_UiBuilderControlTable.cpp index 272b343..59ac301 100644 --- a/src/ui/FUi_UiBuilderControlTable.cpp +++ b/src/ui/FUi_UiBuilderControlTable.cpp @@ -130,7 +130,7 @@ _UiBuilderControlTableManager::RegisterControl(const Tizen::Base::String& contro } else { - SysLogException(NID_UI, E_OUT_OF_MEMORY, "[kongp]Failed to CreateControl()"); + SysLogException(NID_UI, E_OUT_OF_MEMORY, "[UiBuilder] Failed to CreateControl()"); } SysLog(NID_UI, "[UiBuilder]Register success [%ls]", pUiBuilderControlTableInFomation->__controlMakerName.GetPointer()); diff --git a/src/ui/FUi_UiEventManager.cpp b/src/ui/FUi_UiEventManager.cpp index 3eea95c..5167dac 100644 --- a/src/ui/FUi_UiEventManager.cpp +++ b/src/ui/FUi_UiEventManager.cpp @@ -651,7 +651,7 @@ _UiEventManager::ProcessBubblingEvent(const Tizen::Base::Collection::LinkedListT _UiObjectHandle _UiEventManager::GetTarget(void) const { - _Control* pControl = _ControlManager::GetInstance()->GetFocusedControl(); + _Control* pControl = _ControlManager::GetInstance()->GetFocusControl(); SysTryReturn(NID_UI, pControl, _UiObjectHandle(), E_SYSTEM, "[E_SYSTEM] System error occurred."); return pControl->GetHandle(); diff --git a/src/ui/FUi_Window.cpp b/src/ui/FUi_Window.cpp index cc379fc..77333cb 100644 --- a/src/ui/FUi_Window.cpp +++ b/src/ui/FUi_Window.cpp @@ -454,26 +454,20 @@ _Window::OnActivated(void) bool isFrameActivated = _ControlManager::GetInstance()->IsFrameActivated(); SysLog(NID_UI, "frameActivated(%d)", isFrameActivated); - _Control* focusedControl = GetFocusedControl(); + _Control* focusedControl = GetFocusControl(); if (focusedControl) { focusedControl->SetFocused(); } - - if (!isFrameActivated) + else { - return; + SetFocused(); } - _Control* pFocus = GetFocused(); - if (pFocus) - { - pFocus->SetFocused(); - } - else + if (!isFrameActivated) { - SetFocused(); + return; } _TouchManager* pTouchMgr = _TouchManager::GetInstance(); @@ -833,7 +827,8 @@ _Window::_Window() , __systemWindow(false) , __isOpened(false) , __isInitialized(false) - , __pFocusedControl(null) + , __pFocusControl(null) + , __pFocusTraversalControl(null) , __transient(true) , __dimmingEnabled(false) , __rotation(-1) @@ -881,15 +876,15 @@ _Window::IsSystemWindow(void) const } void -_Window::SetFocusedControl(const _Control* pControl) +_Window::SetFocusControl(const _Control* pControl) { - __pFocusedControl = const_cast<_Control*>(pControl); + __pFocusControl = const_cast<_Control*>(pControl); } _Control* -_Window::GetFocusedControl(void) const +_Window::GetFocusControl(void) const { - return __pFocusedControl; + return __pFocusControl; } IListT<_Control*>* @@ -950,4 +945,14 @@ _Window::IsOrientationCallbackModeEnabled(void) const return __orientationCallbackMode; } +_Control* +_Window::GetFocusTraversalControl(void) const +{ + return __pFocusTraversalControl; +} +void +_Window::SetFocusTraversalControl(_Control* pControl) +{ + __pFocusTraversalControl = pControl; +} }} // Tizen::Ui diff --git a/src/ui/controls/FUiCtrl_EditPresenter.cpp b/src/ui/controls/FUiCtrl_EditPresenter.cpp index 59dbbc6..47a38ce 100755 --- a/src/ui/controls/FUiCtrl_EditPresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditPresenter.cpp @@ -65,6 +65,7 @@ #include "FUiCtrl_ScrollPanel.h" #include "FUiCtrl_Toolbar.h" #include "FUiCtrl_TableView.h" +#include "FUi_Window.h" using namespace Tizen::Base::Runtime; @@ -9603,9 +9604,13 @@ _EditPresenter::SetFocused(void) bool focused = true; if (__pParentPanel) { - if ((__pParentPanel->GetFocused() != __pEdit) && IsInternalFocused() == false) + _Window* pTop = __pParentPanel->GetRootWindow(); + if (pTop) { - focused = false; + if ((pTop->GetFocusControl() != __pEdit) && IsInternalFocused() == false) + { + focused = false; + } } } else if (IsInternalFocused() == false) diff --git a/src/ui/controls/FUiCtrl_Form.cpp b/src/ui/controls/FUiCtrl_Form.cpp index 9523859..7082118 100644 --- a/src/ui/controls/FUiCtrl_Form.cpp +++ b/src/ui/controls/FUiCtrl_Form.cpp @@ -84,6 +84,8 @@ _Form::_Form(void) , __keypadShowstate(false) , __clipboardShowstate(false) , __pFormOrientationstatusEventListener(null) + , __pFocusControl(null) + , __pFocusTraversalControl(null) { Color color; result r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color); @@ -3297,6 +3299,18 @@ _Form::GetFocusList(void) const } void +_Form::SetFocusControl(const _Control* pControl) +{ + __pFocusControl = const_cast<_Control*>(pControl); +} + +_Control* +_Form::GetFocusControl(void) const +{ + return __pFocusControl; +} + +void _Form::ResetFocusList(void) { if(__pFocusControlList) @@ -3422,4 +3436,14 @@ _Form::GetFormOrientationStatus(void) const return ORIENTATION_STATUS_PORTRAIT; } +_Control* +_Form::GetFocusTraversalControl(void) const +{ + return __pFocusTraversalControl; +} +void +_Form::SetFocusTraversalControl(_Control* pControl) +{ + __pFocusTraversalControl = pControl; +} }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_Frame.cpp b/src/ui/controls/FUiCtrl_Frame.cpp index 6334c26..2f4de36 100644 --- a/src/ui/controls/FUiCtrl_Frame.cpp +++ b/src/ui/controls/FUiCtrl_Frame.cpp @@ -188,10 +188,10 @@ _Frame::OnActivated(void) pCurrentForm->AddIndicatorObject(); - _Control* pFocusedControl = pCurrentForm->GetFocused(); - if (pFocusedControl) + _Control* pFocusControl = pCurrentForm->GetFocusControl(); + if (pFocusControl) { - pFocusedControl->SetFocused(); + pFocusControl->SetFocused(); } else { @@ -368,6 +368,11 @@ _Frame::SetCurrentForm(const _Form* pForm) { if (pCurrentForm != pForm) { + _Control* pFocusTraversalControl = pCurrentForm->GetFocusTraversalControl(); + if (pFocusTraversalControl) + { + pFocusTraversalControl->SetFocusModeStateEnabled(false) ; + } // Change order r = MoveChildToTop(*pForm); SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); @@ -381,7 +386,7 @@ _Frame::SetCurrentForm(const _Form* pForm) } } - _Control* pFocus = pNewForm->GetFocused(); + _Control* pFocus = pNewForm->GetFocusControl(); if (pFocus) { pFocus->SetFocused(); @@ -624,6 +629,15 @@ _Frame::OnChildAttached(const _Control& child) _Control* pOldCurrentForm = GetChild(controlCount - 2); SysTryReturnVoidResult(NID_UI_CTRL, pOldCurrentForm != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); pOldCurrentForm->SetVisibleState(false); + _Form* pOldForm = static_cast<_Form*>(pOldCurrentForm); + if (pOldForm) + { + _Control* pFocusTraversalControl = pOldForm->GetFocusTraversalControl(); + if (pFocusTraversalControl) + { + pFocusTraversalControl->SetFocusModeStateEnabled(false) ; + } + } } } } @@ -791,4 +805,58 @@ _Frame::ResetFocusList(void) pCurrentForm->ResetFocusList(); } } + +_Control* +_Frame::GetFocusControl(void) const +{ + _Form* pForm = GetCurrentForm(); + if (pForm) + { + return pForm->GetFocusControl(); + } + return null; +} + +void +_Frame::SetFocusControl(const _Control* pControl) +{ + _Form* pForm = GetCurrentForm(); + if (pForm) + { + pForm->SetFocusControl(pControl); + } +} + + +Tizen::Base::Collection::IListT<_Control*>* +_Frame::GetFocusList(void) const +{ + _Form* pForm = GetCurrentForm(); + if (pForm) + { + return pForm->GetFocusList(); + } + return null; +} + +_Control* +_Frame::GetFocusTraversalControl(void) const +{ + _Form* pForm = GetCurrentForm(); + if (pForm) + { + return pForm->GetFocusTraversalControl(); + } + return null; +} + +void +_Frame::SetFocusTraversalControl(_Control* pControl) +{ + _Form* pForm = GetCurrentForm(); + if (pForm) + { + pForm->SetFocusTraversalControl(pControl); + } +} }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_TableViewItem.cpp b/src/ui/controls/FUiCtrl_TableViewItem.cpp index 96ecfe5..af8a32b 100644 --- a/src/ui/controls/FUiCtrl_TableViewItem.cpp +++ b/src/ui/controls/FUiCtrl_TableViewItem.cpp @@ -33,6 +33,7 @@ #include "FUi_CoordinateSystemUtils.h" #include "FUi_Math.h" #include "FUiCtrl_LabelImpl.h" +#include "FUi_Window.h" using namespace Tizen::Base; using namespace Tizen::Base::Runtime; @@ -4590,7 +4591,12 @@ bool _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) { _KeyCode keyCode = keyInfo.GetKeyCode(); - _Control* pFocusedControl = GetFocused(); + _Control* pFocusedControl = null; + _Window* pTop = source.GetRootWindow(); + if (pTop) + { + pFocusedControl = pTop->GetFocusControl(); + } _Control* pChildControl = null; switch (keyCode) diff --git a/src/ui/controls/FUiCtrl_TableViewPresenter.cpp b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp index 9ced5cc..af88fc9 100644 --- a/src/ui/controls/FUiCtrl_TableViewPresenter.cpp +++ b/src/ui/controls/FUiCtrl_TableViewPresenter.cpp @@ -36,11 +36,13 @@ #include "FUiCtrl_TableViewItemProviderAdaptor.h" #include "FUi_CoordinateSystemUtils.h" #include "FUi_Math.h" +#include "FUi_Window.h" using namespace Tizen::Ui::Animations; using namespace Tizen::Graphics; using namespace Tizen::Base; using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui::Controls; namespace Tizen { namespace Ui { namespace Controls { @@ -5224,7 +5226,13 @@ bool _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo) { _KeyCode keyCode = keyInfo.GetKeyCode(); - _Control* pFocusedControl = __pTableView->GetFocused(); + _Control* pFocusedControl = null; + _Window* pTop = source.GetRootWindow(); + if (pTop) + { + pFocusedControl = pTop->GetFocusControl(); + } + _TableView* pTableView = null; _TableViewItem* pItem = null; TableViewItemTag itemPos = {-1, -1}; diff --git a/src/ui/inc/FUiCtrl_Form.h b/src/ui/inc/FUiCtrl_Form.h index 82de4b8..23907fe 100644 --- a/src/ui/inc/FUiCtrl_Form.h +++ b/src/ui/inc/FUiCtrl_Form.h @@ -224,6 +224,12 @@ public: // Focus UI Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const; void ResetFocusList(void); + _Control* GetFocusTraversalControl(void) const; + void SetFocusTraversalControl(_Control* pControl); + +// Focus + _Control* GetFocusControl(void) const; + void SetFocusControl(const _Control* pControl); // Accessor protected: @@ -302,7 +308,8 @@ private: //For Focus UI mutable std::unique_ptr > __pFocusControlList; - + _Control* __pFocusControl; + _Control* __pFocusTraversalControl; friend class _Frame; friend class _OverlayRegionImpl; }; // _Form diff --git a/src/ui/inc/FUiCtrl_Frame.h b/src/ui/inc/FUiCtrl_Frame.h index 52ca7a2..c512913 100644 --- a/src/ui/inc/FUiCtrl_Frame.h +++ b/src/ui/inc/FUiCtrl_Frame.h @@ -90,6 +90,13 @@ public: // Focus Ui virtual void ResetFocusList(void); + virtual Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const; + virtual _Control* GetFocusTraversalControl(void) const; + virtual void SetFocusTraversalControl(_Control* pControl); + +// Focus + virtual _Control* GetFocusControl(void) const; + virtual void SetFocusControl(const _Control* pControl); protected: result SetPresenter(const _FramePresenter& framePresenter); diff --git a/src/ui/inc/FUi_Control.h b/src/ui/inc/FUi_Control.h index f1bfc59..57dba26 100644 --- a/src/ui/inc/FUi_Control.h +++ b/src/ui/inc/FUi_Control.h @@ -417,9 +417,7 @@ public: bool IsFocusable(void) const; void SetFocusable(bool focusable); bool IsFocused(void) const; - _Control* GetFocused(void) const; result SetFocused(bool on = true); - void SetFocusState(bool on); bool IsNativeObjectFocusable(void) const; void SetNativeObjectFocusable(bool focusable); @@ -648,7 +646,6 @@ private: bool __visibleState; bool __initVisibleState; bool __clipToParent; - bool __focusSet; bool __multiTouchEnabled; bool __dragEnabled; bool __dropEnabled; diff --git a/src/ui/inc/FUi_ControlManager.h b/src/ui/inc/FUi_ControlManager.h index e3b568f..06bcc7c 100644 --- a/src/ui/inc/FUi_ControlManager.h +++ b/src/ui/inc/FUi_ControlManager.h @@ -100,8 +100,8 @@ public: Tizen::Graphics::_BaseScreenSize GetLogicalBaseScreenSize(void) const; // Focus - _Control* GetFocusedControl(void) const; - void SetFocusedControl(const _Control& control, bool on = true); + _Control* GetFocusControl(void) const; + void SetFocusControl(const _Control& control, bool on = true); bool TakeFocusFromControl(const _Control& control); // Queries @@ -164,7 +164,7 @@ private: int __logicalCoordinateSystem; Tizen::Graphics::_BaseScreenSize __logicalBaseScreenSize; Tizen::Base::Collection::LinkedListT<_Window*>* __pSystemWindowList; - _Control* __pFocusedControl; + _Control* __pFocusControl; _ControlRotation __screenRotation; _ControlRotation __orientationStatus; _ControlOrientation __orientation; diff --git a/src/ui/inc/FUi_Window.h b/src/ui/inc/FUi_Window.h index d9aa69a..6e11779 100644 --- a/src/ui/inc/FUi_Window.h +++ b/src/ui/inc/FUi_Window.h @@ -86,8 +86,8 @@ public: _WindowType GetWindowType(void); // Focus - _Control* GetFocusedControl(void) const; - void SetFocusedControl(const _Control* pControl); + virtual _Control* GetFocusControl(void) const; + virtual void SetFocusControl(const _Control* pControl); // Callbacks virtual void OnActivated(void); virtual void OnNativeWindowActivated(void); @@ -119,8 +119,10 @@ public: bool IsSystemWindow(void) const; // Focus UI - Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const; + virtual Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const; virtual void ResetFocusList(void); + virtual _Control* GetFocusTraversalControl(void) const; + virtual void SetFocusTraversalControl(_Control* pControl); // Dimming result SetDimmingEnabled(bool enabled); @@ -165,7 +167,8 @@ private: bool __systemWindow; bool __isOpened; bool __isInitialized; - _Control* __pFocusedControl; + _Control* __pFocusControl; + _Control* __pFocusTraversalControl; bool __transient; bool __dimmingEnabled;