N_SE 47881 - Restore Focus after OnOrientationChange() in ListView()
authorkatpaga.a <katpaga.a@samsung.com>
Fri, 2 Aug 2013 14:11:11 +0000 (19:41 +0530)
committerkatpaga.a <katpaga.a@samsung.com>
Wed, 7 Aug 2013 13:31:25 +0000 (19:01 +0530)
Change-Id: I5338e7c55129d32a15591acbb7715bb62fa24af8
Signed-off-by: katpaga.a <katpaga.a@samsung.com>
src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp
src/ui/controls/FUiCtrl_ListViewImpl.cpp
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_TableViewItem.h
src/ui/inc/FUiCtrl_TableViewPresenter.h

index d5a5230..78bfde5 100644 (file)
@@ -1935,6 +1935,10 @@ _GroupedListViewImpl::OnBoundsChanged(void)
 
        if (__isOrientationChanged)
        {
+               if (GetCore().IsTableViewFocused())
+               {
+                       GetCore().RestoreFocus(true);
+               }
                __isOrientationChanged = false;
                UpdateList();
        }
index 93f411e..b9dc6cb 100644 (file)
@@ -1795,6 +1795,10 @@ _ListViewImpl::OnBoundsChanged(void)
        if (__isOrientationChanged)
        {
                __isOrientationChanged = false;
+               if (GetCore().IsTableViewFocused())
+               {
+                       GetCore().RestoreFocus(true);
+               }
                UpdateList();
        }
 }
index 5d8b30d..1019042 100644 (file)
@@ -315,6 +315,30 @@ _TableView::SetReorderModeEnabled(bool enable)
        return E_SUCCESS;
 }
 
+void
+_TableView::RestoreFocus(bool isRestoreFocus)
+{
+       return __pTableViewPresenter->RestoreFocus(isRestoreFocus);
+}
+
+void
+_TableView::SetAnnexFocused(bool isAnnexFocused)
+{
+       return __pTableViewPresenter->SetAnnexFocused(isAnnexFocused);
+}
+
+void
+_TableView::SetTableViewFocused(bool focusStatus)
+{
+       return __pTableViewPresenter->SetTableViewFocused(focusStatus);
+}
+
+bool
+_TableView::IsTableViewFocused(void)
+{
+       return __pTableViewPresenter->IsTableViewFocused();
+}
+
 result
 _TableView::SetItemChecked(int groupIndex, int itemIndex, bool check)
 {
@@ -1332,6 +1356,14 @@ _TableView::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
 }
 
 bool
+_TableView::OnFocusGained(const _Control& source)
+{
+       __pTableViewPresenter->SetTableViewFocused(true);
+
+       return true;
+}
+
+bool
 _TableView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
 {
        return __pTableViewPresenter->OnFlickGestureDetected(gesture);
index 2639eb2..2539ffc 100644 (file)
@@ -1108,6 +1108,16 @@ _TableViewItem::GetItemTapSoundEnabled(void)
        return __isItemTapSoundEnabled;
 }
 
