Add _Window Focus List
authorkeonpyo.kong <keonpyo.kong@samsung.com>
Tue, 26 Mar 2013 13:57:26 +0000 (22:57 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 27 Mar 2013 10:32:07 +0000 (19:32 +0900)
Change-Id: Ifb9de8585d257a25c81c91926b3bf3884f491f1b
Signed-off-by: keonpyo.kong <keonpyo.kong@samsung.com>
src/ui/FUi_FocusManagerImpl.cpp
src/ui/FUi_Window.cpp
src/ui/inc/FUi_Window.h

index 7a6467a..b643ab7 100644 (file)
@@ -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<IEnumeratorT<_Control*> > 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<IEnumeratorT<_Control*> > 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();
        }
 }
 
index a468ad6..e3cc7a4 100644 (file)
@@ -24,6 +24,7 @@
 #include <FUiAnimDisplayContext.h>
 #include <FUiWindow.h>
 #include <FBase_Log.h>
+#include <FBaseColArrayListT.h>
 #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
index 31b0ff3..48d2d51 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef _FUI_INTERNAL_WINDOW_H_
 #define _FUI_INTERNAL_WINDOW_H_
 
+#include <unique_ptr.h>
 #include <FUiWindow.h>
 #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<Tizen::Base::Collection::IListT<_Control*> > __pFocusControlList;
+       
 #if !defined(WINDOW_BASE_ROTATE)
        bool __orientationEnabled;
 #else