modified focus ui in TableView
authorminsung <minsung.jin@samsung.com>
Fri, 7 Jun 2013 11:58:52 +0000 (17:28 +0530)
committerminsung <minsung.jin@samsung.com>
Fri, 7 Jun 2013 11:59:12 +0000 (17:29 +0530)
Change-Id: I7912c4ec15642a6e9c871e6ecb08f8d75ca6095d
Signed-off-by: minsung <minsung.jin@samsung.com>
src/ui/controls/FUiCtrl_TableView.cpp
src/ui/controls/FUiCtrl_TableViewItem.cpp
src/ui/controls/FUiCtrl_TableViewPresenter.cpp
src/ui/inc/FUiCtrl_TableView.h
src/ui/inc/FUiCtrl_TableViewPresenter.h

index bf30055..ab68dbd 100644 (file)
@@ -1383,4 +1383,16 @@ _TableView::IsChildControlFocusManage(void) const
 {
        return true;
 }
+
+void
+_TableView::OnDrawFocus(void)
+{
+       return __pTableViewPresenter->OnDrawFocus();
+}
+
+void
+_TableView::OnFocusModeStateChanged(void)
+{
+       return __pTableViewPresenter->OnFocusModeStateChanged();
+}
 }}} // Tizen::Ui::Controls
index af8a32b..eaace57 100644 (file)
@@ -3638,7 +3638,6 @@ _TableViewItem::SetSectionHeaderFooterContents(const Tizen::Base::String& text,
                        positionY = GetBoundsF().height - contentsHeight;
                }
                __pHeaderFooterItemText->Construct(FloatRectangle(0.0f, positionY, GetBoundsF().width, contentsHeight), text);
-
                __pHeaderFooterItemText->SetTextHorizontalAlignment(alignment);
                __pHeaderFooterItemText->SetTextColor(textColor);
                __pHeaderFooterItemText->SetBackgroundColor(Color(0, 0, 0, 0));
