Fix for N_SE-48840
authorVinay Dutt Vyas <vinay.vyas@samsung.com>
Tue, 20 Aug 2013 14:32:40 +0000 (20:02 +0530)
committerVinay Dutt Vyas <vinay.vyas@samsung.com>
Thu, 22 Aug 2013 14:59:13 +0000 (20:29 +0530)
Change-Id: Ib55da4bee93b975ca4da26b02a9ebcf704c4b245
Signed-off-by: katpaga.a <katpaga.a@samsung.com>
src/ui/controls/FUiCtrl_TableViewPresenter.cpp
src/ui/inc/FUiCtrl_TableViewPresenter.h

index 96d5373..ed49dca 100644 (file)
@@ -83,6 +83,7 @@ _TableViewPresenter::_TableViewPresenter()
        , __itemTouchReleasedEventState(TABLE_VIEW_ITEM_TOUCH_RELEASED_EVENT_NORMAL)
        , __scrollToItemTag()
        , __isOrientationChanged(false)
+       , __isFocusedDuringOrientationChange(false)
 {
        __sweptItemTag.itemIndex = -1;
        __sweptItemTag.groupIndex = -1;
@@ -1890,6 +1891,18 @@ _TableViewPresenter::Draw(void)
                __pTableView->SetFocusNavigateEnabled(true);
        }
 
+       if (!__isRestoreFocus && __isFocusedDuringOrientationChange)
+       {
+               TableViewItemTag bottomDrawnItemIndex = {-1, -1};
+               GetBottomDrawnItem(bottomDrawnItemIndex);
+
+               if ((bottomDrawnItemIndex.groupIndex < __focusItemTag.groupIndex) ||
+                       (bottomDrawnItemIndex.groupIndex == __focusItemTag.groupIndex && bottomDrawnItemIndex.itemIndex <= __focusItemTag.itemIndex))
+               {
+                       ScrollToItem(__focusItemTag.groupIndex, __focusItemTag.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
+               }
+       }
+       __isFocusedDuringOrientationChange = false;
        return E_SUCCESS;
 }
 
@@ -1897,6 +1910,10 @@ void
 _TableViewPresenter::OnChangeLayout(_ControlOrientation orientation)
 {
        __isOrientationChanged = true;
+       if (__focusItemTag.groupIndex != -1)
+       {
+               __isFocusedDuringOrientationChange = true;
+       }
 }
 
 _UiTouchEventDelivery
@@ -1904,6 +1921,9 @@ _TableViewPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchI
 {
        _UiTouchEventDelivery response = _ScrollPanelPresenter::OnPreviewTouchPressed(source, touchInfo);
 
+       __focusItemTag.groupIndex = -1;
+       __focusItemTag.itemIndex = -1;
+
        _TableViewItem* pItem = GetTableViewItemFromControl(source);
        if (pItem == null)
        {
@@ -5700,7 +5720,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
 
                                        if (pItem->GetBoundsF().y < GetScrollPosition())
                                        {
-                                               ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
+                                               ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
                                        }
 
                                        if (pItem->GetEnableState() && pItem->GetVisibleState()
@@ -5774,7 +5794,7 @@ _TableViewPresenter::OnKeyPressed(const _Control& source, const _KeyInfo& keyInf
                                        }
                                        if (pItem->GetBoundsF().y + pItem->GetBoundsF().height > GetScrollPosition() + __pTableView->GetBoundsF().height)
                                        {
-                                               ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
+                                               ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
                                        }
 
                                        if (pItem->GetEnableState() && pItem->GetVisibleState()
@@ -5845,6 +5865,19 @@ _TableViewPresenter::OnDrawFocus(void)
        _TableViewItem* pItem = null;
        TableViewItemTag itemPos = {-1, -1};
 
+       if (__isFocusedDuringOrientationChange)
+       {
+               TableViewItemTag bottomDrawnItemIndex = {-1, -1};
+               GetBottomDrawnItem(bottomDrawnItemIndex);
+
+               if ((bottomDrawnItemIndex.groupIndex < __focusItemTag.groupIndex) ||
+                       (bottomDrawnItemIndex.groupIndex == __focusItemTag.groupIndex && bottomDrawnItemIndex.itemIndex <= __focusItemTag.itemIndex))
+               {
+                       ScrollToItem(__focusItemTag.groupIndex, __focusItemTag.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
+               }
+               __isFocusedDuringOrientationChange = false;
+       }
+
        pItem = FindItem(__focusItemTag);
 
        if (__isRestoreFocus && pItem != null)
index 7c48a20..8e989a6 100644 (file)
@@ -466,6 +466,7 @@ private:
        _TableViewScrollToItemTag __scrollToItemTag;
 
        bool __isOrientationChanged;
+       bool __isFocusedDuringOrientationChange;
 
        static const int TABLEVIEW_MAX_ITEM_COUNT = 30;
        static const int REORDER_SCROLL_ANIMATION_TIMER_DURATION = 10;