+void
+_TableViewItem::DrawAnnexFocus(void)
+{
+       if (__pItemAnnex)
+       {
+               __pItemAnnex->SetFocus();
+       }
+       return;
+}
+
 Tizen::Graphics::Canvas*
 _TableViewItem::OnCanvasRequestedN(const Tizen::Graphics::FloatRectangle& bounds)
 {
@@ -4882,7 +4892,7 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        {
                return false;
        }
-
+       _TableView* pParent = dynamic_cast<_TableView*>(GetParent());
        _KeyCode keyCode = keyInfo.GetKeyCode();
        IListT<_Control*>* pFocusList = GetFocusListN();
        SysTryReturn(NID_UI_CTRL, pFocusList != null, true, GetLastResult(), "[%s] propagating.", GetErrorMessage(GetLastResult()));
@@ -4949,6 +4959,10 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                        if (pChildControl && pChildControl->GetEnableState()
                                        && pChildControl->GetVisibleState() && pChildControl->IsFocusable())
                        {
+                               if (pParent != null)
+                               {
+                                       pParent->SetAnnexFocused(true);
+                               }
                                pChildControl->SetFocused(true);
                                pChildControl->DrawFocus();
                        }
@@ -4960,6 +4974,10 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                                if (pItem != null && pItem->GetEnableState() && !pItem->IsFocused()
                                                && pItem->GetVisibleState() && pItem->IsFocusable())
                                {
+                                       if (pParent != null)
+                                       {
+                                               pParent->SetAnnexFocused(false);
+                                       }
                                        pItem->SetFocused(true);
                                        pItem->DrawFocus();
                                }
@@ -5036,6 +5054,10 @@ _TableViewItem::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
                if (pChildControl && pChildControl->GetEnableState() && pChildControl->GetVisibleState()
                                && pChildControl->IsFocusable())
                {
+                       if (pParent != null)
+                       {
+                               pParent->SetAnnexFocused(true);
+                       }
                        pChildControl->SetFocused(true);
                        pChildControl->DrawFocus();
                }
index 969432c..4ea0214 100644 (file)
@@ -77,6 +77,8 @@ _TableViewPresenter::_TableViewPresenter()
        , __scrollPositionOnFlickStarted(0)
        , __isAnimationCallbackBlocked(false)
        , __lockLoadItemWithScroll(false)
+       , __isRestoreFocus(false)
+       , __isAnnexFocused(false)
        , __itemTouchReleasedEventState(TABLE_VIEW_ITEM_TOUCH_RELEASED_EVENT_NORMAL)
        , __scrollToItemTag()
 {
@@ -88,6 +90,9 @@ _TableViewPresenter::_TableViewPresenter()
 
        __expandableItemTag.groupIndex = -1;
        __expandableItemTag.itemIndex = -1;
+
+       __focusItemTag.groupIndex = -1;
+       __focusItemTag.itemIndex = -1;
 }
 
 _TableViewPresenter::~_TableViewPresenter()
@@ -679,6 +684,13 @@ _TableViewPresenter::UpdateTableView(void)
 
                        PreloadItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex, shiftingDistance);
 
+                       if (__isRestoreFocus)
+                       {
+                               __pTableView->SetFocused(true);
+                               __pTableView->DrawFocus();
+                               __isRestoreFocus = false;
+                       }
+
                        __statusChangedFlag = true;
 
                        if (__itemTouchReleasedEventState == TABLE_VIEW_ITEM_TOUCH_RELEASED_EVENT_FIRE)
@@ -1367,6 +1379,37 @@ _TableViewPresenter::SetLeftMargin(float leftMargin)
 }
 
 void
+_TableViewPresenter::RestoreFocus(bool isRestoreFocus)
+{
+       __isRestoreFocus = isRestoreFocus;
+}
+
+void
+_TableViewPresenter::SetAnnexFocused(bool isAnnexFocused)
+{
+       __isAnnexFocused = isAnnexFocused;
+}
+
+void
+_TableViewPresenter::SetTableViewFocused(bool focusStatus)
+{
+       if (focusStatus == false)
+       {
+               __focusItemTag.groupIndex = -1;
+               __focusItemTag.itemIndex = -1;
+               __isRestoreFocus = false;
+               __isAnnexFocused = false;
+       }
+       __isTableViewFocused = focusStatus;
+}
+
+bool
+_TableViewPresenter::IsTableViewFocused(void)
+{
+       return __isTableViewFocused;
+}
+
+void
 _TableViewPresenter::SetItemType(_TableViewItem* pItem, TableViewItemTag itemPosition)
 {
        TableViewStyle style = __pTableView->GetTableViewStyle();
@@ -5372,6 +5415,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                GetFirstItem(firstItemPos);
                                if (itemPos.groupIndex == firstItemPos.groupIndex && itemPos.itemIndex == firstItemPos.itemIndex)
                                {
+                                       SetTableViewFocused(false);
                                        return false;
                                }
 
@@ -5383,6 +5427,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                                GetFirstItem(firstItemPos);
                                                if (itemPos.groupIndex == firstItemPos.groupIndex && itemPos.itemIndex == firstItemPos.itemIndex)
                                                {
+                                                       SetTableViewFocused(false);
                                                        return false;
                                                }
                                        }
@@ -5395,6 +5440,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                        pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
                                        if (pItem == null)
                                        {
+                                               SetTableViewFocused(false);
                                                return false;
                                        }
 