@@ -4590,28 +4589,171 @@ _TableViewItem::OnAccessibilityValueDecreased(const _AccessibilityContainer& con
 bool
 _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 {
-        _KeyCode keyCode = keyInfo.GetKeyCode();
-        _Control* pFocusedControl = null;
+       _KeyCode keyCode = keyInfo.GetKeyCode();
+       IListT<_Control*>* pFocusList = GetFocusListN();
+       _Control* pChildControl = null;
+       _Control* pFocusedControl = null;
        _Window* pTop = source.GetRootWindow();
+
        if (pTop)
        {
                pFocusedControl = pTop->GetFocusControl();
        }
-        _Control* pChildControl = null;
 
-        switch (keyCode)
-        {
-        case _KEY_LEFT:
-                if (pFocusedControl != null)
-                {
-                        pChildControl = GetPreviousFocusChildControl(*pFocusedControl);
-                }
-                break;
+       int count  = pFocusList->GetCount();
+
+       if (pFocusedControl == null)
+       {
+                 return false;
+       }
+
+       switch (keyCode)
+       {
+       case _KEY_LEFT:
+               if (pFocusList == null)
+               {
+                       break;
+               }
+
+               if (IsFocused() == false)
+               {
+                       for(int i=0; i<count; i++)
+                       {
+                               pFocusList->GetAt(i, pChildControl);
+                               if (pChildControl == null)
+                               {
+                                       continue;
+                               }
+
+                               if (pChildControl->IsFocused())
+                               {
+                                       if (i == count -1)
+                                       {
+                                               pChildControl = null;
+                                               break;
+                                       }
+
+                                       for (int j=i+1; j<count; j++)
+                                       {
+                                               pFocusList->GetAt(j, pChildControl);
+                                               if (pChildControl == null)
+                                               {
+                                                       continue;
+                                               }
+
+                                               if (pChildControl->IsFocusable())
+                                               {
+                                                       break;
+                                               }
+                                               else
+                                               {
+                                                       pChildControl = null;
+                                               }
+                                       }
+                                       break;
+                               }
+                       }
+               }
+
+               if (pChildControl == null)
+               {
+                       for (int i=0; i<count; i++)
+                       {
+                               pFocusList->GetAt(i, pChildControl);
+                               if (pChildControl == null)
+                               {
+                                       continue;
+                               }
+
+                               if (pChildControl->IsFocusable())
+                               {
+                                       break;
+                               }
+                               else
+                               {
+                                       pChildControl = null;
+                               }
+                       }
+               }
+
+               if (pChildControl)
+               {
+                       pChildControl->SetFocused(true);
+                       pChildControl->DrawFocus();
+               }
+               break;
 
        case _KEY_RIGHT:
-               if (pFocusedControl != null)
+               if (pFocusList == null)
+               {
+                       break;
+               }
+
+               if (IsFocused() == false)
+               {
+                       for(int i=count-1; i>=0; i--)
+                       {
+                               pFocusList->GetAt(i, pChildControl);
+                               if (pChildControl == null)
+                               {
+                                       continue;
+                               }
+
+                               if (pChildControl->IsFocused())
+                               {
+                                       if (i == 0)
+                                       {
+                                               pChildControl = null;
+                                               break;
+                                       }
+
+                                       for(int j=i-1; j>=0; j--)
+                                       {
+                                               pFocusList->GetAt(j, pChildControl);
+                                               if (pChildControl == null)
+                                               {
+                                                       continue;
+                                               }
+
+                                               if (pChildControl->IsFocusable())
+                                               {
+                                                       break;
+                                               }
+                                               else
+                                               {
+                                                       pChildControl = null;
+                                               }
+                                       }
+                                       break;
+                               }
+                       }
+               }
+
+               if (pChildControl == null)
+               {
+                       for (int i=count-1; i>=0; i--)
+                       {
+                               pFocusList->GetAt(i, pChildControl);
+                               if (pChildControl == null)
+                               {
+                                       continue;
+                               }
+
+                               if (pChildControl->IsFocusable())
+                               {
+                                       break;
+                               }
+                               else
+                               {
+                                       pChildControl = null;
+                               }
+                       }
+               }
+
+               if (pChildControl)
                {
-                       pChildControl = GetNextFocusChildControl(*pFocusedControl);
+                       pChildControl->SetFocused(true);
+                       pChildControl->DrawFocus();
                }
                break;
 
@@ -4640,23 +4782,6 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                return false;
        }
 
-       if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
-       {
-               if (pFocusedControl != null)
-               {
-                       if (pChildControl)
-                       {
-                               pChildControl->SetFocused(true);
-                               pChildControl->DrawFocus();
-                       }
-                       else
-                       {
-                               _Control* pParentControl = pFocusedControl->GetParent();
-                               pParentControl->SetFocused(true);
-                               pParentControl->DrawFocus();
-                       }
-               }
-       }
        return true;
 }
 
index da1a8fb..d6a7db9 100644 (file)
@@ -5267,17 +5267,6 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                         pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex);
                                         if (GetPreviousItemPosition(itemPos, itemPos))
                                         {
-                                                _Control* pChildControl = null;
-                                                int childControlCount = pItem->GetChildCount();
-                                                for (int i=0; i<childControlCount; i++)
-                                                {
-                                                        pChildControl = pItem->GetChild(i);
-                                                        if (pChildControl != null)
-                                                        {
-                                                                pChildControl->OnFocusLost(*pChildControl);
-                                                        }
-                                                }
-
                                                 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
                                                 {
                                                         TableViewItemTag firstItemPos = {-1, -1};
@@ -5360,17 +5349,6 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                         pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex);
                                         if (GetNextItemPosition(itemPos, itemPos))
                                         {
-                                                _Control* pChildControl = null;
-                                                int childControlCount = pItem->GetChildCount();
-                                                for (int i=0; i<childControlCount; i++)
-                                                {
-                                                        pChildControl = pItem->GetChild(i);
-                                                        if (pChildControl != null)
-                                                        {
-                                                                pChildControl->OnFocusLost(*pChildControl);
-                                                        }
-                                                }
-
                                                 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE && itemPos.itemIndex == -1)
                                                 {
                                                         itemPos.itemIndex = 0;
@@ -5430,6 +5408,60 @@ _TableViewPresenter::OnKeyReleased(const _Control& source, const _KeyInfo& keyIn
        return false;
 }
 
+void
+_TableViewPresenter::OnDrawFocus(void)
+{
+        _Control* pFocusedControl = null;
+       _Window* pTop = __pTableView->GetRootWindow();
+       if (pTop)
+       {
+               pFocusedControl = pTop->GetFocusControl();
+       }
+
+       _TableView* pTableView = null;
+       _TableViewItem* pItem = null;
+       TableViewItemTag itemPos = {-1, -1};
+
+        if (pFocusedControl != null)
+        {
+                pTableView = dynamic_cast<_TableView*>(pFocusedControl);
+                if (pTableView != null)
+                {
+                        GetFirstItem(itemPos);
+                        if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
+                        {
+                                itemPos.itemIndex = 0;
+                        }
+
+                        ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
+                        pItem = FindItem(itemPos);
+                        if (pItem != null)
+                        {
+                                pItem->SetFocused(true);
+                                pItem->DrawFocus();
+                        }
+                }
+        }
+}
+
+void
+_TableViewPresenter::OnFocusModeStateChanged(void)
+{
+        _Control* pFocusedControl = null;
+       _Window* pTop = __pTableView->GetRootWindow();
+       if (pTop)
+       {
+               pFocusedControl = pTop->GetFocusControl();
+       }
+
+       _TableViewItem* pItem = null;
+        pItem = dynamic_cast<_TableViewItem*>(pFocusedControl);
+        if (pItem != null)
+        {
+                pItem->SetFocused(false);
+        }
+}
+
 bool
 _TableViewPresenter::GetAccessibilityElementFocusedState(void)
 {
index 608a33d..d8ab3f0 100644 (file)
@@ -236,6 +236,8 @@ public:
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
        virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
        virtual bool IsChildControlFocusManage(void) const;
+       virtual void OnDrawFocus(void);
+       virtual void OnFocusModeStateChanged(void);
 
 protected:
        // Properties
index 8360e0e..2054ed1 100644 (file)
@@ -188,6 +188,8 @@ public:
        // Focus Ui
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
        virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+       virtual void OnDrawFocus(void);
+       virtual void OnFocusModeStateChanged(void);
 
        void Dispose(void);