Modified TableView item layout logic
authorSangYong Lee <sangyongim.lee@samsung.com>
Fri, 5 Apr 2013 12:51:34 +0000 (21:51 +0900)
committerSangYong Lee <sangyongim.lee@samsung.com>
Fri, 5 Apr 2013 12:51:34 +0000 (21:51 +0900)
Change-Id: I0341bc224a34485f05caf78f551b5a304ef888ac
Signed-off-by: SangYong Lee <sangyongim.lee@samsung.com>
src/ui/controls/FUiCtrl_TableViewPresenter.cpp
src/ui/inc/FUiCtrl_TableViewPresenter.h

index 1930de0..d22f4c3 100644 (file)
@@ -71,6 +71,7 @@ _TableViewPresenter::_TableViewPresenter()
        , __scrollHeightOnFlickStarted(0)
        , __scrollPositionOnFlickStarted(0)
        , __isAnimationCallbackBlocked(false)
+       , __lockLoadItemWithScroll(false)
 {
        __sweptItemTag.itemIndex = -1;
        __sweptItemTag.groupIndex = -1;
@@ -695,7 +696,7 @@ _TableViewPresenter::AdjustLayoutItems(float scrollPosition)
 }
 
 void
-_TableViewPresenter::ResetItemLayout(TableViewItemTag& topDrawnItemTag)
+_TableViewPresenter::ResetItemLayout(TableViewItemTag& topDrawnItemTag, float shiftingDistance)
 {
        if (__pListModel->IsValidItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex) == false)
        {
@@ -713,7 +714,7 @@ _TableViewPresenter::ResetItemLayout(TableViewItemTag& topDrawnItemTag)
 
        TableViewItemTag currentItem = topDrawnItemTag;
        TableViewItemTag itemPos = topDrawnItemTag;
-       float screenAreaHeight = __pTableView->GetBoundsF().height;
+       float screenAreaHeight = __pTableView->GetBoundsF().height + shiftingDistance;
        float loadedItemTotalHeight = 0.0f;
        FloatRectangle itemBounds = pItem->GetBoundsF();
 
@@ -974,7 +975,7 @@ _TableViewPresenter::PreloadItem(void)
 
        __pListModel->RestoreItemStatus();
 
-       CreateItemHeightList(TABLEVIEW_DEFAULT_ITEM_HEIGHT_VALUE);
+       CreateItemHeightList(TABLEVIEW_DEFAULT_ITEM_HEIGHT_VALUE, TABLEVIEW_DEFAULT_ITEM_HEIGHT_VALUE);
        CreateSectionAlignmentList();
 
        int cachingSize = 0;
@@ -1052,7 +1053,7 @@ _TableViewPresenter::PreloadItem(int topDrawnGroupIndex, int topDrawnItemIndex,
        __pListModel->RestoreItemStatus();
 
        DeleteItemHeightList();
-       CreateItemHeightList(__pProviderAdaptor->GetDefaultItemHeight());
+       CreateItemHeightList(__pProviderAdaptor->GetDefaultGroupItemHeight(), __pProviderAdaptor->GetDefaultItemHeight());
 
        DeleteSectionAlignmentList();
        CreateSectionAlignmentList();
@@ -1069,7 +1070,12 @@ _TableViewPresenter::PreloadItem(int topDrawnGroupIndex, int topDrawnItemIndex,
                shiftingDistance = 0;
        }
 
+       __lockLoadItemWithScroll = true;
+
        ScrollToItem(topDrawnGroupIndex, topDrawnItemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP, shiftingDistance);
+
+       __lockLoadItemWithScroll = false;
+
        AdjustClientAreaBounds(true);
 
        if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
@@ -1596,6 +1602,8 @@ _TableViewPresenter::OnBoundsChanged(void)
                        SetItemDrawingProperty();
 
                        AdjustLoadedItemWidth();
+
+                       __pTableView->UpdateLayout();
                }
 
                SetClientAreaHeight(__itemTotalHeight);
@@ -2907,12 +2915,15 @@ _TableViewPresenter::ScrollToInternal(float newPosition)
        float newScrollPosition = (newPosition < 0) ? 0 : (newPosition > currentscrollAreaHeight ? currentscrollAreaHeight : newPosition);
        float newScrollAreaHeight = 0;
 
-       LoadItemWithScrollPosition(currentScrollPosition, newScrollPosition);
-
-       if (currentScrollPosition > newScrollPosition)
+       if (!__lockLoadItemWithScroll)
        {
-               newScrollAreaHeight = GetScrollAreaBounds().height;
-               newScrollPosition += newScrollAreaHeight - currentscrollAreaHeight;
+               LoadItemWithScrollPosition(currentScrollPosition, newScrollPosition);
+
+               if (currentScrollPosition > newScrollPosition)
+               {
+                       newScrollAreaHeight = GetScrollAreaBounds().height;
+                       newScrollPosition += newScrollAreaHeight - currentscrollAreaHeight;
+               }
        }
 
        return _ScrollPanelPresenter::ScrollToInternal(newScrollPosition);
@@ -3031,7 +3042,7 @@ _TableViewPresenter::ScrollToItem(int groupIndex, int itemIndex, TableViewScroll
 
        if (!__pListModel->IsLoadedItem(groupIndex, itemIndex))
        {
-               ResetItemLayout(itemPos);
+               ResetItemLayout(itemPos, shiftingDistance);
        }
 
        _TableViewItem* pItem = FindItem(itemPos);
@@ -4221,7 +4232,7 @@ _TableViewPresenter::CheckItemHeightAndRefreshLayout(TableViewItemTag itemTag, b
 }
 
 bool
-_TableViewPresenter::CreateItemHeightList(float defaultHeight)
+_TableViewPresenter::CreateItemHeightList(float defaultGroupItemHeight, float defaultItemHeight)
 {
        int groupCount = GetGroupCount();
 
@@ -4238,12 +4249,12 @@ _TableViewPresenter::CreateItemHeightList(float defaultHeight)
                }
                else
                {
-                       __itemHeightList.Add(defaultHeight);
+                       __itemHeightList.Add(defaultGroupItemHeight);
                }
 
                for (int j = 0; j < itemCount; j++)
                {
-                       __itemHeightList.Add(defaultHeight);
+                       __itemHeightList.Add(defaultItemHeight);
                }
        }
 
index 38d3e45..6e7d20d 100644 (file)
@@ -264,7 +264,7 @@ private:
        void SetItemLayout(_TableViewItem* pItem, TableViewItemTag& itemPos);
        float CalculateItemPositionY(int groupIndex, int itemIndex);
        void AdjustLayoutItems(float scrollPosition);
-       void ResetItemLayout(TableViewItemTag& topDrawnItemTag);
+       void ResetItemLayout(TableViewItemTag& topDrawnItemTag, float shiftingDistance);
        void RefreshItemLayout(TableViewItemTag& topDrawnItemTag, TableViewItemTag& refreshItemTag, TableViewRefreshType type, bool animation);
        void RefreshItemBounds(_TableViewItem* pItem, TableViewItemTag& itemPos);
        void ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment, float shiftingDistance = 0.0f);
@@ -312,7 +312,7 @@ private:
        // item height
        float GetItemHeight(TableViewItemTag itemTag) const;
        float SetItemHeight(TableViewItemTag itemTag, float height);
-       bool CreateItemHeightList(float defaultHeight);
+       bool CreateItemHeightList(float defaultGroupItemHeight, float defaultItemHeight);
        void DeleteItemHeightList(void);
        void PresetItemHeightList(void);
        bool RefreshItemHeightList(int groupIndex, int itemIndex, TableViewRefreshType refreshType);
@@ -381,6 +381,7 @@ private:
        float __scrollPositionOnFlickStarted;
 
        bool __isAnimationCallbackBlocked;
+       bool __lockLoadItemWithScroll;
 
        static const int TABLEVIEW_MAX_ITEM_COUNT = 30;
        static const int REORDER_SCROLL_ANIMATION_TIMER_DURATION = 10;