@@ -5405,6 +5451,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                                GetFirstItem(firstItemPos);
                                                if (itemPos.groupIndex == firstItemPos.groupIndex && itemPos.itemIndex == firstItemPos.itemIndex)
                                                {
+                                                       SetTableViewFocused(false);
                                                        return false;
                                                }
 
@@ -5420,6 +5467,9 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                                        && pItem->IsFocusable())
                                        {
                                                pItem->SetFocused(true);
+                                               __focusItemTag.groupIndex = itemPos.groupIndex;
+                                               __focusItemTag.itemIndex = itemPos.itemIndex;
+                                               __isAnnexFocused = false;
                                                pItem->DrawFocus();
                                                break;
                                        }
@@ -5427,6 +5477,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                        }
                        else
                        {
+                               SetTableViewFocused(false);
                                return false;
                        }
                }
@@ -5449,6 +5500,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                GetLastItem(lastItemPos);
                                if (itemPos.groupIndex == lastItemPos.groupIndex && itemPos.itemIndex == lastItemPos.itemIndex)
                                {
+                                       SetTableViewFocused(false);
                                        return false;
                                }
 
@@ -5462,6 +5514,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                        pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
                                        if (pItem == null)
                                        {
+                                               SetTableViewFocused(false);
                                                return false;
                                        }
 
@@ -5473,6 +5526,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
 
                                                if (itemPos.groupIndex == lastItemPos.groupIndex && itemPos.itemIndex == lastItemPos.itemIndex)
                                                {
+                                                       SetTableViewFocused(false);
                                                        return false;
                                                }
 
@@ -5488,17 +5542,25 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                        {
                                                pItem->SetFocused(true);
                                                pItem->DrawFocus();
+                                               __focusItemTag.groupIndex = itemPos.groupIndex;
+                                               __focusItemTag.itemIndex = itemPos.itemIndex;
+                                               __isAnnexFocused = false;
                                                break;
                                        }
                                }
                        }
                        else
                        {
+                               SetTableViewFocused(false);
                                return false;
                        }
                }
                break;
 
+       case _KEY_TAB:
+               SetTableViewFocused(false);
+               return false;
+
        default:
                return false;
        }
@@ -5543,6 +5605,27 @@ _TableViewPresenter::OnDrawFocus(void)
        _TableViewItem* pItem = null;
        TableViewItemTag itemPos = {-1, -1};
 
