2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_TableViewPresenter.cpp
20 * @brief This is the header file for the _TableViewPresenter class.
22 * This file contains the declarations of the _TableViewPresenter class.
25 #include <FGrpRectangle.h>
26 #include <FSysSystemTime.h>
27 #include "FUi_ResourceManager.h"
28 #include "FUi_UiTouchEvent.h"
29 #include "FUi_ResourceManager.h"
30 #include "FUiAnim_VisualElement.h"
31 #include "FUiCtrl_FastScroll.h"
32 #include "FUiCtrl_ListViewModel.h"
33 #include "FUiCtrl_Scroll.h"
34 #include "FUiCtrl_TableView.h"
35 #include "FUiCtrl_TableViewItem.h"
36 #include "FUiCtrl_TableViewPresenter.h"
37 #include "FUiCtrl_TableViewItemProviderAdaptor.h"
38 #include "FUi_CoordinateSystemUtils.h"
41 using namespace Tizen::Ui::Animations;
42 using namespace Tizen::Graphics;
43 using namespace Tizen::Base;
44 using namespace Tizen::Base::Runtime;
46 namespace Tizen { namespace Ui { namespace Controls
48 _TableViewPresenter::_TableViewPresenter()
51 , __pProviderAdaptor(null)
53 , __bottomMargin(0.0f)
55 , __modelInitialized(false)
56 , __firstDrawnFlag(true)
57 , __statusChangedFlag(true)
59 , __pItemDrawingProperty(null)
60 , __pBaseVisualElement(null)
61 , __sweepOccured(false)
62 , __sweptItemPosition()
63 , __reservedScrollItemAlignment(TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP)
64 , __firstTouchMoved(false)
65 , __pReorderScrollTimer(null)
67 , __itemTotalHeight(0.0f)
68 , __pCapturedItemVisualElement(null)
69 , __pFastScrollTimer(null)
70 , __isFastScrollTimerEnabled(false)
71 , __scrollHeightOnFlickStarted(0)
72 , __scrollPositionOnFlickStarted(0)
73 , __isAnimationCallbackBlocked(false)
75 __sweptItemTag.itemIndex = -1;
76 __sweptItemTag.groupIndex = -1;
78 __reservedScrollItemIndex.itemIndex = -1;
79 __reservedScrollItemIndex.groupIndex = -1;
82 _TableViewPresenter::~_TableViewPresenter()
88 _TableViewPresenter::GetView() const
94 _TableViewPresenter::GetModel(void) const
100 _TableViewPresenter::Initialize(_TableView* pTableView)
102 _ScrollPanelPresenter::Initialize(*pTableView);
104 __pTableView = pTableView;
105 __pBaseVisualElement = __pTableView->GetVisualElement();
106 __pBaseVisualElement->SetClipChildrenEnabled(true);
107 __pBaseVisualElement->SetSurfaceOpaque(false);
109 result r = __itemHeightList.Construct();
110 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
112 r = __sectionAlignmentList.Construct();
113 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
116 __pListModel = new (std::nothrow) _ListViewModel();
117 SysTryReturn(NID_UI_CTRL, __pListModel != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
119 __pItemDrawingProperty = new (std::nothrow) _ItemDrawingProperty();
120 SysTryReturn(NID_UI_CTRL, __pItemDrawingProperty != null, false, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
123 __pFastScrollTimer = new (std::nothrow) Timer();
124 SysTryCatch(NID_UI_CTRL, __pFastScrollTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
126 r = __pFastScrollTimer->Construct(*this);
127 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
132 if (__isFastScrollTimerEnabled)
134 __pFastScrollTimer->Cancel();
137 delete __pFastScrollTimer;
138 __pFastScrollTimer = null;
144 _TableViewPresenter::Construct(_TableView* pTableView)
146 result r = E_SUCCESS;
149 if (!Initialize(pTableView))
162 _TableViewPresenter::Dispose(void)
164 DeleteItemHeightList();
165 DeleteSectionAlignmentList();
166 DetachContextItem(__sweptItemTag);
171 delete __pProviderAdaptor;
172 __pProviderAdaptor = null;
174 delete __pItemDrawingProperty;
175 __pItemDrawingProperty = null;
177 delete __pReorderScrollTimer;
178 __pReorderScrollTimer = null;
180 if (__isFastScrollTimerEnabled)
182 __pFastScrollTimer->Cancel();
185 delete __pFastScrollTimer;
186 __pFastScrollTimer = null;
188 if (__pCapturedItemVisualElement)
190 GetView()->GetVisualElement()->DetachChild(*__pCapturedItemVisualElement);
191 __pCapturedItemVisualElement->Destroy();
193 __pCapturedItemVisualElement = null;
197 _TableViewPresenter::SetItemProvider(const _TableViewItemProvider* pProvider)
199 result r = E_SUCCESS;
201 _TableViewItemProviderAdaptor* pProviderAdaptor = null;
202 pProviderAdaptor = static_cast <_TableViewItemProviderAdaptor*>(__pListModel->GetItemProviderAdaptor());
204 if (pProviderAdaptor == null)
206 pProviderAdaptor = new (std::nothrow) _TableViewItemProviderAdaptor();
207 SysTryReturn(NID_UI_CTRL, pProviderAdaptor != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, ("[E_OUT_OF_MEMORY] The memory is insufficient."));
209 SetTableViewItemProviderAdaptor(pProviderAdaptor);
212 _TableViewItemProvider* pNewProvider = null;
214 if (pProvider != null)
216 pNewProvider = const_cast <_TableViewItemProvider*>(pProvider);
220 __pListModel->RemoveAllItem(false);
223 pProviderAdaptor->SetItemProvider(pNewProvider);
224 pProviderAdaptor->SetListWidth(__pTableView->GetBoundsF().width - (GetLeftMargin() * 2));
225 pProviderAdaptor->SetTableViewStyle(__pTableView->GetTableViewStyle());
231 _TableViewPresenter::GetItemFromPosition(const Tizen::Graphics::FloatPoint& position, TableViewItemTag& itemPos) const
233 _TableViewItem* pItem = null;
234 TableViewItemTag lastItemPos = {-1, -1};
236 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
237 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
241 pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex));
242 SysTryCatch(NID_UI_CTRL, pItem != null, , E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
244 FloatRectangle itemBounds = pItem->GetBoundsF();
245 if (itemBounds.Contains(position))
250 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
255 } while (GetNextItemPosition(itemPos, itemPos));
258 itemPos.itemIndex = -1;
259 itemPos.groupIndex = -1;
261 return E_OUT_OF_RANGE;
265 _TableViewPresenter::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
267 result r = E_SUCCESS;
269 TableViewItemTag itemPos;
270 r = GetTopDrawnItem(itemPos);
272 groupIndex = itemPos.groupIndex;
273 itemIndex = itemPos.itemIndex;
279 _TableViewPresenter::SetTopDrawnItemIndex(int groupIndex, int itemIndex)
283 return E_INVALID_ARG;
286 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
288 return E_OUT_OF_RANGE;
291 ScrollToItem(groupIndex, itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
297 _TableViewPresenter::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
299 result r = E_SUCCESS;
301 TableViewItemTag itemPos;
302 r = GetBottomDrawnItem(itemPos);
304 groupIndex = itemPos.groupIndex;
305 itemIndex = itemPos.itemIndex;
311 _TableViewPresenter::SetBottomDrawnItemIndex(int groupIndex, int itemIndex)
315 return E_INVALID_ARG;
318 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
320 return E_OUT_OF_RANGE;
323 ScrollToItem(groupIndex, itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
329 _TableViewPresenter::GetGroupCount(void) const
331 return __pListModel->GetAllGroupCount();
336 _TableViewPresenter::GetItemCountAt(int groupIndex) const
338 return __pListModel->GetItemCountInGroup(groupIndex);
342 _TableViewPresenter::HasSectionHeader(int groupIndex) const
344 if (__pProviderAdaptor == null || __pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
349 return __pProviderAdaptor->HasSectionHeader(groupIndex);
353 _TableViewPresenter::HasSectionFooter(int groupIndex) const
355 if (__pProviderAdaptor == null || __pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
360 return __pProviderAdaptor->HasSectionFooter(groupIndex);
364 _TableViewPresenter::GetItemCount(void) const
366 return __pListModel->GetAllItemCount();
370 _TableViewPresenter::RefreshTableView(int groupIndex, int itemIndex, TableViewRefreshType type, bool animation)
372 _TableViewItemProviderAdaptor* pProviderAdaptor = __pProviderAdaptor;
374 SysTryReturn(NID_UI_CTRL, pProviderAdaptor != null, E_INVALID_STATE, E_INVALID_STATE,
375 ("[E_INVALID_STATE] This instance isn't constructed."));
377 if ((groupIndex < 0) || (groupIndex > GetGroupCount()) || (itemIndex < -1) || (itemIndex > GetItemCountAt(groupIndex)))
379 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
380 return E_OUT_OF_RANGE;
383 if (groupIndex == GetGroupCount() && itemIndex != -1 && type != TABLE_VIEW_REFRESH_TYPE_ITEM_ADD)
385 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
386 return E_OUT_OF_RANGE;
389 TableViewItemTag topDrawnItemPos = {-1, -1};
390 TableViewItemTag refreshItemPos = {groupIndex, itemIndex};
391 float prevScrollAreaHeight = GetScrollAreaBounds().height;
393 GetTopDrawnItem(topDrawnItemPos);
399 case TABLE_VIEW_REFRESH_TYPE_ITEM_ADD:
402 bool emptyState = IsEmpty();
404 int itemCount = pProviderAdaptor->GetItemCount(groupIndex);
405 if (__pListModel->InsertGroup(groupIndex, itemCount, false) != E_SUCCESS)
407 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to add Group item.");
413 GetFirstItem(topDrawnItemPos);
415 else if (groupIndex <= topDrawnItemPos.groupIndex)
417 topDrawnItemPos.groupIndex++;
422 bool emptyState = IsEmpty();
424 if (__pListModel->InsertItemToGroup(null, groupIndex, itemIndex) != E_SUCCESS)
426 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to add item.");
432 GetFirstItem(topDrawnItemPos);
436 RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
437 RefreshSectionAlignmentList(groupIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
439 if (__pListModel->GetAllItemCount() == 1)
441 SetStatusChanged(true);
446 case TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE:
449 if (groupIndex == GetGroupCount())
451 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
452 return E_OUT_OF_RANGE;
455 RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
456 RefreshSectionAlignmentList(groupIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
458 if (__pListModel->RemoveGroup(groupIndex) != E_SUCCESS)
460 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to remove group.");
464 if (groupIndex < topDrawnItemPos.groupIndex)
466 topDrawnItemPos.groupIndex--;
469 if ((groupIndex == topDrawnItemPos.groupIndex) && (GetItemCountAt(groupIndex) < topDrawnItemPos.itemIndex))
471 topDrawnItemPos.itemIndex = -1;
476 if (itemIndex == GetItemCountAt(groupIndex))
478 SysLogException(NID_UI_CTRL, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
479 return E_OUT_OF_RANGE;
482 if (__pListModel->RemoveItemAt(groupIndex, itemIndex) != E_SUCCESS)
484 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to remove item.");
488 if ((groupIndex == topDrawnItemPos.groupIndex) && (itemIndex < topDrawnItemPos.itemIndex))
490 GetPreviousItemPosition(topDrawnItemPos, topDrawnItemPos);
493 RefreshItemHeightList(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
496 if (GetModel()->IsValidItem(topDrawnItemPos.groupIndex, topDrawnItemPos.itemIndex) == false)
498 GetPreviousItemPosition(topDrawnItemPos, topDrawnItemPos);
501 if (__pListModel->GetAllItemCount() == 0)
503 SetStatusChanged(true);
508 case TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY:
510 TableViewItemTag itemTag = {groupIndex, itemIndex};
511 _TableViewItem* pTableViewItem = FindItem(itemTag);
513 if (pTableViewItem == null)
518 if (pProviderAdaptor->UpdateItem(pTableViewItem, itemTag.groupIndex, itemTag.itemIndex))
520 CheckItemHeightAndRefreshLayout(itemTag, true);
522 if (__sweptItemTag.groupIndex != itemTag.groupIndex || __sweptItemTag.itemIndex != itemTag.itemIndex)
527 pTableViewItem->SetItemChanged(true);
528 pTableViewItem->Invalidate();
529 pTableViewItem->AdjustContextItemBounds();
537 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to refresh list.");
542 AdjustClientAreaBounds(true);
544 if ((topDrawnItemPos.groupIndex > refreshItemPos.groupIndex)
545 ||((topDrawnItemPos.groupIndex == refreshItemPos.groupIndex)&&(topDrawnItemPos.itemIndex > refreshItemPos.itemIndex)))
547 RefreshItemLayout(topDrawnItemPos, refreshItemPos, type, false);
549 float newScrollPosition = GetScrollPosition() - (prevScrollAreaHeight - GetScrollAreaBounds().height);
550 SetScrollPosition(newScrollPosition, false);
554 RefreshItemLayout(topDrawnItemPos, refreshItemPos, type, animation);
561 _TableViewPresenter::RefreshAllItems(void)
563 result r = E_SUCCESS;
564 TableViewItemTag itemTag = {-1, -1};
565 TableViewItemTag lastLoadedItemTag = {-1, -1};
567 __pListModel->GetLastLoadedItemIndex(lastLoadedItemTag.groupIndex, lastLoadedItemTag.itemIndex);
568 __pListModel->GetFirstLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex);
572 _TableViewItem* pItem = FindItem(itemTag);
579 r = RefreshTableView(itemTag.groupIndex, itemTag.itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY, false);
580 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
582 if ((itemTag.itemIndex == lastLoadedItemTag.itemIndex) && (itemTag.groupIndex == lastLoadedItemTag.groupIndex))
586 } while (GetNextItemPosition(itemTag, itemTag));
592 _TableViewPresenter::UpdateTableView(void)
594 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
596 if (pVisualElement != null)
598 __pTableView->GetVisualElement()->RemoveAllAnimations();
602 if (__modelInitialized == false)
604 SetItemDrawingProperty();
606 if(PreloadItem() == false)
613 TableViewItemTag topDrawnTag = {-1, -1};
614 float shiftingDistance = 0;
618 GetTopDrawnItem(topDrawnTag);
620 if (__pListModel->IsValidItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex))
622 _TableViewItem* pItem = FindItem(topDrawnTag);
626 shiftingDistance = GetScrollPosition() - pItem->GetBoundsF().y;
630 __pListModel->RemoveAllItem(false, true);
632 PreloadItem(topDrawnTag.groupIndex, topDrawnTag.itemIndex, shiftingDistance);
634 __statusChangedFlag = true;
642 _TableViewPresenter::AdjustLayoutItems(float scrollPosition)
644 TableViewItemTag lastLoadedItemPos = {-1, -1};
645 TableViewItemTag firstLoadedItemPos = {-1, -1};
646 TableViewItemTag currentItemPos = {-1, -1};
647 _TableViewItem* pItem = null;
649 __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex);
650 __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex);
652 pItem = FindItem(firstLoadedItemPos);
656 float positionY = pItem->GetPositionF().y;
658 currentItemPos = firstLoadedItemPos;
660 while (!_FloatCompareLE(positionY, scrollPosition) && GetPreviousItemPosition(currentItemPos, currentItemPos))
662 pItem = LoadItem(currentItemPos.groupIndex, currentItemPos.itemIndex);
669 positionY = pItem->GetPositionF().y;
673 pItem = FindItem(lastLoadedItemPos);
677 float positionY = pItem->GetPositionF().y;
678 float itemHeight = pItem->GetBoundsF().height;
679 float limitScreenArea = scrollPosition + __pTableView->GetBoundsF().height;
680 currentItemPos = lastLoadedItemPos;
682 while ((positionY + itemHeight < limitScreenArea) && GetNextItemPosition(currentItemPos, currentItemPos))
684 pItem = LoadItem(currentItemPos.groupIndex, currentItemPos.itemIndex);
691 positionY = pItem->GetPositionF().y;
692 itemHeight = pItem->GetBoundsF().height;
698 _TableViewPresenter::ResetItemLayout(TableViewItemTag& topDrawnItemTag)
700 if (__pListModel->IsValidItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex) == false)
707 _TableViewItem* pItem = LoadItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex);
714 TableViewItemTag currentItem = topDrawnItemTag;
715 TableViewItemTag itemPos = topDrawnItemTag;
716 float screenAreaHeight = __pTableView->GetBoundsF().height;
717 float loadedItemTotalHeight = 0.0f;
718 FloatRectangle itemBounds = pItem->GetBoundsF();
720 itemBounds.y = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex);
721 pItem->SetBounds(itemBounds);
722 CheckItemHeightAndRefreshLayout(itemPos, true);
724 loadedItemTotalHeight += itemBounds.height;
726 while (loadedItemTotalHeight < screenAreaHeight && GetNextItemPosition(currentItem, itemPos))
728 pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
735 currentItem = itemPos;
736 loadedItemTotalHeight += pItem->GetBoundsF().height;
739 if (loadedItemTotalHeight < screenAreaHeight)
741 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
742 currentItem = itemPos;
744 while (loadedItemTotalHeight < screenAreaHeight && GetPreviousItemPosition(currentItem, itemPos))
746 pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
753 currentItem = itemPos;
754 loadedItemTotalHeight += pItem->GetBoundsF().height;
760 _TableViewPresenter::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const
762 __pListModel->GetFirstLoadedItemIndex(groupIndex, itemIndex);
766 _TableViewPresenter::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const
768 __pListModel->GetLastLoadedItemIndex(groupIndex, itemIndex);
772 _TableViewPresenter::RefreshItemLayout(int groupIndex, int itemIndex)
774 TableViewItemTag itemTag = {groupIndex, itemIndex};
778 RefreshItemLayout(itemTag, itemTag, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY, false);
782 _TableViewPresenter::RefreshItemLayout(TableViewItemTag& topDrawnItemTag, TableViewItemTag& refreshItemTag, TableViewRefreshType type, bool animation)
784 if (!__pListModel->IsValidItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex))
789 if (refreshItemTag.itemIndex == -1)
794 _TableViewItem* pItem = null;
796 TableViewItemTag itemPos = {-1, -1};
797 TableViewItemTag currentItem = {-1, -1};
799 int loadItemCount = 0;
800 int maxLoadItemCount = GetMaxItemCachingSize();
801 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
803 StopAllItemAnimation();
805 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
807 if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1)
809 itemPos = topDrawnItemTag;
812 currentItem = itemPos;
814 float itemPositionY = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex);
818 pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
825 if (pItem->HasParent())
827 pItem->SetDrawingProperty(__pItemDrawingProperty);
828 SetItemType(pItem, itemPos);
831 itemBounds = pItem->GetBoundsF();
832 itemBounds.y = itemPositionY;
836 if (type == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD)
838 if (itemPos.groupIndex == refreshItemTag.groupIndex && itemPos.itemIndex == refreshItemTag.itemIndex)
840 pItem->SetBounds(itemBounds);
841 pItem->FadeInOutItem(false, ADD_ITEM_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY);
842 pItem->ZoomInOutItem(false, ADD_ITEM_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY);
846 if (!pItem->MoveItem(FloatPoint(itemBounds.x, itemBounds.y), ADD_ITEM_ANIMATION_DURATION, 0))
848 pItem->SetBounds(itemBounds);
854 if (!pItem->MoveItem(FloatPoint(itemBounds.x, itemBounds.y), REMOVE_ITEM_MOVE_ANIMATION_DURATION, REFRESH_ITEM_ANIMATION_DELAY))
856 pItem->SetBounds(itemBounds);
862 pItem->SetBounds(itemBounds);
865 currentItem = itemPos;
866 itemPositionY = itemBounds.y + itemBounds.height;
870 } while (loadItemCount < maxLoadItemCount && GetNextItemPosition(currentItem, itemPos));
872 if (loadItemCount < maxLoadItemCount)
874 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
875 currentItem = itemPos;
877 while (loadItemCount < maxLoadItemCount && GetPreviousItemPosition(currentItem, itemPos))
879 pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
886 currentItem = itemPos;
892 if (refreshItemTag.itemIndex == -1)
894 ScrollToItem(topDrawnItemTag.groupIndex, topDrawnItemTag.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
899 _TableViewPresenter::RefreshItemBounds(_TableViewItem* pItem, TableViewItemTag& itemPos)
901 FloatRectangle itemBounds;
908 itemBounds = pItem->GetBoundsF();
910 itemBounds.y = CalculateItemPositionY(itemPos.groupIndex, itemPos.itemIndex);
912 if (itemPos.itemIndex != -1)
914 float itemMargin = GetLeftMargin();
915 itemBounds.x = itemMargin;
916 itemBounds.width = __pItemDrawingProperty->width - itemBounds.x - itemMargin;
921 itemBounds.width = __pItemDrawingProperty->width;
924 pItem->SetBounds(itemBounds);
928 _TableViewPresenter::GetItemIndexFromPosition(const FloatPoint& position, int& groupIndex, int& itemIndex) const
930 result r = E_SUCCESS;
931 TableViewItemTag itemPos;
933 FloatPoint targetPosition = position;
934 float scrollPosition = GetScrollPosition();
935 targetPosition.y += scrollPosition;
937 r = GetItemFromPosition(targetPosition, itemPos);
946 groupIndex = itemPos.groupIndex;
947 itemIndex = itemPos.itemIndex;
954 _TableViewPresenter::PreloadItem(void)
956 if (GetModel() == null || __pProviderAdaptor == null)
961 __modelInitialized = true;
963 if (__pListModel->GetAllGroupCount() == 0 && (__pProviderAdaptor != null))
966 int groupCount = __pProviderAdaptor->GetGroupCount();
968 for (int i = 0; i < groupCount; i++)
970 itemCount = __pProviderAdaptor->GetItemCount(i);
971 __pListModel->AddGroup(itemCount, false);
975 __pListModel->RestoreItemStatus();
977 CreateItemHeightList();
978 CreateSectionAlignmentList();
982 if (GetItemCount() > TABLEVIEW_MAX_ITEM_COUNT)
984 cachingSize = TABLEVIEW_MAX_ITEM_COUNT;
986 else if (__pListModel->GetMaxCachingSize() < TABLEVIEW_MAX_ITEM_COUNT)
988 cachingSize = __pListModel->GetMaxCachingSize();
992 cachingSize = GetItemCount();
995 TableViewItemTag itemPos = {-1, -1};
996 GetFirstItem(itemPos);
998 _TableViewItem* pItem = null;
999 for (int i = 0; i < cachingSize; i++)
1001 pItem = LoadItem(itemPos.groupIndex, itemPos.itemIndex);
1008 if (GetNextItemPosition(itemPos, itemPos) == false)
1014 PresetItemHeightList();
1015 AdjustClientAreaBounds(true);
1017 if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
1019 _FastScroll* pFastScroll = __pTableView->GetFastScrollBar();
1020 if (pFastScroll != null)
1022 pFastScroll->UpdateIndex();
1023 pFastScroll->SetScrollVisibility(IsScrollable());
1031 _TableViewPresenter::PreloadItem(int topDrawnGroupIndex, int topDrawnItemIndex, int shiftingDistance)
1033 if (GetModel() == null || __pProviderAdaptor == null)
1038 __modelInitialized = true;
1040 if (__pListModel->GetAllGroupCount() == 0 && (__pProviderAdaptor != null))
1043 int groupCount = __pProviderAdaptor->GetGroupCount();
1045 for (int i = 0; i < groupCount; i++)
1047 itemCount = __pProviderAdaptor->GetItemCount(i);
1048 __pListModel->AddGroup(itemCount, false);
1052 __pListModel->RestoreItemStatus();
1054 CreateItemHeightList();
1055 CreateSectionAlignmentList();
1057 if (!__pListModel->IsValidItem(topDrawnGroupIndex, topDrawnItemIndex))
1059 TableViewItemTag firstItemTag = {-1, -1};
1061 GetFirstItem(firstItemTag);
1063 topDrawnGroupIndex = firstItemTag.groupIndex;
1064 topDrawnItemIndex = firstItemTag.itemIndex;
1066 shiftingDistance = 0;
1069 ScrollToItem(topDrawnGroupIndex, topDrawnItemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP, shiftingDistance);
1071 PresetItemHeightList();
1072 AdjustClientAreaBounds(true);
1074 if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
1076 _FastScroll* pFastScroll = __pTableView->GetFastScrollBar();
1077 if (pFastScroll != null)
1079 pFastScroll->UpdateIndex();
1080 pFastScroll->SetScrollVisibility(IsScrollable());
1088 _TableViewPresenter::IsItemChecked(int groupIndex, int itemIndex) const
1090 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
1095 return __pListModel->IsItemChecked(groupIndex, itemIndex);
1099 _TableViewPresenter::SetItemChecked(int groupIndex, int itemIndex, bool checked)
1101 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
1103 return E_OUT_OF_RANGE;
1106 if (__modelInitialized == false)
1108 return E_INVALID_STATE;
1111 TableViewItemTag itemPos = {groupIndex, itemIndex};
1113 bool enabled = __pListModel->IsItemEnabled(itemPos.groupIndex, itemPos.itemIndex);
1114 SysTryReturn(NID_UI_CTRL, (enabled == true), E_INVALID_OPERATION, E_INVALID_OPERATION,
1115 "[E_INVALID_OPERATION] The item is disabled.");
1117 if (__pListModel->IsItemChecked(itemPos.groupIndex, itemPos.itemIndex) == checked)
1122 TableViewItemTag itemTag = {groupIndex, itemIndex};
1123 _TableViewItem *pItem = FindItem(itemTag);
1126 pItem->SetCheckedAnimationEnabled(checked);
1129 result r = __pListModel->SetItemChecked(itemPos.groupIndex, itemPos.itemIndex, checked);
1135 _TableViewPresenter::IsItemEnabled(int groupIndex, int itemIndex) const
1137 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
1142 return __pListModel->IsItemEnabled(groupIndex, itemIndex);
1146 _TableViewPresenter::SetItemEnabled(int groupIndex, int itemIndex, bool enabled)
1148 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()) || (itemIndex < -1) || (itemIndex >= GetItemCountAt(groupIndex)))
1150 return E_OUT_OF_RANGE;
1153 TableViewItemTag itemPos = {groupIndex, itemIndex};
1155 if (__pListModel->IsItemEnabled(itemPos.groupIndex, itemPos.itemIndex) == enabled)
1160 result r = __pListModel->SetItemEnabled(itemPos.groupIndex, itemPos.itemIndex, enabled);
1166 _TableViewPresenter::SetStatusChanged(bool changed)
1168 __statusChangedFlag = changed;
1170 if (__statusChangedFlag == true)
1172 SetItemDrawingProperty();
1174 if ((__pItemDrawingProperty != null) && (__pItemDrawingProperty->propertyChanged == true))
1176 __pListModel->SetAllLoadedItemStateChanged(true);
1184 _TableViewPresenter::IsStatusChanged(void) const
1186 return __statusChangedFlag;
1190 _TableViewPresenter::GetTopMargin(void) const
1196 _TableViewPresenter::SetTopMargin(float topMargin)
1198 __topMargin = topMargin;
1204 _TableViewPresenter::GetBottomMargin(void) const
1206 return __bottomMargin;
1210 _TableViewPresenter::SetBottomMargin(float bottomMargin)
1212 __bottomMargin = bottomMargin;
1218 _TableViewPresenter::GetLeftMargin(void) const
1220 return __leftMargin;
1224 _TableViewPresenter::SetLeftMargin(float leftMargin)
1226 __leftMargin = leftMargin;
1232 _TableViewPresenter::SetItemType(_TableViewItem* pItem, TableViewItemTag itemPosition)
1234 TableViewStyle style = __pTableView->GetTableViewStyle();
1236 if (itemPosition.itemIndex == -1)
1238 if (style == TABLE_VIEW_STYLE_SECTION)
1240 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_HEADER);
1244 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TITLE);
1249 int itemCount = GetItemCountAt(itemPosition.groupIndex);
1251 if (itemPosition.itemIndex == 0)
1253 if (HasSectionFooter(itemPosition.groupIndex))
1257 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER);
1259 else if (itemCount == 2)
1261 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE);
1265 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP);
1272 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_ONE);
1276 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_TOP);
1282 int lastItemIndex = itemCount - 1;
1284 if (HasSectionFooter(itemPosition.groupIndex))
1286 if (itemPosition.itemIndex == lastItemIndex)
1288 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_FOOTER);
1290 else if (itemPosition.itemIndex == lastItemIndex - 1)
1292 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM);
1296 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE);
1301 if (itemPosition.itemIndex == lastItemIndex)
1303 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_BOTTOM);
1307 pItem->SetItemType(TABLE_VIEW_ITEM_TYPE_MIDDLE);
1315 _TableViewPresenter::SetItemLayout(_TableViewItem* pItem, TableViewItemTag& itemPos)
1317 _TableViewItem* pSeriesItem = null;
1318 TableViewItemTag seriesItemPos = {-1, -1};
1319 FloatRectangle seriesItemBounds;
1320 FloatRectangle itemBounds;
1321 bool validBounds = false;
1322 bool downScroll = true;
1324 if (itemPos.itemIndex == -1 && __pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
1327 itemBounds.width = __pItemDrawingProperty->width;
1331 float itemMargin = GetLeftMargin();
1332 itemBounds.x = itemMargin;
1333 itemBounds.width = __pItemDrawingProperty->width - itemBounds.x - itemMargin;
1336 //itemBounds.height = pItem->GetItemHeight();
1337 itemBounds.height = pItem->GetSizeF().height;
1339 if (itemPos.groupIndex == 0 && itemPos.itemIndex == -1)
1341 itemBounds.y = GetTopMargin();
1346 if (GetPreviousItemPosition(itemPos, seriesItemPos))
1348 if (__pListModel->IsLoadedItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex))
1350 pSeriesItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex));
1351 if ((pSeriesItem != null) && pSeriesItem->HasParent())
1353 if (__pTableView->IsReorderModeEnabled() && (__reorderInfo.groupIndex == seriesItemPos.groupIndex && __reorderInfo.itemIndex == seriesItemPos.itemIndex))
1355 seriesItemBounds = __reorderInfo.itemBounds;
1359 seriesItemBounds = pSeriesItem->GetBoundsF();
1362 itemBounds.y = seriesItemBounds.y + seriesItemBounds.height;
1369 if ((!validBounds) && GetNextItemPosition(itemPos, seriesItemPos))
1371 if (__pListModel->IsLoadedItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex))
1373 pSeriesItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(seriesItemPos.groupIndex, seriesItemPos.itemIndex));
1374 if ((pSeriesItem != null) && pSeriesItem->HasParent())
1376 if (__pTableView->IsReorderModeEnabled() && (__reorderInfo.groupIndex == seriesItemPos.groupIndex && __reorderInfo.itemIndex == seriesItemPos.itemIndex))
1378 seriesItemBounds = __reorderInfo.itemBounds;
1382 seriesItemBounds = pSeriesItem->GetBoundsF();
1385 itemBounds.y = seriesItemBounds.y - itemBounds.height;
1396 pItem->SetBounds(itemBounds);
1398 CheckItemHeightAndRefreshLayout(itemPos, downScroll);
1401 if (pItem->GetItemLayoutEnabled())
1403 pItem->PartialUpdateLayout();
1408 _TableViewPresenter::LoadItem(int groupIndex, int itemIndex)
1410 _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(groupIndex, itemIndex));
1412 if ((pItem != null) && !pItem->HasParent())
1414 __pTableView->AttachChild(*pItem);
1416 pItem->SetDrawingProperty(__pItemDrawingProperty);
1418 TableViewItemTag itemPosition = {groupIndex, itemIndex};
1419 SetItemType(pItem, itemPosition);
1420 SetItemLayout(pItem, itemPosition);
1421 pItem->SetReorderMode(__pTableView->IsReorderModeEnabled());
1422 pItem->AdjustChildControlMargin();
1429 _TableViewPresenter::FindItem(TableViewItemTag& itemTag)
1431 if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex))
1433 return static_cast<_TableViewItem*>(__pListModel->LoadItem(itemTag.groupIndex, itemTag.itemIndex));
1439 _TableViewPresenter::UnloadItem(int groupIndex, int itemIndex)
1441 __pListModel->UnloadItem(groupIndex, itemIndex);
1445 _TableViewPresenter::UnloadItem(TableViewItemTag& itemTag)
1447 __pListModel->UnloadItem(itemTag.groupIndex, itemTag.itemIndex);
1453 _TableViewPresenter::DetachItem(TableViewItemTag& itemTag)
1455 _TableViewItem *pItem = FindItem(itemTag);
1457 if (pItem != null && pItem->HasParent())
1459 pItem->GetParent()->DetachChild(*pItem);
1464 _TableViewPresenter::DetachContextItem(TableViewItemTag& itemTag)
1466 _TableViewItem *pItem = FindItem(itemTag);
1472 _TableViewItem* contextItem = pItem->GetContextItem();
1473 if (contextItem != null && contextItem->HasParent())
1475 contextItem->GetParent()->DetachChild(*pItem);
1480 _TableViewPresenter::DetachAllItem(bool removeItem)
1482 TableViewItemTag itemPos = {-1, -1};
1483 TableViewItemTag lastItemPos = {-1, -1};
1485 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
1486 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
1488 if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1)
1495 DetachItem(itemPos);
1499 UnloadItem(itemPos);
1502 if (itemPos.itemIndex == lastItemPos.itemIndex && itemPos.groupIndex == lastItemPos.groupIndex)
1506 } while (GetNextItemPosition(itemPos, itemPos));
1510 _TableViewPresenter::SetItemDrawingProperty(void)
1512 if (__pItemDrawingProperty != null)
1514 __pItemDrawingProperty->propertyChanged = false;
1516 if (__pItemDrawingProperty->itemDividerEnabled != __pTableView->IsItemDividerEnabled())
1518 __pItemDrawingProperty->itemDividerEnabled = __pTableView->IsItemDividerEnabled();
1519 __pItemDrawingProperty->propertyChanged = true;
1522 if (__pItemDrawingProperty->dividerColor != __pTableView->GetItemDividerColor())
1524 __pItemDrawingProperty->dividerColor = __pTableView->GetItemDividerColor();
1525 __pItemDrawingProperty->propertyChanged = true;
1528 if (__pItemDrawingProperty->sectionStyleEnabled != (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION))
1530 __pItemDrawingProperty->sectionStyleEnabled = (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION);
1531 __pItemDrawingProperty->propertyChanged = true;
1534 if (__pItemDrawingProperty->sectionStyleBgColor != __pTableView->GetSectionColor())
1536 __pItemDrawingProperty->sectionStyleBgColor = __pTableView->GetSectionColor();
1537 __pItemDrawingProperty->propertyChanged = true;
1540 if (__pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SIMPLE)
1542 if (__pItemDrawingProperty->groupedLookEnabled != __pTableView->IsGroupedLookEnabled())
1544 __pItemDrawingProperty->groupedLookEnabled = __pTableView->IsGroupedLookEnabled();
1545 __pItemDrawingProperty->propertyChanged = true;
1549 if (__pItemDrawingProperty->reorderMode != __pTableView->IsReorderModeEnabled())
1551 __pItemDrawingProperty->reorderMode = __pTableView->IsReorderModeEnabled();
1552 __pItemDrawingProperty->propertyChanged = true;
1555 if (!_FloatCompare(__pItemDrawingProperty->leftMargin, __leftMargin))
1557 __pItemDrawingProperty->leftMargin = __leftMargin;
1558 __pItemDrawingProperty->propertyChanged = true;
1561 if (__pTableView->GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
1563 GET_SHAPE_CONFIG(TABLEVIEW::FASTSCROLL_INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __pItemDrawingProperty->scrollMargin);
1567 __pItemDrawingProperty->scrollMargin = 0;
1570 if (!_FloatCompare(__pItemDrawingProperty->width, __pTableView->GetBoundsF().width))
1572 __pItemDrawingProperty->width = __pTableView->GetBoundsF().width;
1573 __pItemDrawingProperty->propertyChanged = true;
1579 _TableViewPresenter::OnBoundsChanged(void)
1581 if (__pProviderAdaptor != null && __modelInitialized)
1583 float listWidth = __pTableView->GetBoundsF().width - (GetLeftMargin() * 2);
1585 if (!_FloatCompare(listWidth, __pProviderAdaptor->GetListWidth()))
1587 __pProviderAdaptor->SetListWidth(listWidth);
1588 SetItemDrawingProperty();
1590 AdjustLoadedItemWidth();
1593 SetClientAreaHeight(__itemTotalHeight);
1596 AdjustLayoutItems(GetScrollPosition());
1600 SetClientAreaHeight(__pTableView->GetBoundsF().height);
1601 _ScrollPanelPresenter::OnBoundsChanged();
1606 _TableViewPresenter::Draw(void)
1608 result r = _ScrollPanelPresenter::Draw();
1609 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1611 if (__modelInitialized == false)
1613 SetItemDrawingProperty();
1615 if(PreloadItem() == false)
1620 if (__reservedScrollItemIndex.groupIndex != -1 && __reservedScrollItemIndex.itemIndex != -1)
1622 ScrollToItem(__reservedScrollItemIndex.groupIndex, __reservedScrollItemIndex.itemIndex, __reservedScrollItemAlignment);
1624 __reservedScrollItemIndex.groupIndex = -1;
1625 __reservedScrollItemIndex.itemIndex = -1;
1631 __firstDrawnFlag = false;
1634 if (IsEmpty() == true)
1636 return DrawEmptyTableView();
1642 _UiTouchEventDelivery
1643 _TableViewPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
1645 _UiTouchEventDelivery response = _ScrollPanelPresenter::OnPreviewTouchPressed(source, touchInfo);
1647 _TableViewItem* pItem = GetTableViewItemFromControl(source);
1653 TableViewItemTag itemPos = {-1, -1};
1655 pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex);
1657 if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1)
1662 if (__pTableView->IsReorderModeEnabled())
1664 __firstTouchMoved = true;
1666 if (SelectReorderItem(itemPos.groupIndex, itemPos.itemIndex))
1668 __reorderInfo.touchPressedPositionY = touchInfo.GetCurrentPosition().y;
1675 _UiTouchEventDelivery
1676 _TableViewPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
1678 if (__pTableView->IsReorderModeEnabled())
1680 if (__reorderInfo.itemIndex != -1)
1682 if (!DragSelectedItem(touchInfo.GetCurrentPosition().y - __reorderInfo.touchPressedPositionY, true))
1684 __firstTouchMoved = false;
1686 ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex);
1689 return _UI_TOUCH_EVENT_DELIVERY_NO;
1693 return _ScrollPanelPresenter::OnPreviewTouchMoved(source, touchInfo);
1696 _UiTouchEventDelivery
1697 _TableViewPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
1699 if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1)
1701 ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex);
1703 if (__reorderInfo.blockedTouchReleaseState)
1705 __reorderInfo.blockedTouchReleaseState = false;
1707 return _UI_TOUCH_EVENT_DELIVERY_NO;
1711 return _ScrollPanelPresenter::OnPreviewTouchReleased(source, touchInfo);
1714 _UiTouchEventDelivery
1715 _TableViewPresenter::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
1717 return _ScrollPanelPresenter::OnPreviewTouchCanceled(source, touchInfo);
1721 _TableViewPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
1723 __firstTouchMoved = true;
1725 _TableViewItem* pItem = GetTableViewItemFromControl(source);
1732 TableViewItemTag itemPos = {-1, -1};
1733 pItem->GetItemIndex(itemPos.groupIndex, itemPos.itemIndex);
1735 if (!(pItem->IsContextItem()
1736 || pItem->IsItemEnabled() == false
1737 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE
1738 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER
1739 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER)
1740 && ((itemPos.groupIndex != __sweptItemTag.groupIndex)
1741 || (itemPos.itemIndex != __sweptItemTag.itemIndex)))
1746 __sweepOccured = false;
1748 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
1749 String animationName(L"EXPAND_GROUP_ANIMATION");
1750 VisualElementValueAnimation* pExpandGroupAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
1751 if (pExpandGroupAnimation != null)
1753 pVisualElement->RemoveAnimation(animationName);
1754 delete pExpandGroupAnimation;
1757 animationName = L"COLLAPSE_GROUP_ANIMATION";
1758 VisualElementValueAnimation* pCollapseGroupAnimation = dynamic_cast<VisualElementValueAnimation*>(pVisualElement->GetAnimationN(animationName));
1759 if (pCollapseGroupAnimation != null)
1761 pVisualElement->RemoveAnimation(animationName);
1762 delete pCollapseGroupAnimation;
1765 return _ScrollPanelPresenter::OnTouchPressed(source, touchInfo);
1769 _TableViewPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
1771 if (__pTableView->IsReorderModeEnabled())
1773 if (__reorderInfo.blockedScroll)
1778 return _ScrollPanelPresenter::OnTouchMoved(source, touchInfo);
1781 _TableViewItem* pItem = GetTableViewItemFromControl(source);
1783 || pItem->IsItemEnabled() == false
1784 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE
1785 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER
1786 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER
1787 || pItem->IsAnnexOnOffSliding())
1789 return _ScrollPanelPresenter::OnTouchMoved(source, touchInfo);;
1792 if (__firstTouchMoved)
1794 FloatPoint prevTouchPosition = GetPreviousTouchPosition();
1795 FloatPoint currTouchPosition = GetCurrentTouchPosition();
1796 float moveDistanceX = currTouchPosition.x - prevTouchPosition.x;
1797 float moveDistanceY = currTouchPosition.y - prevTouchPosition.y;
1799 if ((pItem->GetContextItem() != null && abs(moveDistanceX) > abs(moveDistanceY * 2)) || pItem->IsContextItem())
1801 if (!pItem->IsContextItem())
1803 pItem->GetItemIndex(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex);
1804 __sweptItemPosition = pItem->GetPositionF();
1806 pItem->AdjustContextItemBounds();
1809 __sweepOccured = true;
1814 return _ScrollPanelPresenter::OnTouchMoved(source, touchInfo);
1818 __firstTouchMoved = false;
1822 FloatPoint prevTouchPosition = GetPreviousTouchPosition();
1823 FloatPoint currTouchPosition = GetCurrentTouchPosition();
1825 SweepItem(currTouchPosition.x - prevTouchPosition.x);
1832 _TableViewPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
1834 _TableViewItem* pItem = GetTableViewItemFromControl(source);
1837 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_TITLE
1838 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_HEADER
1839 || pItem->GetItemType() == TABLE_VIEW_ITEM_TYPE_FOOTER)
1841 return _ScrollPanelPresenter::OnTouchReleased(source, touchInfo);
1846 if (pItem->IsContextItem())
1848 pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex));
1850 _TableViewItem* pContextItem = pItem->GetContextItem();
1853 if (pContextItem == null && __pTableView->IsSweepEnabled())
1855 FloatPoint prevPos = _ScrollPanelPresenter::GetPreviousTouchPosition();
1857 if (prevPos.x > touchInfo.GetCurrentPosition().x)
1859 pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_LEFT);
1861 else if (prevPos.x < touchInfo.GetCurrentPosition().x)
1863 pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_RIGHT);
1868 else if (pContextItem != null)
1870 AdjustSweptItemPosition(true);
1874 return _ScrollPanelPresenter::OnTouchReleased(source, touchInfo);
1878 _TableViewPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
1880 if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1)
1882 ResetReorderItem(__reorderInfo.groupIndex, __reorderInfo.itemIndex);
1886 return _ScrollPanelPresenter::OnTouchCanceled(source, touchInfo);
1890 _TableViewPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1892 if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1)
1897 _FlickDirection flickDirection = gesture.GetDirection();
1899 if (flickDirection != _FLICK_DIRECTION_RIGHT && flickDirection != _FLICK_DIRECTION_LEFT)
1901 return _ScrollPanelPresenter::OnFlickGestureDetected(gesture);
1904 _Control* gestureControl = gesture.GetControl();
1906 if (gestureControl == null)
1908 return _ScrollPanelPresenter::OnFlickGestureDetected(gesture);
1911 _TableViewItem* pItem = GetTableViewItemFromControl(*gestureControl);
1915 return _ScrollPanelPresenter::OnFlickGestureDetected(gesture);
1918 if (flickDirection == _FLICK_DIRECTION_RIGHT)
1921 if (pItem->GetContextItem() == null && __pTableView->IsSweepEnabled())
1923 pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_RIGHT);
1927 if (pItem->GetContextItem() != null)
1929 AdjustSweptItemPosition();
1933 else if (flickDirection == _FLICK_DIRECTION_LEFT)
1936 if (pItem->GetContextItem() == null && __pTableView->IsSweepEnabled())
1938 pItem->FireItemSweepEvent(TABLE_VIEW_SWEEP_DIRECTION_LEFT);
1942 if (pItem->GetContextItem() != null)
1944 AdjustSweptItemPosition();
1953 _TableViewPresenter::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1955 return _ScrollPanelPresenter::OnFlickGestureCanceled(gesture);
1959 _TableViewPresenter::OnPreviewFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1961 if (__pTableView->IsReorderModeEnabled() && __reorderInfo.itemIndex != -1)
1966 _FlickDirection flickDirection = gesture.GetDirection();
1967 if (flickDirection != _FLICK_DIRECTION_RIGHT && flickDirection != _FLICK_DIRECTION_LEFT)
1969 return _ScrollPanelPresenter::OnFlickGestureDetected(gesture);
1976 _TableViewPresenter::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
1978 _ScrollPanelPresenter::OnTimerExpired(timer);
1980 if (&timer == __pReorderScrollTimer)
1982 float distance = 0.0f;
1984 if (__reorderInfo.isScrollDirectionUp)
1986 distance = -REORDER_SCROLL_ANIMATION_DISTANCE;
1990 distance = REORDER_SCROLL_ANIMATION_DISTANCE;
1993 DragSelectedItem(distance, false);
1995 distance = ScrollTo(distance + GetScrollPosition());
1997 StartReorderScrollTimer();
1999 else if (&timer == __pFastScrollTimer)
2001 __isFastScrollTimerEnabled = false;
2003 _FastScroll* pFastScroll = __pTableView->GetFastScrollBar();
2005 if (pFastScroll != null && !_ScrollPanelPresenter::IsScrollAnimationRunning())
2007 pFastScroll->SetScrollVisibility(false);
2013 _TableViewPresenter::StartFastScrollTimer(void)
2015 result r = E_SUCCESS;
2017 SysTryReturn(NID_UI_CTRL, __pFastScrollTimer != null, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Timer is not created.");
2019 r = __pFastScrollTimer->Start(FAST_SCROLL_FADE_OUT_DURATION);
2020 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2022 __isFastScrollTimerEnabled = true;
2028 _TableViewPresenter::StopFastScrollTimer(void)
2030 result r = E_SUCCESS;
2032 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollTimer != null, E_INVALID_STATE, "[E_INVALID_STATE] Timer is invalid.");
2034 r = __pFastScrollTimer->Cancel();
2035 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2037 __isFastScrollTimerEnabled = false;
2043 _TableViewPresenter::IsEmpty(void) const
2045 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
2047 if (GetItemCountAt(0) <= 0)
2054 if (GetGroupCount() <= 0 )
2064 _TableViewPresenter::DrawEmptyTableView(void)
2070 _TableViewPresenter::GetFirstItem(TableViewItemTag& firstItem) const
2074 firstItem.groupIndex = -1;
2075 firstItem.itemIndex = -1;
2079 firstItem.groupIndex = 0;
2080 firstItem.itemIndex = -1;
2087 _TableViewPresenter::GetLastItem(TableViewItemTag& lastItem) const
2091 lastItem.groupIndex = -1;
2092 lastItem.itemIndex = -1;
2096 lastItem.groupIndex = GetGroupCount() - 1;
2097 lastItem.itemIndex = GetItemCountAt(lastItem.groupIndex) - 1;
2104 _TableViewPresenter::GetTopDrawnItem(TableViewItemTag& itemPos) const
2106 _TableViewItem* pItem = null;
2107 TableViewItemTag lastItemPos = {-1, -1};
2108 float scrollPosition = 0.0f;
2110 scrollPosition = GetScrollPosition();
2112 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
2113 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
2117 pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex));
2123 FloatRectangle itemBounds = pItem->GetBoundsF();
2125 if (scrollPosition < (itemBounds.y + itemBounds.height))
2130 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
2135 } while (GetNextItemPosition(itemPos, itemPos) == true);
2138 itemPos.itemIndex = -1;
2139 itemPos.groupIndex = -1;
2141 return E_OUT_OF_RANGE;
2145 _TableViewPresenter::GetBottomDrawnItem(TableViewItemTag& itemPos) const
2147 _TableViewItem* pItem = null;
2148 TableViewItemTag lastItemPos = {-1, -1};
2152 itemPos.itemIndex = -1;
2153 itemPos.groupIndex = -1;
2155 return E_INVALID_STATE;
2158 float scrollPosition = GetScrollPosition() + __pTableView->GetBoundsF().height;
2160 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
2161 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
2165 static bool onProcessingByProvider = true;
2166 pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex));
2167 onProcessingByProvider = false;
2173 FloatRectangle itemBounds = pItem->GetBoundsF();
2175 if (itemBounds.y <= scrollPosition && scrollPosition <= (itemBounds.y + itemBounds.height))
2180 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
2185 } while (GetNextItemPosition(itemPos, itemPos) == true);
2191 _TableViewPresenter::GetPreviousItemPosition(const TableViewItemTag& currentItemPos, TableViewItemTag& prevItem) const
2198 // check validation of group index
2199 if ((currentItemPos.groupIndex < 0) || (currentItemPos.groupIndex >= __pListModel->GetAllGroupCount()))
2204 // if the current item is the first item
2205 if (currentItemPos.groupIndex == 0 && currentItemPos.itemIndex == -1)
2210 if (currentItemPos.itemIndex == -1)
2212 if (__pListModel->IsGroupExpanded(currentItemPos.groupIndex - 1) == false)
2214 prevItem.groupIndex = currentItemPos.groupIndex - 1;
2215 prevItem.itemIndex = -1;
2221 if (__pListModel->IsGroupExpanded(currentItemPos.groupIndex) == false)
2223 if (currentItemPos.groupIndex == 0 && currentItemPos.itemIndex == -1)
2228 prevItem.groupIndex = currentItemPos.groupIndex - 1;
2229 prevItem.itemIndex = __pListModel->GetItemCountInGroup(prevItem.groupIndex) - 1;
2234 if (currentItemPos.itemIndex == -1) // group title item
2236 prevItem.groupIndex = currentItemPos.groupIndex - 1;
2237 prevItem.itemIndex = __pListModel->GetItemCountInGroup(prevItem.groupIndex) - 1;
2241 prevItem.groupIndex = currentItemPos.groupIndex;
2242 prevItem.itemIndex = currentItemPos.itemIndex - 1;
2249 _TableViewPresenter::GetNextItemPosition(const TableViewItemTag& currentItem, TableViewItemTag& nextItem) const
2256 int lastGroup = __pListModel->GetAllGroupCount() - 1;
2257 int lastItemInCurrentGroup = __pListModel->GetItemCountInGroup(currentItem.groupIndex) - 1;
2258 int lastItem = __pListModel->GetItemCountInGroup(lastGroup) - 1;
2260 // check validation of group index
2261 if ((currentItem.groupIndex < 0) || (currentItem.groupIndex > lastGroup))
2266 // if the current item is the last item.
2267 if ((currentItem.groupIndex == lastGroup) && (currentItem.itemIndex == lastItem))
2272 if (__pListModel->IsGroupExpanded(currentItem.groupIndex) == false)
2274 if (currentItem.groupIndex == lastGroup)
2279 nextItem.groupIndex = currentItem.groupIndex + 1;
2280 nextItem.itemIndex = -1;
2285 if (lastItemInCurrentGroup == currentItem.itemIndex)
2287 nextItem.groupIndex = currentItem.groupIndex + 1;
2288 nextItem.itemIndex = -1;
2292 nextItem.groupIndex = currentItem.groupIndex;
2293 nextItem.itemIndex = currentItem.itemIndex + 1;
2300 _TableViewPresenter::GetHeightOfAllItems(void) const
2302 int groupCount = GetGroupCount();
2303 float totalHeight = 0;
2305 for (int i = 0; i < groupCount; i++)
2307 TableViewItemTag itemTag = {i, -1};
2309 totalHeight += GetItemHeight(itemTag);
2311 if (!IsGroupExpanded(i))
2316 int itemCount = GetItemCountAt(i);
2318 for (int j = 0; j < itemCount; j++)
2320 itemTag.itemIndex = j;
2322 totalHeight += GetItemHeight(itemTag);
2330 _TableViewPresenter::SetTableViewItemProviderAdaptor(_TableViewItemProviderAdaptor* pProviderAdaptor)
2332 __pListModel->RegisterItemProviderAdaptor(pProviderAdaptor);
2334 __pProviderAdaptor = pProviderAdaptor;
2336 if (__pProviderAdaptor != null)
2338 __pProviderAdaptor->SetTableViewPresenter(this);
2342 _TableViewItemProviderAdaptor*
2343 _TableViewPresenter::GetTableViewItemProviderAdaptor(void) const
2345 return __pProviderAdaptor;
2349 _TableViewPresenter::ExpandGroup(int groupIndex, bool withAnimation)
2351 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()))
2353 return E_OUT_OF_RANGE;
2356 if (__modelInitialized == false)
2358 return E_INVALID_STATE;
2361 if (IsGroupExpanded(groupIndex) == true)
2366 TableViewItemTag topTag;
2367 GetTopDrawnItem(topTag);
2369 TableViewItemTag bottomTag;
2370 GetBottomDrawnItem(bottomTag);
2372 float screenPosition = GetScrollPosition();
2374 __pListModel->SetGroupExpandState(groupIndex, true);
2376 float groupTotalHeight = 0.0f;
2377 int itemCount = GetItemCountAt(groupIndex);
2378 _TableViewItem* pItem = null;
2379 for (int i = 0; i < itemCount; i++)
2381 pItem = static_cast<_TableViewItem*>(__pListModel->GetItemFromTemporaryBuffer(groupIndex, i));
2382 groupTotalHeight += pItem->GetItemHeight();
2385 AdjustClientAreaBounds(false, groupTotalHeight);
2387 if (groupIndex < topTag.groupIndex || groupIndex > bottomTag.groupIndex)
2389 int firstLoadedGroupIndex = -1;
2390 int firstLoadedItemIndex = -1;
2391 __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex);
2393 TableViewItemTag firstLoadedItemTag = {firstLoadedGroupIndex, firstLoadedItemIndex};
2394 _TableViewItem* pItem = FindItem(firstLoadedItemTag);
2397 float itemPositionY = CalculateItemPositionY(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex);
2399 FloatRectangle itemBounds = pItem->GetBoundsF();
2400 itemBounds.y = itemPositionY;
2401 pItem->SetBounds(itemBounds);
2403 AttachNextItemsToBottom(firstLoadedItemTag);
2404 if (groupIndex < topTag.groupIndex)
2406 _ScrollPanelPresenter::ScrollTo(screenPosition + groupTotalHeight);
2413 TableViewItemTag itemTag;
2414 itemTag.groupIndex = groupIndex;
2415 itemTag.itemIndex = -1;
2417 __expandableItemTag.groupIndex = groupIndex;
2418 __expandableItemTag.itemIndex = -1;
2422 _TableViewItem *pItem = FindItem(itemTag);
2428 FloatRectangle itemBounds = pItem->GetBoundsF();
2429 float startPosition = itemBounds.y + itemBounds.height;
2431 float endPosition = startPosition + groupTotalHeight;
2432 if (!_FloatCompareLE(endPosition, screenPosition + __pTableView->GetBoundsF().height))
2434 endPosition = screenPosition + __pTableView->GetBoundsF().height;
2437 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
2438 String animationName(L"EXPAND_GROUP_ANIMATION");
2440 VisualElementValueAnimation* pAnimation = __pTableView->GetVisualElementValueAnimation(animationName);
2441 pAnimation->SetStartValue(Variant(startPosition));
2442 pAnimation->SetEndValue(Variant(endPosition));
2443 pAnimation->SetDuration(EXPAND_GROUP_ANIMATION_DURATION);
2444 pVisualElement->AddAnimation(animationName, *pAnimation);
2448 ExpandGroupAnimationFinished(false);
2455 _TableViewPresenter::CollapseGroup(int groupIndex, bool withAnimation)
2457 if ((groupIndex < 0) || (groupIndex >= GetGroupCount()))
2459 return E_OUT_OF_RANGE;
2462 if (__modelInitialized == false)
2464 return E_INVALID_STATE;
2467 if (IsGroupExpanded(groupIndex) == false)
2472 TableViewItemTag itemTag;
2473 GetTopDrawnItem(itemTag);
2475 TableViewItemTag bottomTag;
2476 GetBottomDrawnItem(bottomTag);
2477 float screenPosition = GetScrollPosition();
2479 __pListModel->SetGroupExpandState(groupIndex, false);
2483 float groupTotalHeight = 0;
2484 int itemCount = GetItemCountAt(groupIndex);
2485 _TableViewItem* pItem = null;
2486 for (int i = 0; i < itemCount; i++)
2488 pItem = static_cast<_TableViewItem*>(__pListModel->GetItemFromTemporaryBuffer(groupIndex, i));
2489 groupTotalHeight += pItem->GetItemHeight();
2492 if (groupIndex < itemTag.groupIndex || groupIndex > bottomTag.groupIndex)
2494 TableViewItemTag firstLoadedItemTag;
2495 __pListModel->GetFirstLoadedItemIndex(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex);
2497 if (firstLoadedItemTag.groupIndex == groupIndex)
2499 SetLoadedItemsVisibleInGroup(groupIndex, false);
2500 firstLoadedItemTag.groupIndex = groupIndex + 1;
2501 firstLoadedItemTag.itemIndex = -1;
2504 _TableViewItem* pItem = FindItem(firstLoadedItemTag);
2507 float itemPositionY = CalculateItemPositionY(firstLoadedItemTag.groupIndex, firstLoadedItemTag.itemIndex);
2509 FloatRectangle itemBounds = pItem->GetBoundsF();
2510 itemBounds.y = itemPositionY;
2511 pItem->SetBounds(itemBounds);
2513 AttachNextItemsToBottom(firstLoadedItemTag);
2514 if (groupIndex < itemTag.groupIndex)
2516 _ScrollPanelPresenter::ScrollTo(screenPosition - groupTotalHeight);
2520 for (int i = 0; i < itemCount; i++)
2522 UnloadItem(groupIndex, i);
2524 AdjustClientAreaBounds(false, -groupTotalHeight);
2529 if (itemTag.groupIndex < groupIndex)
2531 itemTag.groupIndex = groupIndex;
2532 itemTag.itemIndex = -1;
2534 __expandableItemTag.groupIndex = itemTag.groupIndex;
2535 __expandableItemTag.itemIndex = itemTag.itemIndex;
2537 if(__firstDrawnFlag)
2539 withAnimation = false;
2544 _TableViewItem *pItem = FindItem(itemTag);
2550 FloatRectangle itemBounds = pItem->GetBoundsF();
2551 float startPosition = 0;
2552 if (itemTag.itemIndex == -1)
2554 startPosition = itemBounds.y + itemBounds.height;
2558 startPosition = GetScrollPosition();
2561 if (bottomTag.groupIndex > groupIndex)
2563 bottomTag.groupIndex = groupIndex+1;
2564 bottomTag.itemIndex = -1;
2567 pItem = FindItem(bottomTag);
2573 itemBounds = pItem->GetBoundsF();
2574 float endPosition = itemBounds.y;
2575 if (bottomTag.groupIndex != groupIndex +1)
2577 endPosition += itemBounds.height;
2580 if (!_FloatCompareLE(endPosition, screenPosition + __pTableView->GetBoundsF().height))
2582 endPosition = screenPosition + __pTableView->GetBoundsF().height;
2585 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
2586 String animationName(L"COLLAPSE_GROUP_ANIMATION");
2588 VisualElementValueAnimation* pAnimation = __pTableView->GetVisualElementValueAnimation(animationName);
2589 pAnimation->SetStartValue(Variant(endPosition));
2590 pAnimation->SetEndValue(Variant(startPosition));
2591 pAnimation->SetDuration(COLLAPSE_GROUP_ANIMATION_DURATION);
2592 pVisualElement->AddAnimation(animationName, *pAnimation);
2596 CollapseGroupAnimationFinished(false);
2599 AdjustClientAreaBounds(false, -groupTotalHeight);
2605 _TableViewPresenter::IsGroupExpanded(int groupIndex) const
2607 return __pListModel->IsGroupExpanded(groupIndex);
2611 _TableViewPresenter::LoadAllItemsInGroup(int groupIndex, bool downward)
2613 int itemCountInGroup = __pListModel->GetItemCountInGroup(groupIndex);
2614 _TableViewItem* pItem = null;
2618 for (int i = 0; i < itemCountInGroup; i++)
2620 pItem = LoadItem(groupIndex, i);
2624 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to load item.");
2630 for (int i = itemCountInGroup-1; i >= 0; i--)
2632 pItem = LoadItem(groupIndex, i);
2636 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Unable to load item.");
2641 return itemCountInGroup;
2645 _TableViewPresenter::SetLoadedItemsVisibleInGroup(int groupIndex, bool visible)
2647 int itemCountInGroup = __pListModel->GetItemCountInGroup(groupIndex);
2648 _TableViewItem* pItem = null;
2649 TableViewItemTag itemTag;
2650 itemTag.groupIndex = groupIndex;
2652 int firstLoadedGroupIndex = -1;
2653 int firstLoadedItemIndex = -1;
2654 __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex);
2656 if (firstLoadedGroupIndex > groupIndex)
2662 if (groupIndex == firstLoadedGroupIndex && firstLoadedItemIndex > 0)
2664 startIndex = firstLoadedItemIndex;
2667 for (int i = startIndex; i < itemCountInGroup; i++)
2669 itemTag.itemIndex = i;
2670 pItem = FindItem(itemTag);
2676 pItem->SetVisibleState(visible);
2681 _TableViewPresenter::LoadItemsToBeVisible(const TableViewItemTag& from)
2683 TableViewItemTag bottomTag = from;
2684 TableViewItemTag current;
2685 TableViewItemTag next;
2687 _TableViewItem *pItem = LoadItem(from.groupIndex, from.itemIndex);
2694 FloatRectangle itemBounds = pItem->GetBoundsF();
2695 float viewHeight = __pTableView->GetBoundsF().height;
2696 float scrollPosition = GetScrollPosition();
2697 float itemPosition = itemBounds.y + itemBounds.height - scrollPosition;
2699 while (viewHeight >= itemPosition)
2701 current.groupIndex = bottomTag.groupIndex;
2702 current.itemIndex = bottomTag.itemIndex;
2703 if (!GetNextItemPosition(current, next))
2708 pItem = LoadItem(next.groupIndex, next.itemIndex);
2709 bottomTag.groupIndex = next.groupIndex;
2710 bottomTag.itemIndex = next.itemIndex;
2711 itemPosition += pItem->GetBoundsF().height;
2718 _TableViewPresenter::AttachNextItemsToBottom(const TableViewItemTag& anchor)
2720 TableViewItemTag itemTag = anchor;
2721 TableViewItemTag current;
2722 TableViewItemTag next;
2724 _TableViewItem *pItem = FindItem(itemTag);
2730 FloatRectangle itemBounds = pItem->GetBoundsF();
2731 float itemPosition = itemBounds.y + itemBounds.height;
2733 current.groupIndex = itemTag.groupIndex;
2734 current.itemIndex = itemTag.itemIndex;
2735 while (GetNextItemPosition(current, next))
2737 pItem = FindItem(next);
2744 itemBounds = pItem->GetBoundsF();
2745 itemBounds.y = itemPosition;
2746 pItem->SetBounds(itemBounds);
2747 itemPosition += itemBounds.height;
2753 _TableViewPresenter::IsAnyItemInGroupLoaded(int groupIndex) const
2755 int startGroupIndex = 0;
2756 int endGroupIndex = 0;
2759 __pListModel->GetFirstLoadedItemIndex(startGroupIndex, index);
2760 __pListModel->GetLastLoadedItemIndex(endGroupIndex, index);
2762 return groupIndex >= startGroupIndex && groupIndex <= endGroupIndex;
2766 _TableViewPresenter::ScrollToHideNonClientArea(TableViewItemTag& bottomTag)
2768 _TableViewItem* pItem = FindItem(bottomTag);
2774 FloatRectangle itemBounds = pItem->GetBoundsF();
2775 float viewHeight = __pTableView->GetBoundsF().height;
2776 float scrollPosition = GetScrollPosition();
2777 float itemBottom = itemBounds.y + itemBounds.height - scrollPosition;
2779 if (itemBottom < viewHeight)
2781 scrollPosition -= viewHeight - itemBottom;
2782 if (scrollPosition < 0)
2787 SetScrollPosition(scrollPosition, false);
2792 _TableViewPresenter::AdjustClientAreaBounds(bool reset, float dist)
2794 float clientHeight = 0;
2798 __itemTotalHeight = GetHeightOfAllItems();
2799 clientHeight = __itemTotalHeight;
2803 __itemTotalHeight = __itemTotalHeight + dist;
2804 clientHeight = __itemTotalHeight;
2807 SetClientAreaHeight(clientHeight);
2811 _TableViewPresenter::SetClientAreaHeight(float height)
2813 FloatRectangle screenBounds = __pTableView->GetBoundsF();
2814 FloatRectangle clientBounds = screenBounds;
2816 clientBounds.height = height;
2818 if (clientBounds.height < screenBounds.height)
2820 clientBounds.height = screenBounds.height;
2823 SetScrollAreaBounds(clientBounds);
2825 _Scroll* pScroll = __pTableView->GetScrollBar();
2826 if (pScroll != null)
2828 pScroll->SetScrollRange(__pTableView->GetBoundsF().height, clientBounds.height);
2833 _TableViewPresenter::UnloadInvisibleItems(void)
2835 float scrollPosition = GetScrollPosition();
2836 TableViewItemTag itemTag;
2837 __pListModel->GetFirstLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex);
2839 _TableViewItem* pItem = null;
2840 FloatRectangle bounds;
2842 while ((pItem = FindItem(itemTag)) != null)
2844 if (itemTag.itemIndex != -1)
2846 bounds = pItem->GetBoundsF();
2847 if (bounds.y + bounds.height < scrollPosition)
2849 UnloadItem(itemTag);
2856 __pListModel->GetFirstLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex);
2859 __pListModel->GetLastLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex);
2860 scrollPosition += __pTableView->GetBoundsF().height;
2862 while ((pItem = FindItem(itemTag)) != null)
2864 if (itemTag.itemIndex != -1)
2866 bounds = pItem->GetBoundsF();
2867 if (bounds.y > scrollPosition)
2869 UnloadItem(itemTag);
2876 __pListModel->GetLastLoadedItemIndex(itemTag.groupIndex, itemTag.itemIndex);
2882 _TableViewPresenter::ScrollToInternal(float newPosition)
2884 if (!IsScrollEnabled())
2891 if (IsScrollAnimationRunning())
2893 if (__scrollPositionOnFlickStarted > newPosition)
2895 newPosition += GetScrollAreaBounds().height - __scrollHeightOnFlickStarted;
2899 float currentScrollPosition = GetScrollPosition();
2900 float currentscrollAreaHeight = GetScrollAreaBounds().height;
2901 float newScrollPosition = (newPosition < 0) ? 0 : (newPosition > currentscrollAreaHeight ? currentscrollAreaHeight : newPosition);
2902 float newScrollAreaHeight = 0;
2904 LoadItemWithScrollPosition(currentScrollPosition, newScrollPosition);
2906 if (currentScrollPosition > newScrollPosition)
2908 newScrollAreaHeight = GetScrollAreaBounds().height;
2909 newScrollPosition += newScrollAreaHeight - currentscrollAreaHeight;
2912 return _ScrollPanelPresenter::ScrollToInternal(newScrollPosition);
2916 _TableViewPresenter::LoadItemWithScrollPosition(float previousScrollPosition, float currentScrollPos)
2920 TableViewItemTag lastLoadedItemPos = {-1, -1};
2921 TableViewItemTag firstLoadedItemPos = {-1, -1};
2922 __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex);
2923 __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex);
2925 if (currentScrollPos > previousScrollPosition && lastLoadedItemPos.groupIndex != -1)
2927 _TableViewItem* pLastItem = FindItem(lastLoadedItemPos);
2928 if (pLastItem == null)
2933 while (pLastItem->GetBoundsF().y <= currentScrollPos + __pTableView->GetBoundsF().height)
2935 TableViewItemTag nextItemPos = {-1, -1};
2936 if (GetNextItemPosition(lastLoadedItemPos, nextItemPos))
2938 if (nextItemPos.itemIndex == -1)
2940 LoadItem(nextItemPos.groupIndex, nextItemPos.itemIndex);
2942 if (!GetNextItemPosition(nextItemPos, nextItemPos))
2948 if (nextItemPos.groupIndex != -1)
2950 _TableViewItem* item = LoadItem(nextItemPos.groupIndex, nextItemPos.itemIndex);
2952 FloatRectangle scrollAreaBounds = GetScrollAreaBounds();
2953 if (item->GetBoundsF().y + item->GetBoundsF().height >= scrollAreaBounds.height)
2955 AdjustClientAreaBounds(true);
2964 lastLoadedItemPos = nextItemPos;
2965 pLastItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex));
2969 if (currentScrollPos < previousScrollPosition && firstLoadedItemPos.groupIndex != -1)
2971 _TableViewItem* pFirstItem = FindItem(firstLoadedItemPos);
2972 _TableViewItem* pPrevItem = null;
2973 if (pFirstItem == null)
2978 float scrollOffsetFromBottom = GetScrollAreaBounds().height - currentScrollPos;
2982 FloatRectangle scrollAreaBounds = GetScrollAreaBounds();
2983 float itemOffsetFromBottom = scrollAreaBounds.height - (pFirstItem->GetBoundsF().y + pFirstItem->GetBoundsF().height);
2985 if (scrollOffsetFromBottom < itemOffsetFromBottom)
2990 TableViewItemTag prevItemPos = {-1, -1};
2991 if (GetPreviousItemPosition(firstLoadedItemPos, prevItemPos))
2993 if (prevItemPos.itemIndex == -1)
2995 pPrevItem = LoadItem(prevItemPos.groupIndex, prevItemPos.itemIndex);
2997 if (!GetPreviousItemPosition(prevItemPos, prevItemPos))
3003 if (prevItemPos.groupIndex != -1)
3005 pPrevItem = LoadItem(prevItemPos.groupIndex, prevItemPos.itemIndex);
3013 firstLoadedItemPos = prevItemPos;
3014 pFirstItem = FindItem(firstLoadedItemPos);
3020 _TableViewPresenter::ScrollToItem(int groupIndex, int itemIndex, TableViewScrollItemAlignment itemAlignment, float shiftingDistance)
3022 TableViewItemTag itemPos = {groupIndex, itemIndex};
3024 StopAllItemAnimation();
3026 if (!__pListModel->IsLoadedItem(groupIndex, itemIndex))
3028 ResetItemLayout(itemPos);
3031 _TableViewItem* pItem = FindItem(itemPos);
3038 float scrollPosition = pItem->GetBoundsF().y;
3040 scrollPosition = scrollPosition + shiftingDistance;
3042 SetScrollPosition(scrollPosition, false);
3044 if (itemAlignment == TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM)
3046 SetScrollPosition(scrollPosition - (__pTableView->GetBoundsF().height - pItem->GetBoundsF().height), false);
3051 _TableViewPresenter::ScrollByPixel(float scrollDistance)
3054 result r = GetLastResult();
3055 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3057 ScrollTo(scrollDistance + GetScrollPosition());
3058 r = GetLastResult();
3059 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3061 RollbackBouncing(true);
3062 r = GetLastResult();
3063 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3066 r = GetLastResult();
3067 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3073 _TableViewPresenter::SetScrollEnabled(bool enable)
3075 __scrolling = enable;
3079 _TableViewPresenter::IsScrollEnabled(void) const
3085 _TableViewPresenter::GetFirstDrawnFlag(void) const
3087 return __firstDrawnFlag;
3091 _TableViewPresenter::GetMaxItemCachingSize(void) const
3093 return __pListModel->GetMaxCachingSize();
3097 _TableViewPresenter::ResetSweepItem(void)
3099 if (__sweptItemTag.groupIndex != -1 && __sweptItemTag.itemIndex != -1)
3106 _TableViewPresenter::GetSweepItemIndex(int& groupIndex, int& itemIndex) const
3108 groupIndex = __sweptItemTag.groupIndex;
3109 itemIndex = __sweptItemTag.itemIndex;
3113 _TableViewPresenter::GetPressedItemCount(void)
3115 _TableViewItem* pItem = null;
3116 TableViewItemTag itemPos = {-1, -1};
3117 TableViewItemTag lastItemPos = {-1, -1};
3120 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
3121 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
3125 pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex));
3131 if (pItem->GetDrawingStatus() == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3136 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
3140 } while (GetNextItemPosition(itemPos, itemPos) == true);
3146 _TableViewPresenter::BlockAnimationCallback(bool blocked)
3148 __isAnimationCallbackBlocked = blocked;
3152 _TableViewPresenter::CalculateItemPositionY(int groupIndex, int itemIndex)
3154 TableViewItemTag itemPos = {-1, -1};
3155 TableViewItemTag currentItemPos = {-1, -1};
3156 float positionY = 0.0f;
3158 GetFirstItem(itemPos);
3160 if (itemPos.groupIndex == -1 && itemPos.itemIndex == -1)
3165 if (__pProviderAdaptor == null)
3170 positionY = GetTopMargin();
3172 while ((itemPos.groupIndex < groupIndex) || ((itemPos.groupIndex == groupIndex) && (itemPos.itemIndex < itemIndex)))
3174 currentItemPos = itemPos;
3176 float itemHeight = GetItemHeight(itemPos);
3178 positionY += itemHeight;
3180 if (!GetNextItemPosition(currentItemPos, itemPos))
3190 _TableViewPresenter::FadeInScrollBar(void)
3192 TableViewScrollBarStyle scrollStyle = __pTableView->GetScrollStyle();
3194 if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_NONE)
3196 _Scroll* pScroll = __pTableView->GetScrollBar();
3198 if (pScroll != null)
3200 pScroll->SetVisibleState(false);
3203 else if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
3205 _Scroll* pScroll = __pTableView->GetScrollBar();
3207 if (pScroll != null)
3209 pScroll->SetVisibleState(false);
3212 _FastScroll* pFastScroll = __pTableView->GetFastScrollBar();
3214 if (pFastScroll != null)
3216 pFastScroll->SetScrollVisibility(true);
3221 _ScrollPanelPresenter::FadeInScrollBar();
3226 _TableViewPresenter::FadeOutScrollBar(void)
3228 TableViewScrollBarStyle scrollStyle = __pTableView->GetScrollStyle();
3229 if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL)
3231 StopFastScrollTimer();
3233 if (!_ScrollPanelPresenter::IsScrollAnimationRunning())
3235 StartFastScrollTimer();
3238 else if (scrollStyle == TABLE_VIEW_SCROLL_BAR_STYLE_FIXED)
3240 _Scroll* pScroll = __pTableView->GetScrollBar();
3242 if (pScroll != null)
3244 pScroll->SetScrollingEffectVisibility(false);
3249 _ScrollPanelPresenter::FadeOutScrollBar();
3254 _TableViewPresenter::SweepItem(float x)
3256 if (!_FloatCompare(x, 0.0f))
3258 _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex));
3262 _TableViewItem* pContextItem = pItem->GetContextItem();
3264 if (pContextItem != null)
3266 float currentPosition = __sweptItemPosition.x + x;
3267 float sweepDistance = __pTableView->GetBoundsF().width;
3268 float sweepMargin = 0.0f;
3269 float contextItemWidth = pItem->GetBoundsF().width;
3270 bool activated = pItem->IsContextItemActivated();
3271 bool needToFireEvent = false;
3273 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sweepMargin);
3275 if (currentPosition >= (sweepDistance - sweepMargin))
3277 currentPosition = (sweepDistance - sweepMargin);
3278 needToFireEvent = !activated;
3280 else if (currentPosition <= __leftMargin)
3282 currentPosition = __leftMargin;
3283 needToFireEvent = activated;
3286 __sweptItemPosition.x = currentPosition;
3288 // Set TableViewItem bounds
3289 pItem->SetPosition(__sweptItemPosition);
3291 // Set TableViewContextItem bounds
3292 if (!__pTableView->IsAncestorOf(*pContextItem))
3294 pContextItem->SetDrawingProperty(__pItemDrawingProperty);
3295 __pTableView->InsertChildToBottom(*pContextItem);
3298 contextItemWidth = ((contextItemWidth > (__sweptItemPosition.x - __leftMargin)) ? (__sweptItemPosition.x - __leftMargin) : contextItemWidth);
3300 pContextItem->ExposeContextItem(FloatRectangle(__leftMargin, __sweptItemPosition.y, contextItemWidth, pContextItem->GetSizeF().height), pItem->GetSize().width);
3302 if (needToFireEvent)
3304 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_SLIDER_SWEEP);
3306 activated = !activated; // ContextItem Activation State Changed
3308 __pTableView->FireTableViewContextItemActivationEvent(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex, pContextItem, activated);
3309 pItem->SetContextItemActivation(activated);
3322 _TableViewPresenter::ResetSweptItem(void)
3324 _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex));
3328 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
3330 if (pVisualElement != null)
3332 String animationName(L"SWEEP_ITEM_ANIMATION");
3333 VisualElementAnimation* pContextItemAnimation = pVisualElement->GetAnimationN(animationName);
3334 if (pContextItemAnimation != null)
3336 pVisualElement->RemoveAnimation(animationName);
3338 delete pContextItemAnimation;
3342 pItem->SetPosition(FloatPoint(__leftMargin, __sweptItemPosition.y));
3344 _TableViewItem* pContextItem = pItem->GetContextItem();
3345 if (pContextItem != null)
3347 if (__pTableView->IsAncestorOf(*pContextItem))
3349 __pTableView->DetachChild(*pContextItem);
3352 if (pItem->IsContextItemActivated())
3354 __pTableView->FireTableViewContextItemActivationEvent(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex, pContextItem, false);
3355 pItem->SetContextItemActivation(false);
3360 __sweptItemTag.itemIndex = -1;
3361 __sweptItemTag.groupIndex = -1;
3363 __sweptItemPosition.SetPosition(-1.0f, -1.0f);
3364 __sweepOccured = false;
3368 _TableViewPresenter::AdjustSweptItemPosition(bool withAnimation)
3370 float itemWidth = __pTableView->GetBoundsF().width;
3371 float sweepDistance = 0.0f;
3373 if (_FloatCompare(__sweptItemPosition.x, __leftMargin))
3379 float sweepMargin = 0.0f;
3380 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sweepMargin);
3382 if (__sweptItemPosition.x > (itemWidth - sweepMargin) / 2)
3384 sweepDistance = itemWidth - __sweptItemPosition.x;
3388 sweepDistance = -__sweptItemPosition.x;
3393 SweepItem(sweepDistance);
3397 _TableViewItem* pItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(__sweptItemTag.groupIndex, __sweptItemTag.itemIndex));
3401 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
3403 if (pVisualElement != null)
3405 String animationName(L"SWEEP_ITEM_ANIMATION");
3406 float startValue = __sweptItemPosition.x;
3407 float endValue = ((sweepDistance > 0) ? (itemWidth - sweepMargin) : __leftMargin);
3409 pVisualElement->SetImplicitAnimationEnabled(false);
3411 VisualElementValueAnimation* pAnimation = __pTableView->GetVisualElementValueAnimation(animationName);
3412 pAnimation->SetStartValue(Variant(startValue));
3413 pAnimation->SetEndValue(Variant(endValue));
3414 pAnimation->SetDuration(SWEEP_ITEM_ANIMATION_DURATION);
3415 pVisualElement->AddAnimation(animationName, *pAnimation);
3422 _TableViewPresenter::AdjustLoadedItemWidth(void)
3424 TableViewItemTag lastLoadedItemPos = {-1, -1};
3425 TableViewItemTag firstLoadedItemPos = {-1, -1};
3426 __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex);
3427 __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex);
3431 _TableViewItem* pItem = FindItem(firstLoadedItemPos);
3438 FloatDimension itemSize = pItem->GetSizeF();
3439 itemSize.width = __pProviderAdaptor->GetListWidth();
3441 pItem->SetItemChanged(true);
3442 pItem->SetSize(itemSize);
3444 if ((firstLoadedItemPos.itemIndex == lastLoadedItemPos.itemIndex) && (firstLoadedItemPos.groupIndex == lastLoadedItemPos.groupIndex))
3448 } while (GetNextItemPosition(firstLoadedItemPos, firstLoadedItemPos));
3452 _TableViewPresenter::OpenContextItem(int groupIndex, int itemIndex)
3454 SysTryReturn(NID_UI_CTRL, groupIndex >= 0 && groupIndex < GetGroupCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid group index.");
3456 TableViewItemTag itemTag = {groupIndex, itemIndex};
3457 _TableViewItem* pItem = FindItem(itemTag);
3459 SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Item was not loaded.");
3460 SysTryReturn(NID_UI_CTRL, pItem->GetContextItem() != null, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] ContextItem is not set to the item.");
3461 SysTryReturn(NID_UI_CTRL,__sweptItemTag.groupIndex != groupIndex || __sweptItemTag.itemIndex != itemIndex, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] ContextItem already opened.");
3465 __sweptItemTag.groupIndex = groupIndex;
3466 __sweptItemTag.itemIndex = itemIndex;
3467 __sweptItemPosition = pItem->GetPositionF();
3469 pItem->AdjustContextItemBounds();
3470 __sweepOccured = true;
3472 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
3474 if (pVisualElement != null)
3476 float itemWidth = __pTableView->GetBoundsF().width;
3477 float sweepMargin = 0.0f;
3478 GET_SHAPE_CONFIG(TABLEVIEW::CONTEXTITEM_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, sweepMargin);
3480 String animationName(L"SWEEP_ITEM_ANIMATION");
3481 float startValue = __sweptItemPosition.x;
3482 float endValue = itemWidth - sweepMargin;
3484 pVisualElement->SetImplicitAnimationEnabled(false);
3486 VisualElementValueAnimation* pAnimation = __pTableView->GetVisualElementValueAnimation(animationName);
3487 pAnimation->SetStartValue(Variant(startValue));
3488 pAnimation->SetEndValue(Variant(endValue));
3489 pAnimation->SetDuration(SWEEP_ITEM_ANIMATION_DURATION);
3490 pVisualElement->AddAnimation(animationName, *pAnimation);
3497 _TableViewPresenter::CloseContextItem(int groupIndex, int itemIndex)
3499 SysTryReturn(NID_UI_CTRL, groupIndex >= 0 && groupIndex < GetGroupCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid group index.");
3501 TableViewItemTag itemTag = {groupIndex, itemIndex};
3502 _TableViewItem* pItem = FindItem(itemTag);
3504 SysTryReturn(NID_UI_CTRL, pItem != null, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Item was not loaded.");
3505 SysTryReturn(NID_UI_CTRL, pItem->GetContextItem() != null, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] ContextItem is not set to the item.");
3506 SysTryReturn(NID_UI_CTRL, __sweptItemTag.groupIndex == groupIndex && __sweptItemTag.itemIndex == itemIndex, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] ContextItem was not opened.");
3514 _TableViewPresenter::IsContextItemOpened(int groupIndex, int itemIndex) const
3516 SysTryReturn(NID_UI_CTRL, groupIndex >= 0 && groupIndex < GetGroupCount(), false, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid group index.");
3518 if ( __sweptItemTag.groupIndex == -1 && __sweptItemTag.itemIndex == -1)
3523 if (__sweptItemTag.groupIndex == groupIndex && __sweptItemTag.itemIndex == itemIndex)
3532 _TableViewPresenter::SetSectionHeaderTextHorizontalAlignment(int sectionIndex, HorizontalAlignment alignment)
3534 SysTryReturn(NID_UI_CTRL, __pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
3535 SysTryReturn(NID_UI_CTRL, HasSectionHeader(sectionIndex), E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Header is not set to the section.");
3536 SysTryReturn(NID_UI_CTRL, sectionIndex >= 0 && sectionIndex < GetGroupCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid section index.");
3538 _TableViewSectionStringAlignment newAlignment;
3540 __sectionAlignmentList.GetAt(sectionIndex, newAlignment);
3541 newAlignment.headerHorizontalAlignment = alignment;
3542 __sectionAlignmentList.SetAt(newAlignment, sectionIndex);
3544 TableViewItemTag itemTag = {sectionIndex, -1};
3545 _TableViewItem* pItem = FindItem(itemTag);
3549 pItem->SetSectionHeaderFooterAlignment(alignment);
3556 _TableViewPresenter::GetSectionHeaderTextHorizontalAlignment(int sectionIndex) const
3558 SysTryReturn(NID_UI_CTRL, __pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION, ALIGNMENT_LEFT, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
3559 SysTryReturn(NID_UI_CTRL, HasSectionHeader(sectionIndex), ALIGNMENT_LEFT, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Header is not set to the section.");
3560 SysTryReturn(NID_UI_CTRL, sectionIndex >= 0 && sectionIndex < GetGroupCount(), ALIGNMENT_LEFT, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid section index.");
3562 _TableViewSectionStringAlignment alignment;
3563 __sectionAlignmentList.GetAt(sectionIndex, alignment);
3565 return alignment.headerHorizontalAlignment;
3569 _TableViewPresenter::SetSectionFooterTextHorizontalAlignment(int sectionIndex, HorizontalAlignment alignment)
3571 SysTryReturn(NID_UI_CTRL, __pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION, E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
3572 SysTryReturn(NID_UI_CTRL, HasSectionFooter(sectionIndex), E_INVALID_OPERATION, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Footer is not set to the section.");
3573 SysTryReturn(NID_UI_CTRL, sectionIndex >= 0 && sectionIndex < GetGroupCount(), E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid section index.");
3575 _TableViewSectionStringAlignment newAlignment;
3577 __sectionAlignmentList.GetAt(sectionIndex, newAlignment);
3578 newAlignment.footerHorizontalAlignment= alignment;
3579 __sectionAlignmentList.SetAt(newAlignment, sectionIndex);
3581 TableViewItemTag itemTag = {sectionIndex, GetItemCountAt(sectionIndex) - 1};
3582 _TableViewItem* pItem = FindItem(itemTag);
3586 pItem->SetSectionHeaderFooterAlignment(alignment);
3593 _TableViewPresenter::GetSectionFooterTextHorizontalAlignment(int sectionIndex) const
3595 SysTryReturn(NID_UI_CTRL, __pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION, ALIGNMENT_RIGHT, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The style of TableView is TABLE_VIEW_STYLE_SECTION");
3596 SysTryReturn(NID_UI_CTRL, HasSectionFooter(sectionIndex), ALIGNMENT_RIGHT, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Footer is not set to the section.");
3597 SysTryReturn(NID_UI_CTRL, sectionIndex >= 0 && sectionIndex < GetGroupCount(), ALIGNMENT_RIGHT, E_OUT_OF_RANGE, "[E_INVALID_ARG] Invalid section index.");
3599 _TableViewSectionStringAlignment alignment;
3600 __sectionAlignmentList.GetAt(sectionIndex, alignment);
3602 return alignment.footerHorizontalAlignment;
3606 _TableViewPresenter::IsValidDrawnItem(int groupIndex, int itemIndex)
3608 TableViewItemTag currentItemTag = {groupIndex, itemIndex};
3609 TableViewItemTag itemTag = {-1, -1};
3611 if (GetNextItemPosition(currentItemTag, itemTag))
3613 if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex))
3619 if (GetPreviousItemPosition(currentItemTag, itemTag))
3621 if (__pListModel->IsLoadedItem(itemTag.groupIndex, itemTag.itemIndex))
3631 _TableViewPresenter::StopAllItemAnimation(void)
3633 TableViewItemTag currentItemTag = {-1, -1};
3634 TableViewItemTag lastItemTag = {-1, -1};
3636 __pListModel->GetFirstLoadedItemIndex(currentItemTag.groupIndex, currentItemTag.itemIndex);
3637 __pListModel->GetLastLoadedItemIndex(lastItemTag.groupIndex, lastItemTag.itemIndex);
3641 _TableViewItem *pItem = FindItem(currentItemTag);
3644 pItem->StopAllAnimation();
3647 if (currentItemTag.groupIndex == lastItemTag.groupIndex && currentItemTag.itemIndex == lastItemTag.itemIndex)
3652 }while (GetNextItemPosition(currentItemTag, currentItemTag));
3656 _TableViewPresenter::GetTableViewItemPosition(_TableViewItem& item, TableViewItemTag& itemTag)
3658 TableViewItemTag lastLoadedItemPos = {-1, -1};
3659 TableViewItemTag firstLoadedItemPos = {-1, -1};
3660 __pListModel->GetLastLoadedItemIndex(lastLoadedItemPos.groupIndex, lastLoadedItemPos.itemIndex);
3661 __pListModel->GetFirstLoadedItemIndex(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex);
3663 _TableViewItem* pCurrentItem = null;
3666 pCurrentItem = static_cast<_TableViewItem*>(__pListModel->LoadItem(firstLoadedItemPos.groupIndex, firstLoadedItemPos.itemIndex));
3667 if (pCurrentItem == &item)
3669 itemTag.groupIndex = firstLoadedItemPos.groupIndex;
3670 itemTag.itemIndex = firstLoadedItemPos.itemIndex;
3674 if ((firstLoadedItemPos.itemIndex == lastLoadedItemPos.itemIndex) && (firstLoadedItemPos.groupIndex == lastLoadedItemPos.groupIndex))
3678 } while (GetNextItemPosition(firstLoadedItemPos, firstLoadedItemPos));
3684 _TableViewPresenter::GetItemHeight(TableViewItemTag itemTag) const
3686 float itemHeight = 0.0f;
3688 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SECTION && itemTag.itemIndex != -1)
3690 if (HasSectionFooter(itemTag.groupIndex))
3692 if (itemTag.itemIndex == GetItemCountAt(itemTag.groupIndex) - 1)
3694 GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight);
3700 if (__pProviderAdaptor == null)
3706 for (int i = 0; i < itemTag.groupIndex; i++)
3708 int itemCount = GetItemCountAt(i);
3710 startIndex = startIndex + itemCount + 1;
3713 itemTag.itemIndex++;
3714 itemTag.itemIndex = startIndex + itemTag.itemIndex;
3716 __itemHeightList.GetAt(itemTag.itemIndex, itemHeight);
3722 _TableViewPresenter::SetItemHeight(TableViewItemTag itemTag, float height)
3726 for (int i = 0; i < itemTag.groupIndex; i++)
3728 int itemCount = GetItemCountAt(i);
3730 startIndex = startIndex + itemCount + 1;
3733 itemTag.itemIndex++;
3734 itemTag.itemIndex = startIndex + itemTag.itemIndex;
3736 float oldHeight = 0.0f;
3737 __itemHeightList.GetAt(itemTag.itemIndex, oldHeight);
3738 __itemHeightList.SetAt(height, itemTag.itemIndex);
3745 _TableViewPresenter::SetReorderMode(bool enabled)
3749 __reorderInfo.itemIndex = -1;
3750 __reorderInfo.groupIndex = -1;
3752 _TableViewItem* pItem = null;
3753 TableViewItemTag itemPos = {-1, -1};
3754 TableViewItemTag lastItemPos = {-1, -1};
3756 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
3757 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
3761 pItem = FindItem(itemPos);
3765 pItem->SetReorderMode(enabled);
3767 if (enabled && itemPos.itemIndex != -1)
3769 if (pItem->GetDrawingStatus() == TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED)
3771 if (SelectReorderItem(itemPos.groupIndex, itemPos.itemIndex))
3773 FloatPoint itemPosition = pItem->GetPositionF();
3774 // +++ check floating
3775 //FloatPoint touchPosition = pItem->GetLastTouchPressedPosition();
3776 FloatPoint touchPosition = _CoordinateSystemUtils::ConvertToFloat(pItem->GetLastTouchPressedPosition());
3778 __reorderInfo.touchPressedPositionY = itemPosition.y + touchPosition.y - GetScrollPosition();
3779 __reorderInfo.blockedTouchReleaseState = true;
3785 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
3790 } while (GetNextItemPosition(itemPos, itemPos) == true);
3796 _TableViewPresenter::SelectReorderItem(int groupIndex, int itemIndex)
3798 if (itemIndex == -1 || GetPressedItemCount() > 0)
3803 TableViewItemTag itemPos = {groupIndex, itemIndex};
3804 _TableViewItem* pItem = FindItem(itemPos);
3811 pItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
3812 pItem->SetItemChanged(true);
3813 pItem->Invalidate();
3815 __reorderInfo.blockedScroll = false;
3816 __reorderInfo.itemBounds = pItem->GetBoundsF();
3817 __reorderInfo.itemIndex = itemIndex;
3818 __reorderInfo.groupIndex = groupIndex;
3819 __reorderInfo.originGroupIndex = groupIndex;
3820 __reorderInfo.originItemIndex = itemIndex;
3821 __reorderInfo.itemBasisPositionY = __reorderInfo.itemBounds.y;
3823 Tizen::System::SystemTime::GetTicks(__reorderInfo.touchPressedTick);
3825 pItem->GetVisualElement()->SetZOrder(null, true);
3827 if (GetScrollAreaBounds().height < __pTableView->GetBoundsF().height)
3829 float itemHeight = pItem->GetBoundsF().height;
3831 __pListModel->GetLastLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
3833 pItem = FindItem(itemPos);
3837 FloatRectangle itemBounds = pItem->GetBoundsF();
3838 __reorderInfo.nonScrollableLimitArea = itemBounds.y + itemBounds.height - itemHeight;
3843 __reorderInfo.nonScrollableLimitArea = 0;
3850 _TableViewPresenter::ResetReorderItem(int groupIndex, int itemIndex)
3852 TableViewItemTag itemPos = {groupIndex, itemIndex};
3853 _TableViewItem* pItem = FindItem(itemPos);
3860 pItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
3861 pItem->SetItemChanged(true);
3862 pItem->Invalidate();
3864 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_LIST_REORDER);
3866 FloatPoint position = FloatPoint(__reorderInfo.itemBounds.x, __reorderInfo.itemBounds.y);
3867 pItem->SetPosition(position);
3869 if (__reorderInfo.originGroupIndex != __reorderInfo.groupIndex || __reorderInfo.originItemIndex != __reorderInfo.itemIndex)
3871 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
3873 __pTableView->FireTableViewItemReorderEvent(__reorderInfo.originItemIndex, __reorderInfo.itemIndex);
3875 else if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_GROUPED)
3877 __pTableView->FireTableViewItemReorderEvent(__reorderInfo.originGroupIndex, __reorderInfo.originItemIndex, __reorderInfo.groupIndex, __reorderInfo.itemIndex);
3881 __reorderInfo.groupIndex = -1;
3882 __reorderInfo.itemIndex = -1;
3883 __reorderInfo.originGroupIndex = -1;
3884 __reorderInfo.originItemIndex = -1;
3885 __reorderInfo.nonScrollableLimitArea = 0;
3887 StopReorderScrollTimer();
3893 _TableViewPresenter::CheckReorderItemScrollAnimation(_TableViewItem *pItem)
3895 float currentScrollPosition = GetScrollPosition();
3896 float limitTopPositionY = currentScrollPosition;
3897 float limitBottomPositionY = currentScrollPosition + __pTableView->GetBoundsF().height - __reorderInfo.itemBounds.height;
3899 float itemPositionY = pItem->GetPositionF().y;
3901 if (itemPositionY < limitTopPositionY)
3903 if (__pReorderScrollTimer == null)
3905 __reorderInfo.isScrollDirectionUp = true;
3910 else if (itemPositionY > limitBottomPositionY)
3912 if (__pReorderScrollTimer == null)
3914 __reorderInfo.isScrollDirectionUp = false;
3924 _TableViewPresenter::DragSelectedItem(float distance, bool relativeCoordinate)
3926 TableViewItemTag itemPos = {__reorderInfo.groupIndex, __reorderInfo.itemIndex};
3927 _TableViewItem* pItem = FindItem(itemPos);
3934 if (__firstTouchMoved)
3936 long long currentTick = 0;
3937 Tizen::System::SystemTime::GetTicks(currentTick);
3939 if (currentTick - __reorderInfo.touchPressedTick < REORDER_TOUCH_UIACTIVATE_DURATION)
3944 __firstTouchMoved = false;
3947 FloatPoint itemPosition = pItem->GetPositionF();
3949 if (relativeCoordinate)
3951 itemPosition.y = __reorderInfo.itemBasisPositionY + distance;
3955 itemPosition.y += distance;
3957 __reorderInfo.itemBasisPositionY += distance;
3960 if (itemPosition.y < 0)
3965 float scrollAreaHeight = GetScrollAreaBounds().height;
3966 float screenHeight = __pTableView->GetBoundsF().height;
3967 float limitBottomPositionY = 0.0f;
3969 if (scrollAreaHeight < screenHeight)
3971 limitBottomPositionY = __reorderInfo.nonScrollableLimitArea;
3975 limitBottomPositionY = scrollAreaHeight - __reorderInfo.itemBounds.height;
3978 if (itemPosition.y > limitBottomPositionY)
3980 itemPosition.y = limitBottomPositionY;
3983 pItem->SetPosition(itemPosition);
3986 if (CheckReorderItemScrollAnimation(pItem))
3988 if (__pReorderScrollTimer == null)
3990 StartReorderScrollTimer();
3995 if (__pReorderScrollTimer != null)
3997 StopReorderScrollTimer();
4002 TableViewItemTag moveItemTag = {-1, -1};
4004 if (CheckReorderItemPosition(pItem, moveItemTag))
4006 if (moveItemTag.itemIndex == -1)
4008 int destGroupIndex = moveItemTag.groupIndex;
4010 if (destGroupIndex != 0 && destGroupIndex == __reorderInfo.groupIndex)
4015 if (moveItemTag.groupIndex == 0 || !__pProviderAdaptor->IsReorderable(__reorderInfo.groupIndex, destGroupIndex))
4017 __reorderInfo.blockedScroll = true;
4023 ReorderItem(moveItemTag.groupIndex, moveItemTag.itemIndex);
4030 _TableViewPresenter::CheckReorderItemPosition(_TableViewItem* pItem, TableViewItemTag& reorderItemTag)
4032 TableViewItemTag currentItemTag = {__reorderInfo.groupIndex, __reorderInfo.itemIndex};
4033 TableViewItemTag previousItemTag = {-1, -1};
4034 TableViewItemTag nextItemTag = {-1, -1};
4036 FloatRectangle itemBounds = pItem->GetBoundsF();
4038 if (GetPreviousItemPosition(currentItemTag, previousItemTag))
4040 _TableViewItem* pPreviousItem = LoadItem(previousItemTag.groupIndex, previousItemTag.itemIndex);
4042 if (pPreviousItem != null)
4044 FloatRectangle previousItemBounds = pPreviousItem->GetBoundsF();
4046 if (itemBounds.y < previousItemBounds.y + (previousItemBounds.height / 2))
4048 //return previousItemIndex;
4049 reorderItemTag.groupIndex = previousItemTag.groupIndex;
4050 reorderItemTag.itemIndex = previousItemTag.itemIndex;
4057 if (GetNextItemPosition(currentItemTag, nextItemTag))
4059 _TableViewItem* pNextItem = LoadItem(nextItemTag.groupIndex, nextItemTag.itemIndex);
4061 if (pNextItem != null)
4063 FloatRectangle nextItemBounds = pNextItem->GetBoundsF();
4065 if (itemBounds.y + itemBounds.height > nextItemBounds.y + (nextItemBounds.height / 2))
4067 //return nextItemIndex;
4068 reorderItemTag.groupIndex = nextItemTag.groupIndex;
4069 reorderItemTag.itemIndex = nextItemTag.itemIndex;
4076 reorderItemTag.groupIndex = -1;
4077 reorderItemTag.itemIndex = -1;
4083 _TableViewPresenter::ReorderItem(int destinationGroupIndex, int destinationItemIndex)
4085 TableViewItemTag itemPos = {destinationGroupIndex, destinationItemIndex};
4087 _TableViewItem* pItem = FindItem(itemPos);
4094 if (pItem->IsAnimationPlaying())
4099 FloatRectangle destinationItemBounds = pItem->GetBoundsF();
4101 FloatPoint destinationItemPosition = FloatPoint(destinationItemBounds.x, 0.0f);
4103 if ( __reorderInfo.itemIndex > destinationItemIndex && __reorderInfo.groupIndex == destinationGroupIndex)
4105 destinationItemPosition.y = __reorderInfo.itemBounds.y + __reorderInfo.itemBounds.height - destinationItemBounds.height;
4106 __reorderInfo.itemBounds.y = destinationItemBounds.y;
4108 if (destinationItemIndex == -1)
4110 destinationGroupIndex--;
4111 int itemCount = GetItemCountAt(destinationGroupIndex);
4112 destinationItemIndex = itemCount;
4117 destinationItemPosition.y = __reorderInfo.itemBounds.y;
4118 __reorderInfo.itemBounds.y = destinationItemBounds.y + destinationItemBounds.height - __reorderInfo.itemBounds.height;
4120 if (destinationItemIndex == -1)
4122 destinationItemIndex = 0;
4126 _ListItemPos originPosition = {__reorderInfo.groupIndex, __reorderInfo.itemIndex};
4127 _ListItemPos destinationPosition = {destinationGroupIndex, destinationItemIndex};
4129 __pListModel->MoveItem(originPosition, destinationPosition);
4131 if (!pItem->MoveItem(destinationItemPosition, REORDER_ITEM_MOVE_ANIMATION_DURATION, 0))
4133 pItem->SetPosition(destinationItemPosition);
4136 __reorderInfo.itemIndex = destinationItemIndex;
4137 __reorderInfo.groupIndex = destinationGroupIndex;
4143 _TableViewPresenter::StartReorderScrollTimer(void)
4145 StopReorderScrollTimer();
4147 __pReorderScrollTimer = new (std::nothrow) Tizen::Base::Runtime::Timer;
4148 SysTryReturnVoidResult(NID_UI_CTRL, __pReorderScrollTimer != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
4150 result r = __pReorderScrollTimer->Construct(*this);
4151 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4153 r = __pReorderScrollTimer->Start(REORDER_SCROLL_ANIMATION_TIMER_DURATION);
4154 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4159 StopReorderScrollTimer();
4163 _TableViewPresenter::StopReorderScrollTimer(void)
4165 delete __pReorderScrollTimer;
4166 __pReorderScrollTimer = null;
4171 _TableViewPresenter::UpdateLayout(void)
4177 _TableViewPresenter::CheckItemHeightAndRefreshLayout(TableViewItemTag itemTag, bool downScroll)
4179 _TableViewItem* pItem = FindItem(itemTag);
4186 if (pItem->IsAnimationPlaying())
4191 FloatRectangle itemBounds = pItem->GetBoundsF();
4193 if (_FloatCompare(GetItemHeight(itemTag), itemBounds.height))
4198 float newHeight = itemBounds.height;
4199 float originHeight = SetItemHeight(itemTag, newHeight);
4200 float dist = newHeight - originHeight;
4202 AdjustClientAreaBounds(false, dist);
4206 itemBounds.y += dist;
4207 pItem->SetBounds(itemBounds);
4210 AttachNextItemsToBottom(itemTag);
4216 _TableViewPresenter::CreateItemHeightList(void)
4218 int groupCount = GetGroupCount();
4220 result r = __itemHeightList.SetCapacity(GetItemCount());
4221 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4223 for (int i = 0; i < groupCount; i++)
4225 int itemCount = GetItemCountAt(i);
4227 if (__pTableView->GetTableViewStyle() == TABLE_VIEW_STYLE_SIMPLE)
4229 __itemHeightList.Add(0);
4233 __itemHeightList.Add(-1);
4236 for (int j = 1; j <= itemCount; j++)
4238 __itemHeightList.Add(-1);
4245 DeleteItemHeightList();
4251 _TableViewPresenter::DeleteItemHeightList(void)
4253 __itemHeightList.RemoveAll();
4257 _TableViewPresenter::RefreshItemHeightList(int groupIndex, int itemIndex, TableViewRefreshType refreshType)
4259 float defaultItemHeight = __pProviderAdaptor->GetDefaultItemHeight();
4260 float defaultGroupItemHeight = __pProviderAdaptor->GetDefaultGroupItemHeight();
4263 for (int i = 0; i < groupIndex; i++)
4265 int itemCount = GetItemCountAt(i);
4266 startIndex = startIndex + itemCount + 1;
4269 int targetIndex = startIndex + itemIndex + 1;
4271 if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD)
4273 if (itemIndex == -1)
4275 result r = __itemHeightList.SetCapacity(GetItemCount());
4276 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
4278 int itemCount = GetItemCountAt(groupIndex);
4279 for (int i = 0; i < itemCount; i++)
4281 __itemHeightList.InsertAt(defaultItemHeight, targetIndex);
4284 __itemHeightList.InsertAt(defaultGroupItemHeight, targetIndex);
4289 __itemHeightList.InsertAt(defaultItemHeight, targetIndex);
4292 else if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE)
4294 if (itemIndex == -1)
4296 int itemCount = GetItemCountAt(groupIndex) + 1;
4298 for (int i = 0; i < itemCount; i++)
4300 __itemHeightList.RemoveAt(targetIndex);
4305 __itemHeightList.RemoveAt(targetIndex);
4313 _TableViewPresenter::CreateSectionAlignmentList(void)
4315 if (__pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
4320 int groupCount = GetGroupCount();
4322 result r = __sectionAlignmentList.SetCapacity(GetGroupCount());
4323 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
4325 _TableViewSectionStringAlignment alignment;
4326 alignment.headerHorizontalAlignment = ALIGNMENT_LEFT;
4327 alignment.footerHorizontalAlignment = ALIGNMENT_RIGHT;
4329 for (int i = 0; i < groupCount; i++)
4332 __sectionAlignmentList.Add(alignment);
4339 _TableViewPresenter::DeleteSectionAlignmentList(void)
4341 __sectionAlignmentList.RemoveAll();
4345 _TableViewPresenter::RefreshSectionAlignmentList(int groupIndex, TableViewRefreshType refreshType)
4347 if (__pTableView->GetTableViewStyle() != TABLE_VIEW_STYLE_SECTION)
4352 if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_ADD)
4354 _TableViewSectionStringAlignment alignment;
4355 alignment.headerHorizontalAlignment = ALIGNMENT_LEFT;
4356 alignment.footerHorizontalAlignment = ALIGNMENT_RIGHT;
4358 __sectionAlignmentList.InsertAt(alignment, groupIndex);
4360 else if (refreshType == TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE)
4362 __sectionAlignmentList.RemoveAt(groupIndex);
4369 _TableViewPresenter::CaptureAndStartRemoveItemAnimation(int groupIndex, int itemIndex)
4371 TableViewItemTag itemTag = {groupIndex, itemIndex};
4372 _TableViewItem* pItem = FindItem(itemTag);
4379 FloatRectangle itemBounds = pItem->GetBoundsF();
4380 result r = E_SUCCESS;
4382 _VisualElement* pVisualElement = null;
4383 String animationName(L"REMOVE_ITEM_ANIMATION");
4384 Canvas* pCanvas = null;
4385 VisualElementValueAnimation* pAnimation = __pTableView->GetVisualElementValueAnimation(animationName);
4387 FloatDimension startValue(100.0f, itemBounds.height);
4388 FloatDimension endValue(0.0f, 0.0f);
4390 Tizen::Graphics::Bitmap* pBitmap = pItem->GetCapturedBitmapN(true);
4392 if (pBitmap == null)
4398 pVisualElement = new (std::nothrow) _VisualElement();
4399 SysTryCatch(NID_UI_CTRL, pVisualElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
4401 r = pVisualElement->Construct();
4402 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4404 pVisualElement->SetImplicitAnimationEnabled(false);
4405 pVisualElement->SetSurfaceOpaque(false);
4406 pVisualElement->SetBounds(FloatRectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height));
4407 pVisualElement->SetShowState(true);
4409 pCanvas = pVisualElement->GetCanvasN();
4410 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
4413 pCanvas->DrawBitmap(FloatRectangle(0, 0, itemBounds.width, itemBounds.height), *pBitmap);
4415 pAnimation->SetDelay(0);
4416 pAnimation->SetStartValue(Variant(startValue));
4417 pAnimation->SetEndValue(Variant(endValue));
4418 pAnimation->SetDuration(REMOVE_ITEM_MOVE_ANIMATION_DURATION);
4420 r = pVisualElement->AddAnimation(animationName, *pAnimation);
4421 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4432 pVisualElement->Destroy();
4436 _TableViewPresenter::PresetItemHeightList(void)
4438 int groupCount = GetGroupCount();
4439 float defaultGroupItemHeight = __pProviderAdaptor->GetDefaultGroupItemHeight();
4440 float defaultItemHeight = __pProviderAdaptor->GetDefaultItemHeight();
4442 for (int i = 0; i < groupCount; i++)
4444 TableViewItemTag itemTag = {i, -1};
4445 int itemCount = GetItemCountAt(i);
4447 if (GetItemHeight(itemTag) == -1)
4449 SetItemHeight(itemTag, defaultGroupItemHeight);
4452 for (int j = 1; j <= itemCount; j++)
4454 itemTag.itemIndex = j;
4455 if (GetItemHeight(itemTag) == -1)
4457 SetItemHeight(itemTag, defaultItemHeight);
4464 _TableViewPresenter::GetTableViewItemFromControl(const _Control& source)
4466 _Control* currentControl = const_cast<_Control*>(&source);
4467 _TableViewItem* pItem = null;
4469 while (__pTableView != currentControl)
4471 pItem = dynamic_cast<_TableViewItem*>(currentControl);
4473 if ((pItem != null) || (currentControl == null))
4478 currentControl = currentControl->GetParent();
4485 _TableViewPresenter::ShowTableViewCapturedItem(int groupIndex, int itemIndex, float height)
4487 TableViewItemTag itemTag = {groupIndex, itemIndex};
4488 _TableViewItem* pItem = FindItem(itemTag);
4490 if ((pItem == null) || _FloatCompare(height, 0.0f))
4495 result r = E_SUCCESS;
4496 Canvas* pCanvas = null;
4497 FloatRectangle itemBounds = pItem->GetBoundsF();
4499 bool visibleState = pItem->GetVisibleState();
4500 pItem->SetVisibleState(true);
4501 Bitmap* pBitmap = pItem->GetCapturedBitmapN(true);
4502 pItem->SetVisibleState(visibleState);
4504 if (pBitmap == null)
4509 if (__pCapturedItemVisualElement == null)
4511 __pCapturedItemVisualElement = new (std::nothrow) _VisualElement();
4512 SysTryCatch(NID_UI_CTRL, __pCapturedItemVisualElement != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
4514 r = __pCapturedItemVisualElement->Construct();
4515 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
4517 r = GetView()->GetVisualElement()->AttachChild(*__pCapturedItemVisualElement);
4518 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach child to the control VisualElement.", GetErrorMessage(r));
4520 __pCapturedItemVisualElement->SetSurfaceOpaque(false);
4521 __pCapturedItemVisualElement->SetImplicitAnimationEnabled(false);
4524 __pCapturedItemVisualElement->SetShowState(true);
4525 __pCapturedItemVisualElement->SetBounds(FloatRectangle(itemBounds.x, itemBounds.y, itemBounds.width, height));
4527 pCanvas = __pCapturedItemVisualElement->GetCanvasN();
4528 SysTryCatch(NID_UI_CTRL, pCanvas != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
4530 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
4532 pCanvas->DrawBitmap(FloatPoint(0.0f, 0.0f), *pBitmap);
4543 __pCapturedItemVisualElement->Destroy();
4547 _TableViewPresenter::SetLoadedItemsVisibleFromPosition(float position, bool visible)
4549 _TableViewItem* pItem;
4550 FloatRectangle itemBounds;
4551 TableViewItemTag current;
4552 current.groupIndex = __expandableItemTag.groupIndex;
4553 current.itemIndex = __expandableItemTag.itemIndex;
4555 int itemCountInGroup = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex);
4557 for (int i = 0; i < itemCountInGroup; i++)
4559 current.itemIndex = i;
4563 pItem = LoadItem(current.groupIndex, current.itemIndex);
4567 pItem = FindItem(current);
4575 itemBounds = pItem->GetBoundsF();
4579 if (_FloatCompare(position, itemBounds.y) && !_FloatCompareGE(position, itemBounds.y + itemBounds.height))
4581 ShowTableViewCapturedItem(current.groupIndex, current.itemIndex, position - itemBounds.y);
4582 pItem->SetVisibleState(false);
4585 else if(_FloatCompareGE(position, itemBounds.y) && !_FloatCompareGE(position, itemBounds.y + itemBounds.height))
4587 ShowTableViewCapturedItem(current.groupIndex, current.itemIndex, position - itemBounds.y);
4588 pItem->SetVisibleState(true);
4593 pItem->SetVisibleState(true);
4598 if (!_FloatCompareGE(position, itemBounds.y))
4600 UnloadItem(current);
4602 else if (_FloatCompareGE(position, itemBounds.y) && !_FloatCompareGE(position, itemBounds.y + itemBounds.height))
4604 pItem->SetVisibleState(false);
4605 ShowTableViewCapturedItem(current.groupIndex, current.itemIndex, position - itemBounds.y);
4609 pItem->SetVisibleState(true);
4616 _TableViewPresenter::MoveLoadedItemsFromPosition(float position)
4618 FloatRectangle itemBounds;
4619 float itemPosition = position;
4621 TableViewItemTag current;
4622 TableViewItemTag next;
4624 current.groupIndex = __expandableItemTag.groupIndex;
4625 current.itemIndex = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex) -1;
4627 float screenPosition = GetScrollPosition();
4628 FloatRectangle screenBounds = __pTableView->GetBoundsF();
4629 screenPosition += screenBounds.height;
4631 _TableViewItem* pItem = null;
4632 while (GetNextItemPosition(current, next))
4634 if (screenPosition > itemPosition)
4636 pItem = LoadItem(next.groupIndex, next.itemIndex);
4640 pItem = FindItem(next);
4648 itemBounds = pItem->GetBoundsF();
4649 itemBounds.y = itemPosition;
4650 pItem->SetBounds(itemBounds);
4651 itemPosition += itemBounds.height;
4658 _TableViewPresenter::ExpandGroupAnimationFinished(bool completedNormally)
4660 if (completedNormally == false)
4662 TableViewItemTag current;
4663 TableViewItemTag next;
4665 current.groupIndex = __expandableItemTag.groupIndex;
4666 current.itemIndex = -1;
4668 _TableViewItem* pNextItem = null;
4669 _TableViewItem* pCurrentItem = null;
4670 pCurrentItem = LoadItem(current.groupIndex, current.itemIndex);
4672 if (pCurrentItem == null)
4677 FloatRectangle itemBounds;
4678 FloatRectangle screenBounds = __pTableView->GetBoundsF();
4679 float screenPosition = GetScrollPosition() + screenBounds.height;
4680 float nextItemPositionY = pCurrentItem->GetBoundsF().y + pCurrentItem->GetBoundsF().height;
4682 while (GetNextItemPosition(current, next))
4684 if (_FloatCompareGE(screenPosition, nextItemPositionY))
4686 pCurrentItem = LoadItem(current.groupIndex, current.itemIndex);
4687 if (pCurrentItem == null)
4691 pNextItem = LoadItem(next.groupIndex, next.itemIndex);
4692 if (pNextItem == null)
4696 pNextItem->SetVisibleState(true);
4697 itemBounds = pNextItem->GetBoundsF();
4698 itemBounds.y = pCurrentItem->GetBoundsF().y + pCurrentItem->GetBoundsF().height;
4699 pNextItem->SetBounds(itemBounds);
4700 nextItemPositionY = itemBounds.y + itemBounds.height;
4704 UnloadItem(next.groupIndex, next.itemIndex);
4712 int currentGroupIndex = -1;
4713 int currentItemIndex = -1;
4714 GetBottomDrawnItemIndex(currentGroupIndex, currentItemIndex);
4716 int lastLoadedGroupIndex = -1;
4717 int lastLoadedItemIndex = -1;
4718 __pListModel->GetLastLoadedItemIndex(lastLoadedGroupIndex, lastLoadedItemIndex);
4720 for (int j = currentGroupIndex; j <= lastLoadedGroupIndex; j++)
4722 int itemCount = GetItemCountAt(j);
4724 for (int i = -1; i < itemCount; i++)
4726 if (i <= currentItemIndex && j == currentGroupIndex)
4738 _TableViewPresenter::CollapseGroupAnimationFinished(bool completedNormally)
4740 if (completedNormally == false)
4742 TableViewItemTag current;
4743 TableViewItemTag next;
4745 current.groupIndex = __expandableItemTag.groupIndex;
4746 current.itemIndex = -1;
4748 _TableViewItem* pCurrentItem = null;
4749 int itemCountInGroup = __pListModel->GetItemCountInGroup(__expandableItemTag.groupIndex);
4751 for (int i = 0; i < itemCountInGroup; i++)
4753 UnloadItem(__expandableItemTag.groupIndex, i);
4756 pCurrentItem = FindItem(current);
4757 if (pCurrentItem == null)
4759 SysTryReturnVoidResult(NID_UI_CTRL, pCurrentItem != null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred.")
4762 FloatRectangle itemBounds;
4763 float nextItemPositionY = pCurrentItem->GetBoundsF().y + pCurrentItem->GetBoundsF().height;
4765 FloatRectangle screenBounds = __pTableView->GetBoundsF();
4766 float screenPosition = GetScrollPosition() + screenBounds.height;
4768 while (GetNextItemPosition(current, next))
4771 if (_FloatCompareGE(screenPosition, nextItemPositionY))
4773 pCurrentItem = LoadItem(current.groupIndex, current.itemIndex);
4774 if (pCurrentItem == null)
4779 pCurrentItem->SetVisibleState(true);
4780 itemBounds = pCurrentItem->GetBoundsF();
4781 itemBounds.y = nextItemPositionY;
4782 pCurrentItem->SetBounds(itemBounds);
4784 nextItemPositionY = pCurrentItem->GetBoundsF().y + pCurrentItem->GetBoundsF().height;
4788 UnloadItem(current.groupIndex, current.itemIndex);
4794 float scrollPosition = GetScrollPosition();
4796 int groupItemsHeight = 0;
4797 _TableViewItem* pItem = null;
4798 for (int i = 0; i < __expandableItemTag.itemIndex; i++)
4800 pItem = static_cast<_TableViewItem*>(__pListModel->GetItemFromTemporaryBuffer(__expandableItemTag.groupIndex, i));
4801 groupItemsHeight += pItem->GetItemHeight();
4804 _TableViewItem* pTableViewItem = static_cast<_TableViewItem*>(__pListModel->GetItemFromTemporaryBuffer(__expandableItemTag.groupIndex, __expandableItemTag.itemIndex));
4805 FloatRectangle itemBounds = pTableViewItem->GetBoundsF();
4806 groupItemsHeight += (scrollPosition - itemBounds.y);
4808 int currentGroupIndex = -1;
4809 int currentItemIndex = -1;
4810 GetTopDrawnItemIndex(currentGroupIndex, currentItemIndex);
4812 int firstLoadedGroupIndex = -1;
4813 int firstLoadedItemIndex = -1;
4814 __pListModel->GetFirstLoadedItemIndex(firstLoadedGroupIndex, firstLoadedItemIndex);
4816 for (int j = firstLoadedGroupIndex; j <= currentGroupIndex; j++)
4818 int itemCount = GetItemCountAt(j);
4820 for (int i = -1; i < itemCount; i++)
4822 if (i >= currentItemIndex && j == currentGroupIndex)
4831 int itemCount = GetItemCountAt(__expandableItemTag.groupIndex);
4832 for (int i = 0; i < itemCount; i++)
4834 UnloadItem(__expandableItemTag.groupIndex, i);
4840 _TableViewPresenter::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
4842 if (keyName == L"REMOVE_ITEM_ANIMATION")
4847 if (keyName == L"SCROLL_PANEL_SCROLLING_ANIMATION")
4849 __scrollHeightOnFlickStarted = GetScrollAreaBounds().height;
4850 __scrollPositionOnFlickStarted = GetScrollPosition();
4853 _ScrollPanelPresenter::OnVisualElementAnimationStarted(animation, keyName, target);
4857 _TableViewPresenter::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
4859 if (keyName == L"REMOVE_ITEM_ANIMATION")
4863 _ScrollPanelPresenter::OnVisualElementAnimationRepeated(animation, keyName, target, currentRepeatCount);
4867 _TableViewPresenter::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
4869 if (__isAnimationCallbackBlocked)
4874 if (keyName == L"REMOVE_ITEM_ANIMATION")
4876 _VisualElement* pVisualElement = GetView()->GetVisualElement();
4878 pVisualElement->DetachChild(target);
4883 else if (keyName == L"EXPAND_GROUP_ANIMATION")
4885 if (__pCapturedItemVisualElement)
4887 __pCapturedItemVisualElement->SetShowState(false);
4890 ExpandGroupAnimationFinished(completedNormally);
4893 else if (keyName == L"COLLAPSE_GROUP_ANIMATION")
4895 if (__pCapturedItemVisualElement)
4897 __pCapturedItemVisualElement->SetShowState(false);
4900 CollapseGroupAnimationFinished(completedNormally);
4904 _ScrollPanelPresenter::OnVisualElementAnimationFinished(animation, keyName, target, completedNormally);
4908 _TableViewPresenter::OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue)
4910 _VisualElement* pVisualElement = __pTableView->GetVisualElement();
4912 if (&target != pVisualElement)
4917 if (keyName == L"REMOVE_ITEM_ANIMATION")
4919 Dimension value = currentValue.ToDimension();
4920 target.SetOpacity(value.width);
4922 FloatRectangle bounds = target.GetBounds();
4923 bounds.height = value.height;
4924 target.SetBounds(bounds);
4926 target.SetFlushNeeded();
4930 else if (keyName == L"EXPAND_GROUP_ANIMATION")
4932 float currentPosition = currentValue.ToFloat();
4933 SetLoadedItemsVisibleFromPosition(currentPosition, true);
4934 MoveLoadedItemsFromPosition(currentPosition);
4938 else if (keyName == L"COLLAPSE_GROUP_ANIMATION")
4940 float currentPosition = currentValue.ToFloat();
4941 SetLoadedItemsVisibleFromPosition(currentPosition, false);
4942 MoveLoadedItemsFromPosition(currentPosition);
4946 else if (keyName == L"SWEEP_ITEM_ANIMATION")
4948 float currentPosition = currentValue.ToFloat();
4949 float moveDestance = currentPosition - __sweptItemPosition.x;
4950 SweepItem(moveDestance);
4955 _ScrollPanelPresenter::OnTickOccurred(animation, keyName, target, currentValue);
4959 _TableViewPresenter::OnAccessibilityItemRefreshed(const _AccessibilityContainer& control, const _AccessibilityElement& element, _AccessibilityFocusDirection direction)
4961 TableViewItemTag itemPos = {-1, -1};
4963 if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_NEXT)
4965 GetFirstItem(itemPos);
4966 if (GetAccessibilityElementFocusedState() == false && FindItem(itemPos) == null)
4968 ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_TOP);
4973 else if (direction == _ACCESSIBILITY_FOCUS_DIRECTION_PREVIOUS)
4975 GetLastItem(itemPos);
4976 if (GetAccessibilityElementFocusedState() == false && FindItem(itemPos) == null)
4978 ScrollToItem(itemPos.groupIndex, itemPos.itemIndex, TABLE_VIEW_SCROLL_ITEM_ALIGNMENT_BOTTOM);
4988 _TableViewPresenter::GetAccessibilityElementFocusedState(void)
4990 _TableViewItem* pItem = null;
4991 TableViewItemTag itemPos = {-1, -1};
4992 TableViewItemTag lastItemPos = {-1, -1};
4994 __pListModel->GetFirstLoadedItemIndex(itemPos.groupIndex, itemPos.itemIndex);
4995 __pListModel->GetLastLoadedItemIndex(lastItemPos.groupIndex, lastItemPos.itemIndex);
4999 pItem = static_cast <_TableViewItem*>(__pListModel->LoadItem(itemPos.groupIndex, itemPos.itemIndex));
5000 SysTryReturn(NID_UI_CTRL, pItem != null, false, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index is out of range.");
5002 _AccessibilityContainer* pContainer = pItem->GetAccessibilityContainer();
5003 _AccessibilityElement* pElement = null;
5005 if (pContainer != null)
5007 pElement = pContainer->GetCurrentFocusedElement();
5008 if (pElement != null)
5014 if ((itemPos.itemIndex == lastItemPos.itemIndex) && (itemPos.groupIndex == lastItemPos.groupIndex))
5019 } while (GetNextItemPosition(itemPos, itemPos) == true);
5025 _TableViewSectionStringAlignment::operator== (const _TableViewSectionStringAlignment& rhs) const
5027 if (headerHorizontalAlignment == rhs.headerHorizontalAlignment && footerHorizontalAlignment == rhs.footerHorizontalAlignment)
5035 _TableViewSectionStringAlignment::operator!= (const _TableViewSectionStringAlignment& rhs) const
5037 if (headerHorizontalAlignment == rhs.headerHorizontalAlignment && footerHorizontalAlignment == rhs.footerHorizontalAlignment)
5045 }}} // Tizen::Ui::Controls