From da3fb2b43772252d62d6e5fd062cd1e78c0a3254 Mon Sep 17 00:00:00 2001 From: "keonpyo.kong" Date: Tue, 26 Mar 2013 22:57:26 +0900 Subject: [PATCH] Add _Window Focus List Change-Id: Ib4f5672e982878a7b1dd47ce75d7df283fcf88c3 Signed-off-by: keonpyo.kong --- src/ui/FUi_FocusManagerImpl.cpp | 101 +++++++++++++++++++++------------------- src/ui/FUi_Window.cpp | 13 ++++++ src/ui/inc/FUi_Window.h | 8 ++++ 3 files changed, 73 insertions(+), 49 deletions(-) diff --git a/src/ui/FUi_FocusManagerImpl.cpp b/src/ui/FUi_FocusManagerImpl.cpp index 7a6467a..b643ab7 100644 --- a/src/ui/FUi_FocusManagerImpl.cpp +++ b/src/ui/FUi_FocusManagerImpl.cpp @@ -30,6 +30,8 @@ #include "FUi_UiEventManager.h" #include "FUi_ResourceManager.h" #include "FUi_UiKeyEvent.h" +#include "FUi_Window.h" +#include "FUiCtrl_Frame.h" using namespace std; using namespace Tizen::Base::Collection; @@ -180,73 +182,74 @@ _FocusManagerImpl::StartFocusTraversal(_Control* pControl, FocusDirection focusD } } - _Form* pForm = null; - _Control* pParentControl = pControl; - - while(pControl) + IListT<_Control*>* pFocusControlList = null; + _Window* pTop = pControl->GetRootWindow(); + if (pTop) { - pForm = dynamic_cast<_Form*>(pParentControl); - - if (pForm != null) + _Frame* pFrame = dynamic_cast<_Frame*>(pTop); + if (pFrame) { - break; + _Form* pForm = pFrame->GetCurrentForm(); + pFocusControlList = pForm->GetFocusList(); } else { - pParentControl = pParentControl->GetParent(); + pFocusControlList = pTop->GetFocusList(); } - } + } - IListT<_Control*>* pFocusControlList = pForm->GetFocusList(); - unique_ptr > pEnum (pFocusControlList->GetEnumeratorN()); - - int index = 0; - bool findNextFocusControl = false; - _Control* pFocusControl = null; - while (pEnum->MoveNext() == E_SUCCESS) + if (pFocusControlList) { - _Control* pEnumeratorControl = null; - pEnum->GetCurrent(pEnumeratorControl); - - //Find current focused control - if (pControl == pEnumeratorControl) - { - //Find next focusable control. - index = GetNextIndex(index, focusDirection, pFocusControlList); - while (pFocusControlList->GetAt(index, pFocusControl) == E_SUCCESS) + unique_ptr > pEnum (pFocusControlList->GetEnumeratorN()); + SysTryReturnVoidResult(NID_UI_CTRL, pEnum, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + int index = 0; + bool findNextFocusControl = false; + _Control* pFocusControl = null; + while (pEnum->MoveNext() == E_SUCCESS) { - bool isFocusalbe = pFocusControl->IsFocusable(); - bool enableState = pFocusControl->GetEnableState(); - bool visibleState = pFocusControl->GetVisibleState(); - if (enableState == true && visibleState == true && isFocusalbe == true) + _Control* pEnumeratorControl = null; + pEnum->GetCurrent(pEnumeratorControl); + + //Find current focused control + if (pControl == pEnumeratorControl) { - pFocusControl->SetFocused(); - findNextFocusControl = true; - break; + //Find next focusable control. + index = GetNextIndex(index, focusDirection, pFocusControlList); + while (pFocusControlList->GetAt(index, pFocusControl) == E_SUCCESS) + { + bool isFocusalbe = pFocusControl->IsFocusable(); + bool enableState = pFocusControl->GetEnableState(); + bool visibleState = pFocusControl->GetVisibleState(); + if (enableState == true && visibleState == true && isFocusalbe == true) + { + pFocusControl->SetFocused(); + findNextFocusControl = true; + break; + } + else + { + index = GetNextIndex(index, focusDirection, pFocusControlList); + } } - else + } + + if (findNextFocusControl == true) { - index = GetNextIndex(index, focusDirection, pFocusControlList); + break; } - } - } - if (findNextFocusControl == true) - { - break; + index ++; } - index ++; - } - - if (pFocusControl && findNextFocusControl == true) - { - _Control* pParentControl = pFocusControl->GetParent(); - if (pParentControl) + if (pFocusControl && findNextFocusControl == true) { - pParentControl->OnChildControlFocusMoved(*pFocusControl); + _Control* pParentControl = pFocusControl->GetParent(); + if (pParentControl) + { + pParentControl->OnChildControlFocusMoved(*pFocusControl); + } + pFocusControl->DrawFocus(); } - pFocusControl->DrawFocus(); } } diff --git a/src/ui/FUi_Window.cpp b/src/ui/FUi_Window.cpp index a468ad6..e3cc7a4 100644 --- a/src/ui/FUi_Window.cpp +++ b/src/ui/FUi_Window.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "FUi_Window.h" #include "FUi_ControlManager.h" #include "FUi_TouchManager.h" @@ -707,4 +708,16 @@ _Window::GetFocusedControl(void) const { return __pFocusedControl; } + +IListT<_Control*>* +_Window::GetFocusList(void) const +{ + if(!__pFocusControlList) + { + __pFocusControlList.reset(GetFocusListN()); + __pFocusControlList->InsertAt(const_cast<_Window*>(this), 0); + } + return __pFocusControlList.get(); +} + }} // Tizen::Ui diff --git a/src/ui/inc/FUi_Window.h b/src/ui/inc/FUi_Window.h index 31b0ff3..48d2d51 100644 --- a/src/ui/inc/FUi_Window.h +++ b/src/ui/inc/FUi_Window.h @@ -25,6 +25,7 @@ #ifndef _FUI_INTERNAL_WINDOW_H_ #define _FUI_INTERNAL_WINDOW_H_ +#include #include #include "FUi_Control.h" @@ -108,6 +109,9 @@ public: result SetZOrderGroup(int windowZOrderGroup); bool IsSystemWindow(void) const; + // Focus UI + Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const; + protected: _Window(void); _IWindowDelegate& GetWindowDelegate(void) const; @@ -141,6 +145,10 @@ private: bool __isInitialized; _Control* __pFocusedControl; bool __transient; + + //For Focus UI + mutable std::unique_ptr > __pFocusControlList; + #if !defined(WINDOW_BASE_ROTATE) bool __orientationEnabled; #else -- 2.7.4