+       pItem = FindItem(__focusItemTag);
+
+       if (__isRestoreFocus && pItem != null)
+       {
+               if (pItem->GetEnableState() && pItem->GetVisibleState() && pItem->IsFocusable())
+               {
+                       if (__isAnnexFocused)
+                       {
+                               pItem->DrawAnnexFocus();
+                       }
+                       else
+                       {
+                               pItem->SetFocused(true);
+                               pItem->DrawFocus();
+                       }
+               }
+
+               __isRestoreFocus = false;
+               return;
+       }
+
        if (pFocusedControl != null)
        {
                pTableView = dynamic_cast<_TableView*>(pFocusedControl);
@@ -5563,6 +5646,9 @@ _TableViewPresenter::OnDrawFocus(void)
                                        if (pItem->GetEnableState() && pItem->GetVisibleState()
                                                        && pItem->IsFocusable())
                                        {
+                                               __focusItemTag.groupIndex = itemPos.groupIndex;
+                                               __focusItemTag.itemIndex = itemPos.itemIndex;
+                                               __isAnnexFocused = false;
                                                pItem->SetFocused(true);
                                                pItem->DrawFocus();
                                        }
@@ -5609,6 +5695,9 @@ _TableViewPresenter::OnDrawFocus(void)
                                                                }
                                                                else
                                                                {
+                                                                       __focusItemTag.groupIndex = itemPos.groupIndex;
+                                                                       __focusItemTag.itemIndex = itemPos.itemIndex;
+                                                                       __isAnnexFocused = false;
                                                                        pItem->SetFocused(true);
                                                                        pItem->DrawFocus();
                                                                        break;
@@ -5629,6 +5718,9 @@ _TableViewPresenter::OnDrawFocus(void)
                                        if (pItem->GetEnableState() && pItem->GetVisibleState()
                                                        && pItem->IsFocusable())
                                        {
+                                               __focusItemTag.groupIndex = itemPos.groupIndex;
+                                               __focusItemTag.itemIndex = itemPos.itemIndex;
+                                               __isAnnexFocused = false;
                                                pItem->SetFocused(true);
                                                pItem->DrawFocus();
                                        }
@@ -5675,6 +5767,9 @@ _TableViewPresenter::OnDrawFocus(void)
                                                                }
                                                                else
                                                                {
+                                                                       __focusItemTag.groupIndex = itemPos.groupIndex;
+                                                                       __focusItemTag.itemIndex = itemPos.itemIndex;
+                                                                       __isAnnexFocused = false;
                                                                        pItem->SetFocused(true);
                                                                        pItem->DrawFocus();
                                                                        break;
@@ -5691,6 +5786,11 @@ _TableViewPresenter::OnDrawFocus(void)
 void
 _TableViewPresenter::OnFocusModeStateChanged(void)
 {
+       __focusItemTag.groupIndex = -1;
+       __focusItemTag.itemIndex = -1;
+       __isRestoreFocus = false;
+       __isAnnexFocused = false;
+
        _Window* pTop = __pTableView->GetRootWindow();
 
        if (pTop != null)
index 546f259..3bc6707 100644 (file)
@@ -102,6 +102,9 @@ public:
        virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
        virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
 
+       //Focus
+       virtual bool OnFocusGained(const _Control& source);
+
        // gestureListener Callback API
        virtual bool OnFlickGestureDetected(_TouchFlickGestureDetector& gesture);
        virtual bool OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture);
@@ -112,6 +115,12 @@ public:
        bool IsReorderModeEnabled(void) const;
        result SetReorderModeEnabled(bool enable);
 
+       //Restore list Focus
+       void RestoreFocus(bool isRestoreFocus);
+       void SetAnnexFocused(bool isAnnexFocused);
+       void SetTableViewFocused(bool focusStatus);
+       bool IsTableViewFocused(void);
+
        _FastScroll* GetFastScrollBar(void) const;
        result SetFastScrollIndex(const Tizen::Base::String& text, bool useSearchIcon);
 
@@ -282,6 +291,7 @@ private:
        bool __reorderEnabled;
        bool __sectionStyle;
        bool __groupedLookEnable;
+
        TableViewStyle __tableViewStyle;
        TableViewScrollBarStyle __scrollStyle;
 
index 02b998e..a93e30a 100644 (file)
@@ -305,6 +305,8 @@ public:
        bool SetItemTapSoundEnabled(bool tapSoundEnabled);
        bool GetItemTapSoundEnabled(void);
 
+       void DrawAnnexFocus(void);
+
        virtual Tizen::Graphics::Canvas* OnCanvasRequestedN(const Tizen::Graphics::FloatRectangle& bounds);
 
        //Enable/Visible state change
index f3fc9d9..446b5f5 100644 (file)
@@ -231,6 +231,12 @@ public:
        float GetLeftMargin(void) const;
        result SetLeftMargin(float leftMargin);
 
+       //Restore Focus
+       void RestoreFocus(bool isRestoreFocus);
+       void SetAnnexFocused(bool isAnnexFocused);
+       void SetTableViewFocused(bool focusStatus);
+       bool IsTableViewFocused(void);
+
        bool IsItemChecked(int groupIndex, int itemIndex) const;
        result SetItemChecked(int groupIndex, int itemIndex, bool checked);
 
@@ -403,6 +409,8 @@ private:
        Tizen::Graphics::FloatPoint __sweptItemPosition;
        TableViewItemTag __sweptItemTag;
 
+       TableViewItemTag __focusItemTag;
+
        TableViewItemTag __reservedScrollItemIndex;
        TableViewScrollItemAlignment __reservedScrollItemAlignment;
 
@@ -428,6 +436,10 @@ private:
        bool __isAnimationCallbackBlocked;
        bool __lockLoadItemWithScroll;
 
+       bool __isRestoreFocus;
+       bool __isAnnexFocused;
+       bool __isTableViewFocused;
+
        int __itemTouchReleasedEventState;
 
        _TableViewScrollToItemTag __scrollToItemTag;