2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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_TabPresenter.cpp
20 * @brief This is the implementation file for the _TabPresenter class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseRtITimerEventListener.h>
25 #include <FBaseRtTimer.h>
28 #include <FBaseSysLog.h>
29 #include <FUiAnimVisualElementPropertyAnimation.h>
30 #include <FGrp_FontImpl.h>
31 #include <FGrp_TextTextObject.h>
32 #include <FGrp_BitmapImpl.h>
33 #include <FGrp_TextTextSimple.h>
34 #include "FUi_AccessibilityElement.h"
35 #include "FUi_IAccessibilityListener.h"
36 #include "FUi_AccessibilityContainer.h"
37 #include "FUiAnim_VisualElement.h"
38 #include "FUi_UiTouchEvent.h"
39 #include "FUi_ResourceManager.h"
40 #include "FUiCtrl_TabPresenter.h"
41 #include "FUi_CoordinateSystemUtils.h"
43 using namespace Tizen::Base;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Graphics::_Text;
46 using namespace Tizen::Base::Runtime;
47 using namespace Tizen::Ui::Animations;
49 namespace Tizen { namespace Ui { namespace Controls {
51 struct ReorderAnimationInfo{
66 _TabPresenter::_TabPresenter(void)
71 , __isRecalculateNeeded(false)
74 //, __pVerticalLineBitmap(null)
75 , __pHorizontalLineBitmap(null)
76 // , __pFrontScrollingEffectBitmap(null)
77 // , __pRearScrollingEffectBitmap(null)
78 // , __pScrollingEffectBitmap(null)
79 , __pFocusBitmap(null)
80 // , __pScrollingEffectVe(null)
81 , __pFlickAnimationTimer(null)
82 , __pScrollAnimationTimer(null)
87 , __moveDistance(0.0f)
88 , __isFlickEnabled(false)
93 , __isRightScrollable(false)
94 , __isLeftScrollable(false)
95 , __isDirectionRight(true)
96 , __isTimerCanceled(false)
98 , __flickDistance(0.0f)
100 , __reorderDist(0.0f)
101 , __firstItemIndex(0)
103 // , __isScrollEffectEnded(false)
104 // , __isScrollEffectStarted(false)
106 , __isTouchMove(false)
108 , __tabMinimumSize(0.0f)
109 , __fontChangeItemCount(0)
112 __currentTouchPosition = FloatPoint(0.0f, 0.0f);
113 __dividerLine = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
114 __selectedLine = FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
116 for (int i = 0; i < (_TIMER_COUNT); i++)
118 __pTimerInfo[i] = null;
121 for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++)
123 __pAnimInfo[i] = null;
128 _TabPresenter::~_TabPresenter(void)
138 delete __pTextObject;
139 __pTextObject = null;
142 //if (__pVerticalLineBitmap)
144 // delete __pVerticalLineBitmap;
145 // __pVerticalLineBitmap = null;
148 if (__pHorizontalLineBitmap)
150 delete __pHorizontalLineBitmap;
151 __pHorizontalLineBitmap = null;
154 if (__pFlickAnimationTimer)
156 delete __pFlickAnimationTimer;
157 __pFlickAnimationTimer = null;
160 for (int i = 0; i < (_TIMER_COUNT); i++)
164 if (__pTimerInfo[i]->pReorderTimer)
166 delete __pTimerInfo[i]->pReorderTimer;
167 __pTimerInfo[i]->pReorderTimer = null;
169 delete __pTimerInfo[i];
170 __pTimerInfo[i] = null;
174 for (int i = 0; i < _TAB_ITEM_MAXCOUNT; i++)
178 delete __pAnimInfo[i];
179 __pAnimInfo[i] = null;
183 if (__pScrollAnimationTimer)
185 delete __pScrollAnimationTimer;
186 __pScrollAnimationTimer = null;
189 // if (__pFrontScrollingEffectBitmap)
191 // delete __pFrontScrollingEffectBitmap;
192 // __pFrontScrollingEffectBitmap = null;
195 // if (__pRearScrollingEffectBitmap)
197 // delete __pRearScrollingEffectBitmap;
198 // __pRearScrollingEffectBitmap = null;
201 // if (__pScrollingEffectBitmap)
203 // __pScrollingEffectBitmap = null;
208 delete __pFocusBitmap;
209 __pFocusBitmap = null;
212 // if (__pScrollingEffectVe)
214 // __pScrollingEffectVe->RemoveAllAnimations();
215 // __pScrollingEffectVe->Destroy();
216 // __pScrollingEffectVe = null;
221 _TabPresenter::Construct(const _Tab& tab)
223 result r = E_SUCCESS;
225 __pTab = const_cast<_Tab*>(&tab);
227 __pFont = __pTab->GetFallbackFont();
228 SysTryReturn(NID_UI_CTRL, __pFont, E_SYSTEM , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to retrive Font.");
230 _TabModel* pModel = new (std::nothrow) _TabModel;
231 SysTryReturn(NID_UI_CTRL, pModel, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
233 r = SetModel(*pModel);
234 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to set _TabModel instance.");
236 r = pModel->Construct();
237 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to construct _TabModel instance.");
239 __pTextObject = new (std::nothrow) TextObject;
240 SysTryCatch(NID_UI_CTRL, __pTextObject, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
242 __pTextObject->Construct();
243 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
244 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
247 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate bitmap.");
249 GET_FIXED_VALUE_CONFIG(TAB::ITEM_MAX_COUNT, __pTab->GetOrientation(), __itemMaxCount);
250 GET_SHAPE_CONFIG(TAB::SCREEN_WIDTH, __pTab->GetOrientation(), __width);
251 GET_SHAPE_CONFIG(TAB::SCREEN_HEIGHT, __pTab->GetOrientation(), __height);
253 GET_FIXED_VALUE_CONFIG(TAB::DIVIDER_WIDTH, __pTab->GetOrientation(), __dividerLine.width);
254 GET_SHAPE_CONFIG(TAB::DIVIDER_HEIGHT, __pTab->GetOrientation(), __dividerLine.height);
256 GET_SHAPE_CONFIG(TAB::TAB_MINIMUM_SIZE, __pTab->GetOrientation(), __tabMinimumSize);
258 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), __selectedLine.height);
259 GET_FIXED_VALUE_CONFIG(TAB::FONT_CHANGE_ITEM_COUNT, __pTab->GetOrientation(), __fontChangeItemCount);
261 __flickAnimation.SetSizeInformation(_CoordinateSystemUtils::ConvertToInteger(__width), _CoordinateSystemUtils::ConvertToInteger(__height), DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
262 __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_TAB, FLICK_ANIMATION_SENSITIVITY_TAB);
263 __flickAnimation.SetDirection(FD_HORIZONTAL);
265 for (int i = 0; i < _TIMER_COUNT; i++)
267 __pTimerInfo[i] = new (std::nothrow) TimerInfo();
268 SysTryCatch(NID_UI_CTRL, __pTimerInfo[i], , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
270 __pTimerInfo[i]->index = -1;
271 __pTimerInfo[i]->pReorderTimer = null;
280 delete __pTextObject;
281 __pTextObject = null;
287 _TabPresenter::LoadBitmap(void)
289 result r = E_SUCCESS;
290 Tizen::Graphics::Bitmap* pBitmap = null;
291 Tizen::Graphics::Bitmap* pFocusBitmap = null;
292 Color focusBgColor(0x00000000);
293 Color itemSelectedColor(0x00000000);
295 r = GET_BITMAP_CONFIG_N(TAB::ITEM_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
296 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate horizontal line bitmap.");
298 GET_COLOR_CONFIG(TAB::ITEM_SELECTED, itemSelectedColor);
302 __pHorizontalLineBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pBitmap), Color::GetColor(COLOR_ID_MAGENTA), itemSelectedColor);
303 SysTryLog(NID_UI_CTRL, (__pHorizontalLineBitmap != null), "Failed to locate focus item line bitmap.");
306 // r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, __pFrontScrollingEffectBitmap);
307 // SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling left bitmap.");
309 // r = GET_BITMAP_CONFIG_N(TAB::TAB_BOUNCE_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, __pRearScrollingEffectBitmap);
310 // SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate overscrolling right bitmap.");
312 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pFocusBitmap);
313 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate focus bitmap.");
315 GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, focusBgColor);
319 __pFocusBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pFocusBitmap), Color::GetColor(COLOR_ID_MAGENTA), focusBgColor);
320 SysTryLog(NID_UI_CTRL, (__pFocusBitmap != null), "Failed to locate focus item line bitmap.");
329 _TabPresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
331 result r = E_SUCCESS;
338 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
340 r = canvas.DrawNinePatchedBitmap(bounds, *pBitmap);
341 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
345 r = canvas.DrawBitmap(bounds, *pBitmap);
346 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
353 _TabPresenter::SetModel(const _TabModel& tabModel)
355 __pTabModel = const_cast<_TabModel*>(&tabModel);
361 _TabPresenter::SetSelectedItemIndex(int index)
363 int selectedIndex = GetSelectedItemIndex();
365 SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
366 __pTabModel->SetSelectedItemIndex(index);
367 SetItemStatus(index, _TABITEM_STATUS_SELECTED);
373 _TabPresenter::GetSelectedItemIndex(void) const
375 return __pTabModel->GetSelectedItemIndex();
379 _TabPresenter::SetPressedItemIndex(int index)
381 __pTabModel->SetPressedItemIndex(index);
386 _TabPresenter::GetPressedItemIndex(void) const
388 return __pTabModel->GetPressedItemIndex();
392 _TabPresenter::SetFirstDrawnItemIndex(int index)
394 __pTabModel->SetFirstDrawnItemIndex(index);
399 _TabPresenter::GetFirstDrawnItemIndex(void) const
402 return __pTabModel->GetFirstDrawnItemIndex();
406 _TabPresenter::SetEditModeEnabled(bool isEnabled)
409 return __pTabModel->SetEditModeEnabled(isEnabled);
413 _TabPresenter::IsEditModeEnabled(void) const
415 return __pTabModel->IsEditModeEnabled();
419 _TabPresenter::GetItemCount(void) const
422 return __pTab->GetItemCount();
426 _TabPresenter::GetItemAt(int index)
428 return __pTab->GetItemAt(index);
432 _TabPresenter::SetItemStatus(int index, _TabItemStatus status)
434 _TabItem *pItem = GetItemAt(index);
435 SysTryReturn(NID_UI_CTRL, pItem, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
437 pItem->SetUpdateState(true);
438 pItem->SetStatus(status);
444 _TabPresenter::GetItemStatus(int index) const
447 _TabItem *pItem = __pTab->GetItemAt(index);
451 return _TABITEM_STATUS_NORMAL;
454 return pItem->GetStatus();
458 _TabPresenter::GetItemIndexFromPosition(const FloatPoint& point) const
461 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
463 int itemIndex = GetFirstDrawnItemIndex();
465 if ((point.x < 0.0f) || (point.x > __pTab->GetBoundsF().width)
466 || (point.y < 0.0f) || (point.y > __pTab->GetBoundsF().height))
471 _TabItem* pItem = __pTab->GetItemAt(itemIndex);
477 while (pItem != null)
479 itemBounds = pItem->GetItemBounds();
481 if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width)
482 && (point.y > itemBounds.y) && (point.y < itemBounds.y + itemBounds.height))
488 pItem = __pTab->GetItemAt(itemIndex);
499 _TabPresenter::Draw(void)
503 SysTryReturnVoidResult(NID_UI_CTRL, __pTab, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _Tab instance is null.");
504 GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, backgroundColor);
506 if (__isRecalculateNeeded)
508 __isRecalculateNeeded = false;
509 CalculateItemBounds();
511 else if (__isFlickEnabled )
516 Canvas* pCanvas = __pTab->GetCanvasN();
517 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
519 pCanvas->SetBackgroundColor(backgroundColor);
522 if (__pTab->GetStyle() == _TAB_STYLE_TEXT)
524 DrawTextItem(pCanvas);
526 else if (__pTab->GetStyle() == _TAB_STYLE_ICON)
528 DrawIconItem(pCanvas);
530 else // _TAB_STYLE_ICON_TEXT
535 if (__pTab->GetCurrentHighlightedItemIndex() > -1 && __pTab->IsInFocusMode() == true && GetItemCount() > 0)
537 DrawResourceBitmap(*pCanvas, GetItemAt(__pTab->GetCurrentHighlightedItemIndex())->GetItemBounds(), __pFocusBitmap);
540 __pTab->UpdateAccessibilityElement();
547 _TabPresenter::SetRecalculateItemBounds(bool isRecalculationRequired)
549 __isRecalculateNeeded = isRecalculationRequired;
554 _TabPresenter::DrawTextItem(Canvas* pCanvas)
557 TextSimple* pSimpleText = null;
558 Rectangle bounds = __pTab->GetBounds();
560 _TabItem* pDrawItem = null;
561 String itemText(L"");
562 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
564 const int itemCount = GetItemCount();
566 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
568 bool isMultiline = false;
570 float topMargin = 0.0f;
571 float bottomMargin = 0.0f;
572 float leftMargin = 0.0f;
573 float rightMargin = 0.0f;
574 float lineHeight = 0.0f;
575 float selectedLineHeight = 0.0f;
576 GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMargin);
577 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
578 GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
579 GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
580 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
581 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
583 SetFirstLoadedItemIndex();
584 SetLastLoadedItemIndex();
586 int startIndex = __firstLoadedItemIndex - 1;
587 int endIndex = __lastLoadedItemIndex + 1;
588 if (__firstLoadedItemIndex == 0)
590 startIndex = __firstLoadedItemIndex;
593 if (__lastLoadedItemIndex == (GetItemCount() - 1))
595 endIndex = __lastLoadedItemIndex;
598 for (int i = startIndex; i <= endIndex; i++)
600 if (i == __editItemIndex)
604 pDrawItem = GetItemAt(i);
606 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
608 SetFirstDrawnItemIndex(0);
610 itemDrawRect = pDrawItem->GetItemBounds();
611 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
612 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
614 itemStatus = pDrawItem->GetStatus();
616 if (!__pTab->IsEnabled())
618 itemStatus = _TABITEM_STATUS_DISABLED;
622 if (itemStatus == _TABITEM_STATUS_SELECTED)
624 DrawSelectedItemBackground(pCanvas, itemDrawRect);
625 __selectedLine.width = __itemWidth;
626 __selectedLine.x = itemDrawRect.x;
628 else if (itemStatus == _TABITEM_STATUS_PRESSED)
630 DrawPressedItemBackground(pCanvas, itemDrawRect);
632 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
634 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
638 DrawItemBackground(pCanvas, itemDrawRect);
641 itemText = pDrawItem->GetText();
643 __pTextObject->RemoveAll();
644 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
645 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
647 __pTextObject->AppendElement(*pSimpleText);
648 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
649 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
651 itemDrawRect.x = itemDrawRect.x + leftMargin;
652 itemDrawRect.y = itemDrawRect.y + topMargin;
653 itemDrawRect.width = itemDrawRect.width - leftMargin - rightMargin;
654 itemDrawRect.height = itemDrawRect.height - topMargin - bottomMargin;
656 __pTextObject->SetBounds(itemDrawRect);
657 __pTextObject->Compose();
659 const int textRowCount = __pTextObject->GetTotalLineCount();
663 if (textRowCount >= 2)
668 float fontSize = 0.0f;
670 if (__showItemCount < __fontChangeItemCount)
672 if (isMultiline == false)
674 GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
678 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
681 else if (__showItemCount == __fontChangeItemCount)
683 if (isMultiline == false)
685 GET_SHAPE_CONFIG(TAB::FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
689 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
694 if (isMultiline == false)
696 GET_SHAPE_CONFIG(TAB::FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
700 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
704 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
706 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
708 if (itemStatus == _TABITEM_STATUS_SELECTED)
710 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
711 __selectedLine.y = lineHeight - selectedLineHeight;
713 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
716 else if (itemStatus == _TABITEM_STATUS_PRESSED)
718 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
720 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
722 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
724 else if (itemStatus == _TABITEM_STATUS_DISABLED)
726 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
730 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
733 __pTextObject->SetBounds(itemDrawRect);
734 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
735 if (i < (itemCount - 1))
737 DrawItemDivider(*pCanvas, __dividerLine);
740 DrawBadgeIcon(pDrawItem, pCanvas);
746 DrawEditTextItem(pCanvas);
753 _TabPresenter::DrawEditTextItem(Canvas* pCanvas)
757 TextSimple* pSimpleText = null;
758 Rectangle bounds = __pTab->GetBounds();
760 _TabItem* pDrawItem = null;
761 String itemText(L"");
762 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
764 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
766 bool isMultiline = false;
768 float topMargin = 0.0f;
769 float bottomMargin = 0.0f;
770 float leftMargin = 0.0f;
771 float rightMargin = 0.0f;
772 float lineHeight = 0.0f;
773 float selectedLineHeight = 0.0f;
774 GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMargin);
775 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
776 GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
777 GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
778 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
779 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
781 pDrawItem = GetItemAt(__editItemIndex);
782 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
784 itemDrawRect = pDrawItem->GetItemBounds();
785 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
786 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
788 itemStatus = pDrawItem->GetStatus();
790 if (itemStatus == _TABITEM_STATUS_SELECTED)
792 DrawSelectedItemBackground(pCanvas, itemDrawRect);
793 __selectedLine.width = __itemWidth;
794 __selectedLine.x = itemDrawRect.x;
796 else if (itemStatus == _TABITEM_STATUS_PRESSED)
798 DrawPressedItemBackground(pCanvas, itemDrawRect);
800 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
802 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
806 DrawItemBackground(pCanvas, itemDrawRect);
809 itemText = pDrawItem->GetText();
811 __pTextObject->RemoveAll();
812 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
813 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
815 __pTextObject->AppendElement(*pSimpleText);
816 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
817 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
819 itemDrawRect.x = itemDrawRect.x + leftMargin;
820 itemDrawRect.y = itemDrawRect.y + topMargin;
821 itemDrawRect.width = itemDrawRect.width - leftMargin - rightMargin;
822 itemDrawRect.height = itemDrawRect.height - topMargin - bottomMargin;
824 __pTextObject->SetBounds(itemDrawRect);
825 __pTextObject->Compose();
827 const int textRowCount = __pTextObject->GetTotalLineCount();
831 if (textRowCount >= 2)
836 float fontSize = 0.0f;
838 if (__showItemCount < __fontChangeItemCount)
840 if (isMultiline == false)
842 GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
846 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
849 else if (__showItemCount == __fontChangeItemCount)
851 if (isMultiline == false)
853 GET_SHAPE_CONFIG(TAB::FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
857 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
862 if (isMultiline == false)
864 GET_SHAPE_CONFIG(TAB::FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
868 GET_SHAPE_CONFIG(TAB::MULTILINE_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
872 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
874 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
876 if (itemStatus == _TABITEM_STATUS_SELECTED)
878 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
879 __selectedLine.y = lineHeight - selectedLineHeight;
881 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
884 else if (itemStatus == _TABITEM_STATUS_PRESSED)
886 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
888 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
890 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
892 else if (itemStatus == _TABITEM_STATUS_DISABLED)
894 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
898 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
901 __pTextObject->SetBounds(itemDrawRect);
902 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
904 DrawBadgeIcon(pDrawItem, pCanvas);
910 _TabPresenter::DrawItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
912 Bitmap* pBackgroundBitmap = __pTab->GetBackgroundBitmap();
913 Bitmap* pDisabledBackgroundBitmap = __pTab->GetDisabledBackgroundBitmap();
915 if ((!__pTab->IsEnabled()) && (pDisabledBackgroundBitmap != null))
917 DrawResourceBitmap(*pCanvas, itemRect, pDisabledBackgroundBitmap);
921 DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
927 _TabPresenter::DrawPressedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
929 Bitmap* pBackgroundBitmap = __pTab->GetPressedItemBackgroundBitmap();
930 Bitmap* pBackgroundEffectBitmap = __pTab->GetPressedItemBackgroundEffectBitmap();
932 DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
934 DrawResourceBitmap(*pCanvas, itemRect, pBackgroundEffectBitmap);
940 _TabPresenter::DrawHighlightedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
942 Bitmap* pBackgroundBitmap = __pTab->GetHighlightedItemBackgroundBitmap();
944 DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
950 _TabPresenter::DrawSelectedItemBackground(Canvas* pCanvas, FloatRectangle& itemRect)
952 Bitmap* pBackgroundBitmap = __pTab->GetSelectedItemBackgroundBitmap();
954 DrawResourceBitmap(*pCanvas, itemRect, pBackgroundBitmap);
960 _TabPresenter::DrawIconItem(Canvas* pCanvas)
963 Rectangle bounds = __pTab->GetBounds();
965 _TabItem* pDrawItem = null;
966 String itemText(L"");
967 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
968 const int itemCount = GetItemCount();
970 SetFirstLoadedItemIndex();
971 SetLastLoadedItemIndex();
973 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
975 float iconWidth = 0.0f;
976 float iconHeight = 0.0f;
977 float bottomMargin = 0.0f;
978 float lineHeight = 0.0f;
979 float selectedLineHeight = 0.0f;
981 GET_SHAPE_CONFIG(TAB::ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
982 GET_SHAPE_CONFIG(TAB::ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
983 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
984 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
985 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
987 int startIndex = __firstLoadedItemIndex - 1;
988 int endIndex = __lastLoadedItemIndex + 1;
989 if (__firstLoadedItemIndex == 0)
991 startIndex = __firstLoadedItemIndex;
994 if (__lastLoadedItemIndex == (GetItemCount() - 1))
996 endIndex = __lastLoadedItemIndex;
999 for (int i = startIndex; i <= endIndex; i++)
1001 if (i == __editItemIndex)
1006 pDrawItem = GetItemAt(i);
1007 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1009 SetFirstDrawnItemIndex(0);
1011 itemDrawRect = pDrawItem->GetItemBounds();
1012 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1013 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1015 itemStatus = pDrawItem->GetStatus();
1017 if (!__pTab->IsEnabled())
1019 itemStatus = _TABITEM_STATUS_DISABLED;
1022 if (itemStatus == _TABITEM_STATUS_SELECTED)
1024 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1025 __selectedLine.width = __itemWidth;
1026 __selectedLine.x = itemDrawRect.x;
1027 __selectedLine.y = lineHeight - selectedLineHeight;
1029 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1032 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1034 DrawPressedItemBackground(pCanvas, itemDrawRect);
1036 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1038 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1042 DrawItemBackground(pCanvas, itemDrawRect);
1045 itemDrawRect.x = itemDrawRect.x + ((itemDrawRect.width - iconWidth) / 2.0f);
1046 itemDrawRect.y = itemDrawRect.y + ((itemDrawRect.height - iconHeight) / 2.0f);
1047 itemDrawRect.width = iconWidth;
1048 itemDrawRect.height = iconHeight;
1050 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1052 DrawResourceBitmap(*pCanvas, itemDrawRect, pIconBitmap);
1054 if (i < itemCount - 1)
1056 DrawItemDivider(*pCanvas, __dividerLine);
1059 DrawBadgeIcon(pDrawItem, pCanvas);
1064 DrawEditIconItem(pCanvas);
1071 _TabPresenter::DrawEditIconItem(Canvas* pCanvas)
1075 Rectangle bounds = __pTab->GetBounds();
1077 _TabItem* pDrawItem = null;
1078 String itemText(L"");
1079 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1081 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1083 float iconWidth = 0.0f;
1084 float iconHeight = 0.0f;
1085 float bottomMargin = 0.0f;
1086 float lineHeight = 0.0f;
1087 float selectedLineHeight = 0.0f;
1089 GET_SHAPE_CONFIG(TAB::ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1090 GET_SHAPE_CONFIG(TAB::ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1091 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1092 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1093 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1095 pDrawItem = GetItemAt(__editItemIndex);
1096 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1098 itemDrawRect = pDrawItem->GetItemBounds();
1099 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1100 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1102 itemStatus = pDrawItem->GetStatus();
1104 if (itemStatus == _TABITEM_STATUS_SELECTED)
1106 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1107 __selectedLine.width = __itemWidth;
1108 __selectedLine.x = itemDrawRect.x;
1109 __selectedLine.y = lineHeight - selectedLineHeight;
1111 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1113 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1115 DrawPressedItemBackground(pCanvas, itemDrawRect);
1117 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1119 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1123 DrawItemBackground(pCanvas, itemDrawRect);
1126 itemDrawRect.x = itemDrawRect.x + ((itemDrawRect.width - iconWidth) / 2.0f);
1127 itemDrawRect.y = itemDrawRect.y + ((itemDrawRect.height - iconHeight) / 2.0f);
1128 itemDrawRect.width = iconWidth;
1129 itemDrawRect.height = iconHeight;
1131 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1133 DrawResourceBitmap(*pCanvas, itemDrawRect, pIconBitmap);
1135 DrawBadgeIcon(pDrawItem, pCanvas);
1142 _TabPresenter::DrawItem(Canvas* pCanvas)
1146 Rectangle bounds = __pTab->GetBounds();
1148 TextSimple* pSimpleText = null;
1149 _TabItem* pDrawItem = null;
1150 Rectangle buttonBounds(0, 0, 0, 0);
1151 String itemText(L"");
1152 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1153 FloatRectangle itemDrawIconRect(0.0f, 0.0f, 0.0f, 0.0f);
1154 FloatRectangle itemDrawTextRect(0.0f, 0.0f, 0.0f, 0.0f);
1155 const int itemCount = GetItemCount();
1157 SetFirstLoadedItemIndex();
1158 SetLastLoadedItemIndex();
1160 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1162 bool isMultiline = false;
1164 float topMargin = 0.0f;
1165 float bottomMargin = 0.0f;
1166 float leftMargin = 0.0f;
1167 float rightMargin = 0.0f;
1168 float topMarginTextOnly = 0.0f;
1169 float bottomMarginTextOnly = 0.0f;
1170 float iconWidth = 0.0f;
1171 float iconHeight = 0.0f;
1172 float iconGap = 0.0f;
1173 float lineHeight = 0.0f;
1174 float selectedLineHeight = 0.0f;
1176 GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMarginTextOnly);
1177 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMarginTextOnly);
1178 GET_SHAPE_CONFIG(TAB::ICON_TEXT_TOP_MARGIN, __pTab->GetOrientation(), topMargin);
1179 GET_SHAPE_CONFIG(TAB::ICON_TEXT_BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1180 GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
1181 GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
1182 GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1183 GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1184 GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconGap);
1185 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1186 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1188 int startIndex = __firstLoadedItemIndex - 1;
1189 int endIndex = __lastLoadedItemIndex + 1;
1190 if (__firstLoadedItemIndex == 0)
1192 startIndex = __firstLoadedItemIndex;
1195 if (__lastLoadedItemIndex == (GetItemCount() - 1))
1197 endIndex = __lastLoadedItemIndex;
1200 for (int i = startIndex; i <= endIndex; i++)
1202 if (i == __editItemIndex)
1207 pDrawItem = GetItemAt(i);
1208 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1210 SetFirstDrawnItemIndex(0);
1212 itemDrawRect = pDrawItem->GetItemBounds();
1213 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1214 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1216 itemStatus = pDrawItem->GetStatus();
1218 if (!__pTab->IsEnabled())
1220 itemStatus = _TABITEM_STATUS_DISABLED;
1223 if (itemStatus == _TABITEM_STATUS_SELECTED)
1225 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1226 __selectedLine.width = __itemWidth;
1227 __selectedLine.x = itemDrawRect.x;
1229 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1231 DrawPressedItemBackground(pCanvas, itemDrawRect);
1233 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1235 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1239 DrawItemBackground(pCanvas, itemDrawRect);
1243 itemText = pDrawItem->GetText();
1245 __pTextObject->RemoveAll();
1246 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
1247 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1249 __pTextObject->AppendElement(*pSimpleText);
1251 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1252 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1253 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1254 textLength = __pTextObject->GetTextLength();
1256 if ((pDrawItem->GetIcon()) == null)
1258 topMargin = topMarginTextOnly;
1259 bottomMargin = bottomMarginTextOnly;
1261 FloatDimension textDim(0.0f, 0.0f);
1263 float fontSize = 0.0f;
1265 if (__showItemCount < __fontChangeItemCount)
1267 if (isMultiline == false)
1269 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
1273 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1276 else if (__showItemCount == __fontChangeItemCount)
1278 if (isMultiline == false)
1280 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1284 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1289 if (isMultiline == false)
1291 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1295 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1299 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
1301 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1303 __pFont->GetTextExtent(itemText, itemText.GetLength(), textDim);
1305 itemDrawTextRect = itemDrawRect;
1306 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1307 isMultiline = false;
1308 if (textDim.width > (__itemWidth / 2.0f))
1311 textDim.width = (__itemWidth / 2.0f);
1312 textDim.height = textDim.height * 2.0f;
1314 itemDrawTextRect.width = textDim.width;
1315 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1316 itemDrawTextRect.x = itemDrawTextRect.x + ((itemDrawRect.width - leftMargin - rightMargin) - (iconWidth + iconGap + itemDrawTextRect.width)) / 2.0f;
1317 itemDrawTextRect.height = textDim.height;
1318 itemDrawIconRect = itemDrawTextRect;
1319 itemDrawTextRect.x = itemDrawIconRect.x + iconWidth + iconGap;
1321 if ((pDrawItem->GetIcon()) != null)
1323 itemDrawIconRect.height = itemDrawRect.height - topMargin - bottomMargin;
1324 itemDrawIconRect.y = itemDrawIconRect.y + topMargin + (itemDrawIconRect.height - iconHeight) / 2.0f;
1326 itemDrawIconRect.width = iconWidth;
1327 itemDrawIconRect.height = iconHeight;
1328 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1330 DrawResourceBitmap(*pCanvas, itemDrawIconRect, pIconBitmap);
1335 itemDrawTextRect.x = itemDrawRect.x + leftMargin + (itemDrawRect.width - leftMargin - rightMargin - itemDrawTextRect.width) / 2.0f;
1339 if (isMultiline == false)
1341 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1345 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1347 __pTextObject->SetBounds(itemDrawTextRect);
1348 __pTextObject->Compose();
1349 if (itemStatus == _TABITEM_STATUS_SELECTED)
1351 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
1352 __selectedLine.y = lineHeight - selectedLineHeight;
1354 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1357 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1359 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
1361 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1363 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
1365 else if (itemStatus == _TABITEM_STATUS_DISABLED)
1367 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
1371 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
1374 __pTextObject->SetBounds(itemDrawTextRect);
1376 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1378 if (i < itemCount - 1)
1380 DrawItemDivider(*pCanvas, __dividerLine);
1382 DrawBadgeIcon(pDrawItem, pCanvas);
1387 DrawEditIconTextItem(pCanvas);
1393 _TabPresenter::DrawEditIconTextItem(Canvas* pCanvas)
1397 Rectangle bounds = __pTab->GetBounds();
1399 TextSimple* pSimpleText = null;
1400 _TabItem* pDrawItem = null;
1401 Rectangle buttonBounds(0, 0, 0, 0);
1402 String itemText(L"");
1403 FloatRectangle itemDrawRect(0.0f, 0.0f, 0.0f, 0.0f);
1404 FloatRectangle itemDrawIconRect(0.0f, 0.0f, 0.0f, 0.0f);
1405 FloatRectangle itemDrawTextRect(0.0f, 0.0f, 0.0f, 0.0f);
1407 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1409 bool isMultiline = false;
1412 float topMargin = 0.0f;
1413 float bottomMargin = 0.0f;
1414 float leftMargin = 0.0f;
1415 float rightMargin = 0.0f;
1416 float topMarginTextOnly = 0.0f;
1417 float bottomMarginTextOnly = 0.0f;
1418 float iconWidth = 0.0f;
1419 float iconHeight = 0.0f;
1420 float iconGap = 0.0f;
1421 float lineHeight = 0.0f;
1422 float selectedLineHeight = 0.0f;
1424 GET_SHAPE_CONFIG(TAB::TOP_MARGIN, __pTab->GetOrientation(), topMarginTextOnly);
1425 GET_SHAPE_CONFIG(TAB::BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMarginTextOnly);
1426 GET_SHAPE_CONFIG(TAB::ICON_TEXT_TOP_MARGIN, __pTab->GetOrientation(), topMargin);
1427 GET_SHAPE_CONFIG(TAB::ICON_TEXT_BOTTOM_MARGIN, __pTab->GetOrientation(), bottomMargin);
1428 GET_SHAPE_CONFIG(TAB::ITEM_LEFT_MARGIN, __pTab->GetOrientation(), leftMargin);
1429 GET_SHAPE_CONFIG(TAB::ITEM_RIGHT_MARGIN, __pTab->GetOrientation(), rightMargin);
1430 GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_WIDTH, __pTab->GetOrientation(), iconWidth);
1431 GET_SHAPE_CONFIG(TAB::ICON_TEXT_ICON_HEIGHT, __pTab->GetOrientation(), iconHeight);
1432 GET_FIXED_VALUE_CONFIG(TAB::ICON_TEXT_GAP, __pTab->GetOrientation(), iconGap);
1433 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1434 GET_SHAPE_CONFIG(TAB::SELECTED_LINE_HEIGHT, __pTab->GetOrientation(), selectedLineHeight);
1436 pDrawItem = GetItemAt(__editItemIndex);
1437 SysTryReturnVoidResult(NID_UI_CTRL, pDrawItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1439 SetFirstDrawnItemIndex(0);
1441 itemDrawRect = pDrawItem->GetItemBounds();
1442 __dividerLine.x = itemDrawRect.x + (itemDrawRect.width - (__dividerLine.width) / 2.0f);
1443 __dividerLine.y = ((itemDrawRect.height - __dividerLine.height) / 2.0f);
1445 itemStatus = pDrawItem->GetStatus();
1447 if (itemStatus == _TABITEM_STATUS_SELECTED)
1449 DrawSelectedItemBackground(pCanvas, itemDrawRect);
1450 __selectedLine.width = __itemWidth;
1451 __selectedLine.x = itemDrawRect.x;
1453 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1455 DrawPressedItemBackground(pCanvas, itemDrawRect);
1457 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1459 DrawHighlightedItemBackground(pCanvas, itemDrawRect);
1463 DrawItemBackground(pCanvas, itemDrawRect);
1466 itemText = pDrawItem->GetText();
1468 __pTextObject->RemoveAll();
1469 pSimpleText = new (std::nothrow)TextSimple(const_cast <mchar*>(itemText.GetPointer()), itemText.GetLength());
1470 SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1472 __pTextObject->AppendElement(*pSimpleText);
1474 __pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1475 __pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1476 __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1477 textLength = __pTextObject->GetTextLength();
1479 if ((pDrawItem->GetIcon()) == null)
1481 topMargin = topMarginTextOnly;
1482 bottomMargin = bottomMarginTextOnly;
1485 FloatDimension textDim(0.0f, 0.0f);
1488 float fontSize = 0.0f;
1490 if (__showItemCount < __fontChangeItemCount)
1492 if (isMultiline == false)
1494 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_01, __pTab->GetOrientation(), fontSize);
1498 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1501 else if (__showItemCount == __fontChangeItemCount)
1503 if (isMultiline == false)
1505 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1509 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_02, __pTab->GetOrientation(), fontSize);
1514 if (isMultiline == false)
1516 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1520 GET_SHAPE_CONFIG(TAB::ICON_TEXT_FONT_SIZE_03, __pTab->GetOrientation(), fontSize);
1524 (_FontImpl::GetInstance(*__pFont))->SetSize(fontSize);
1526 __pTextObject->SetFont(__pFont, 0, __pTextObject->GetTextLength());
1528 __pFont->GetTextExtent(itemText, itemText.GetLength(), textDim);
1530 itemDrawTextRect = itemDrawRect;
1531 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1532 isMultiline = false;
1534 if (textDim.width > (__itemWidth / 2.0f))
1537 textDim.width = (__itemWidth / 2.0f);
1538 textDim.height = textDim.height * 2.0f;
1541 itemDrawTextRect.width = textDim.width;
1542 itemDrawTextRect.x = itemDrawRect.x + leftMargin;
1543 itemDrawTextRect.x = itemDrawTextRect.x + ((itemDrawRect.width - leftMargin - rightMargin) - (iconWidth + iconGap + itemDrawTextRect.width)) / 2.0f;
1544 itemDrawTextRect.height = textDim.height;
1545 itemDrawIconRect = itemDrawTextRect;
1546 itemDrawTextRect.x = itemDrawIconRect.x + iconWidth + iconGap;
1548 if ((pDrawItem->GetIcon()) != null)
1550 itemDrawIconRect.height = itemDrawRect.height - topMargin - bottomMargin;
1551 itemDrawIconRect.y = itemDrawIconRect.y + topMargin + (itemDrawIconRect.height - iconHeight) / 2.0f;
1553 itemDrawIconRect.width = iconWidth;
1554 itemDrawIconRect.height = iconHeight;
1555 Bitmap* pIconBitmap = pDrawItem->GetIcon();
1557 DrawResourceBitmap(*pCanvas, itemDrawIconRect, pIconBitmap);
1561 itemDrawTextRect.x = itemDrawRect.x + leftMargin + (itemDrawRect.width - leftMargin - rightMargin - itemDrawTextRect.width) / 2.0f;
1565 if (isMultiline == false)
1567 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1571 itemDrawTextRect.y = itemDrawRect.y + topMargin + (itemDrawRect.height - topMargin - bottomMargin - itemDrawTextRect.height) / 2.0f;
1574 __pTextObject->SetBounds(itemDrawTextRect);
1575 __pTextObject->Compose();
1576 if (itemStatus == _TABITEM_STATUS_SELECTED)
1578 __pTextObject->SetForegroundColor(__pTab->GetSelectedTextColor(), 0, __pTextObject->GetTextLength());
1579 __selectedLine.y = lineHeight - selectedLineHeight;
1581 DrawResourceBitmap(*pCanvas, __selectedLine, __pHorizontalLineBitmap);
1583 else if (itemStatus == _TABITEM_STATUS_PRESSED)
1585 __pTextObject->SetForegroundColor(__pTab->GetPressedTextColor(), 0, __pTextObject->GetTextLength());
1587 else if (itemStatus == _TABITEM_STATUS_HIGHLIGHTED)
1589 __pTextObject->SetForegroundColor(__pTab->GetHighlightedTextColor(), 0, __pTextObject->GetTextLength());
1591 else if (itemStatus == _TABITEM_STATUS_DISABLED)
1593 __pTextObject->SetForegroundColor(__pTab->GetDisabledTextColor(), 0, __pTextObject->GetTextLength());
1597 __pTextObject->SetForegroundColor(__pTab->GetTextColor(), 0, __pTextObject->GetTextLength());
1600 __pTextObject->SetBounds(itemDrawTextRect);
1602 __pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1604 DrawBadgeIcon(pDrawItem, pCanvas);
1610 _TabPresenter::SetEditItemBounds(const FloatPoint& point)
1612 _TabItem *pTabItem = null;
1613 FloatRectangle editRect(0.0f, 0.0f, 0.0f, 0.0f);
1614 pTabItem = GetItemAt(__editItemIndex);
1615 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1617 editRect = pTabItem->GetItemBounds();
1619 editRect.x = point.x - (__itemWidth / 2.0f);
1620 pTabItem->SetItemBounds(editRect);
1626 _TabPresenter::DrawItemDivider(Canvas& canvas, FloatRectangle& lineRect)
1628 Color dividerLeftHalfColor;
1629 Color dividerRightHalfColor;
1631 float halfLineWidth = 0.0f;
1633 GET_COLOR_CONFIG(TAB::DIVIDER_LEFT_HALF, dividerLeftHalfColor);
1634 GET_COLOR_CONFIG(TAB::DIVIDER_RIGHT_HALF, dividerRightHalfColor);
1636 result r = E_SUCCESS;
1637 halfLineWidth = lineRect.width / 2.0f;
1639 canvas.SetForegroundColor(dividerLeftHalfColor);
1640 canvas.SetLineWidth(halfLineWidth);
1642 r = canvas.DrawLine(FloatPoint(lineRect.x, lineRect.y), FloatPoint(lineRect.x, lineRect.y + lineRect.height));
1643 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1645 canvas.SetForegroundColor(dividerRightHalfColor);
1646 canvas.SetLineWidth(halfLineWidth);
1648 r = canvas.DrawLine(FloatPoint(lineRect.x + halfLineWidth, lineRect.y), FloatPoint(lineRect.x + halfLineWidth, lineRect.y + lineRect.height));
1649 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1655 _TabPresenter::DrawHorizontal()
1659 int itemCount = GetItemCount();
1660 int boundItemIndex = 0;
1661 if (__moveDistance == 0.0f)
1667 SysLog(NID_UI_CTRL, "itemCount is 0.");
1671 //Bound beyond which the item shouldnt move when flicked
1672 boundItemIndex = itemCount - __itemMaxCount;
1674 _TabItem* pItem = null;
1675 pItem = GetItemAt(boundItemIndex);
1676 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1678 FloatRectangle bounds = pItem->GetItemBounds();
1679 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
1680 if ((bounds.x + __moveDistance) < 0.0f)
1682 __moveDistance = -bounds.x;
1683 ResetFlickAnimationTimer();
1686 pItem = GetItemAt(0);
1687 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1689 bounds = pItem->GetItemBounds();
1691 if ((bounds.x + __moveDistance) > 0.0f)
1693 CalculateItemBounds();
1694 ResetFlickAnimationTimer();
1698 for (int i = 0; i < itemCount; i++)
1700 pItem = GetItemAt(i);
1701 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1703 itemBounds = pItem->GetItemBounds();
1705 itemBounds.x = itemBounds.x + __moveDistance;
1706 pItem->SetItemBounds(itemBounds);
1712 _TabPresenter::ShiftToFocusedItem(int itemIndex, _FocusDirectionMove direction)
1714 if (direction == _FOCUS_DIRECTION_MOVE_LEFT && itemIndex == __firstLoadedItemIndex - 1) //left key pressed
1716 SetItemFit(__firstLoadedItemIndex - 1);
1718 if (direction == _FOCUS_DIRECTION_MOVE_RIGHT && itemIndex == __lastLoadedItemIndex + 1) //right key pressed
1720 SetItemFit(__firstLoadedItemIndex + 1);
1722 if(itemIndex == 0) //when touched
1726 __pTab->Invalidate();
1732 _TabPresenter::DrawBadgeIcon(_TabItem* pDrawItem, Canvas* pCanvas)
1734 Bitmap* pBadgeIcon = null;
1735 float badgeMargin = 0.0f;
1736 GET_SHAPE_CONFIG(TAB::BADGE_ICON_MARGIN, __pTab->GetOrientation(), badgeMargin);
1738 pBadgeIcon = pDrawItem->GetBadgeIcon();
1740 if (pBadgeIcon != null)
1742 FloatRectangle badgeRect = pDrawItem->GetItemBounds();
1744 badgeRect.x = (badgeRect.x + badgeRect.width) - pBadgeIcon->GetWidthF() - badgeMargin;
1745 badgeRect.y = badgeMargin;
1746 badgeRect.width = pBadgeIcon->GetWidthF();
1747 badgeRect.height = pBadgeIcon->GetHeightF();
1749 DrawResourceBitmap(*pCanvas, badgeRect, pBadgeIcon);
1757 _TabPresenter::CalculateItemBounds(void)
1761 GET_SHAPE_CONFIG(TAB::SCREEN_WIDTH, __pTab->GetOrientation(), __width);
1762 GET_SHAPE_CONFIG(TAB::SCREEN_HEIGHT, __pTab->GetOrientation(), __height);
1764 const int itemCount = GetItemCount();
1771 CalculateTabBounds(true);
1773 FloatRectangle bounds = __pTab->GetBoundsF();
1775 _TabItem* pItem = null;
1776 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
1778 if (__itemMaxCount > itemCount)
1780 __showItemCount = itemCount;
1784 __showItemCount = __itemMaxCount;
1787 itemBounds.width = bounds.width / __showItemCount;
1788 itemBounds.height = bounds.height;
1789 __itemWidth = itemBounds.width;
1790 __itemHeight = bounds.height;
1793 for (int i = 0; i < itemCount; i++)
1795 pItem = GetItemAt(i);
1796 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1798 __pAnimInfo[i]->xPosition = itemBounds.x;
1799 __pAnimInfo[i]->totalDistance = __itemWidth;
1800 pItem->SetItemBounds(itemBounds);
1801 itemBounds.x = itemBounds.x + itemBounds.width;
1807 _TabPresenter::CalculateTabBounds(bool isReset)
1809 FloatRectangle bounds = __pTab->GetBoundsF();
1811 bool isMovable = __pTab->IsMovable();
1812 bool isResizable = __pTab->IsResizable();
1814 float lineHeight = 0.0f;
1815 float tabLeftMargin = 0.0f;
1816 float tabRightMargin = 0.0f;
1817 GET_SHAPE_CONFIG(TAB::LEFT_MARGIN, __pTab->GetOrientation(), tabLeftMargin);
1818 GET_SHAPE_CONFIG(TAB::RIGHT_MARGIN, __pTab->GetOrientation(), tabRightMargin);
1819 GET_SHAPE_CONFIG(TAB::HEIGHT, __pTab->GetOrientation(), lineHeight);
1821 __lastItemIndex = (__pTab->GetItemCount() - 1);
1823 bounds.height = lineHeight;
1825 for (int i = 0; i < (__pTab->GetItemCount()); i++)
1827 if (__pAnimInfo[i] == null)
1829 __pAnimInfo[i] = new (std::nothrow) ReorderAnimationInfo();
1830 SysTryReturnVoidResult(NID_UI_CTRL, __pAnimInfo[i], E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1832 __pAnimInfo[i]->totalDistance = 0.0f;
1833 __pAnimInfo[i]->move = 0.0f;
1834 __pAnimInfo[i]->reorderValue = 0;
1838 __pTab->SetMovable(true);
1839 __pTab->SetResizable(true);
1841 __pTab->SetBounds(bounds);
1843 __pTab->SetMovable(isMovable);
1844 __pTab->SetResizable(isResizable);
1851 _TabPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1853 if (GetItemCount() == 0)
1857 __currentTouchPosition = touchinfo.GetCurrentPosition();
1858 SetFirstLoadedItemIndex();
1859 SetLastLoadedItemIndex();
1860 ResetScrollAnimationTimer();
1861 SetRecalculateItemBounds(false);
1862 ResetFlickAnimationTimer();
1864 const int index = GetItemIndexFromPosition(__currentTouchPosition);
1870 if (GetItemStatus(index) != _TABITEM_STATUS_SELECTED)
1872 SetItemStatus(index, _TABITEM_STATUS_PRESSED);
1873 SetPressedItemIndex(index);
1876 __pTab->Invalidate();
1882 _TabPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1884 if (GetItemCount() == 0)
1889 // __scrollFlag = 0;
1890 Rectangle itemBounds(0, 0, 0, 0);
1891 _TabItem* pItem = null;
1893 ResetReorderTimer();
1894 ResetScrollAnimationTimer();
1895 int index = GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1897 // if (__pScrollingEffectVe)
1899 // __pScrollingEffectVe->RemoveAllAnimations();
1900 // __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
1901 // __pScrollingEffectVe->Destroy();
1902 // __pScrollingEffectVe = null;
1903 // __isScrollEffectEnded = false;
1904 // __isScrollEffectStarted = false;
1907 int pressedIndex = GetPressedItemIndex();
1908 __isRightScrollable = false;
1910 if (index == -1 && !__isFlickEnabled)
1912 SetFirstLoadedItemIndex();
1913 if (GetItemStatus(pressedIndex) == _TABITEM_STATUS_PRESSED)
1915 SetItemStatus(pressedIndex, _TABITEM_STATUS_NORMAL);
1917 CalculateItemBounds();
1919 __moveDistance = -(GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x);
1921 __pTab->Invalidate();
1924 __isEditMode = false;
1927 if (__isEditMode && __editItemIndex == __rearIndex)
1929 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1930 if (__editItemIndex > 0)
1932 pItem = GetItemAt((__editItemIndex - 1));
1933 SysTryReturn(NID_UI_CTRL, pItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1935 bounds = pItem->GetItemBounds();
1936 bounds.x = bounds.x + __itemWidth;
1937 GetItemAt(__editItemIndex)->SetItemBounds(bounds);
1941 CalculateItemBounds();
1945 // Edit Mode - Item Insert
1946 if (__isEditMode && (__editItemIndex != __rearIndex))
1948 index = __rearIndex;
1949 int selectedIndex = GetSelectedItemIndex();
1950 SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
1952 if (__isDirectionRight)
1957 __pTab->ChangeItemAt(__editItemIndex, (index));
1958 if (__editItemIndex < index)
1960 SetItemStatus((index-1), _TABITEM_STATUS_SELECTED);
1961 SetSelectedItemIndex((index-1));
1963 else if (__editItemIndex > index)
1965 SetItemStatus(index, _TABITEM_STATUS_SELECTED);
1966 SetSelectedItemIndex(index);
1969 SetFirstLoadedItemIndex();
1970 SetLastLoadedItemIndex();
1973 CalculateItemBounds();
1974 __moveDistance = -(__firstLoadedItemIndex * __itemWidth);
1979 // Pressed -> Selected or Normal
1980 if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && !__isFlickEnabled && !__isTouchMove)
1982 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pTab);
1983 int selectedIndex = GetSelectedItemIndex();
1984 SetItemStatus(selectedIndex, _TABITEM_STATUS_NORMAL);
1986 SetItemStatus(index, _TABITEM_STATUS_SELECTED);
1987 SetSelectedItemIndex(index);
1991 int pressedIndex = GetPressedItemIndex();
1992 if (GetItemStatus(pressedIndex) == _TABITEM_STATUS_PRESSED)
1994 SetItemStatus(pressedIndex, _TABITEM_STATUS_NORMAL);
2001 __pTab->Invalidate();
2002 __isTouchMove = false;
2003 __isEditMode = false;
2004 __editItemIndex = -1;
2007 if (__firstItemIndex > 0)
2012 if (__lastItemIndex < (__pTab->GetItemCount() - 1))
2021 _TabPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2023 if (GetItemCount() == 0)
2028 _TabItem *pTabItem = null;
2029 _TabItem *pNextItem = null;
2030 _TabItem *pPrevItem = null;
2031 FloatPoint movedPosition = touchinfo.GetCurrentPosition();
2033 int index = GetNextItemIndexFromPosition(movedPosition, __editItemIndex);
2034 SetFirstLoadedItemIndex();
2035 SetLastLoadedItemIndex();
2037 //Remove the Pressed Bitmap during Touch Move
2038 int i = GetPressedItemIndex();
2041 if (GetItemStatus(i) == _TABITEM_STATUS_PRESSED)
2043 SetItemStatus(i, _TABITEM_STATUS_NORMAL);
2049 distance = movedPosition.x - __currentTouchPosition.x;
2050 __currentTouchPosition.x = movedPosition.x;
2052 // if (!__isEditMode && distance > 0.0f) //Move right i.e Bounce at leftEnd
2054 // __isTouchMove = true;
2055 // if (!__isDirectionRight)
2057 // if (__pScrollingEffectVe)
2059 // __pScrollingEffectVe->RemoveAllAnimations();
2060 // __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
2061 // __pScrollingEffectVe->Destroy();
2062 // __pScrollingEffectVe = null;
2065 // __isScrollEffectEnded = false;
2066 // __isScrollEffectStarted = false;
2069 // __isDirectionRight = true;
2070 // SetFirstLoadedItemIndex();
2071 // if ( GetItemAt(0)->GetItemBounds().x >= 0.0f)
2073 // if (!__isScrollEffectStarted)
2075 // __pScrollingEffectBitmap = __pFrontScrollingEffectBitmap;
2076 // SetOpacityVisualElement(0.0f);
2077 // StartScrollingEffect();
2080 // __isScrollEffectStarted = true;
2083 // __moveDistance = distance;
2084 // DrawHorizontal();
2086 // __moveDistance = 0.0f;
2091 // if (!__isEditMode && distance < 0.0f)//Move left i.e Bounce at RightEnd
2093 // __isTouchMove = true;
2094 // if (__isDirectionRight)
2096 // if (__pScrollingEffectVe)
2098 // __pScrollingEffectVe->RemoveAllAnimations();
2099 // __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
2100 // __pScrollingEffectVe->Destroy();
2101 // __pScrollingEffectVe = null;
2104 // __isScrollEffectEnded = false;
2105 // __isScrollEffectStarted = false;
2108 // __isDirectionRight = false;
2109 // SetLastLoadedItemIndex();
2111 // if ( __lastLoadedItemIndex == (GetItemCount() - 1) && ((GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x + __itemWidth) <= (__width)))
2113 // if (!__isScrollEffectStarted)
2115 // int index = (GetItemCount() - 1);
2116 // float xPosition = (GetItemAt(index)->GetItemBounds().x + (__itemWidth / 2.0f));
2117 // __pScrollingEffectBitmap = __pRearScrollingEffectBitmap;
2118 // SetOpacityVisualElement(xPosition);
2119 // StartScrollingEffect();
2122 // __isScrollEffectStarted = true;
2125 // __moveDistance = distance;
2126 // DrawHorizontal();
2128 // __moveDistance = 0.0f;
2138 if (distance > 0.0f)
2140 if (!__isDirectionRight)
2142 __isTimerCanceled = true;
2143 __isRightScrollable = false;
2144 __isLeftScrollable = false;
2145 ResetReorderTimer();
2148 __isDirectionRight = true;
2152 if (__isDirectionRight)
2154 __isTimerCanceled = true;
2155 __isLeftScrollable = false;
2156 __isRightScrollable = false;
2157 ResetReorderTimer();
2160 __isDirectionRight = false;
2163 pTabItem = GetItemAt(__editItemIndex);
2164 SysTryReturn(NID_UI_CTRL, pTabItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2166 FloatRectangle bounds = pTabItem->GetItemBounds();
2169 if (__isDirectionRight)
2171 pNextItem = GetItemAt(index);
2172 SysTryReturn(NID_UI_CTRL, pNextItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2174 FloatRectangle boundsNext = pNextItem->GetItemBounds();
2175 if ((bounds.x + (__itemWidth / 2.0f)) > (boundsNext.x) && ((bounds.x + __itemWidth) < (boundsNext.x + boundsNext.width)))
2177 __pTimerInfo[__timerCount]->index = index;
2178 StartReorderTimer(__timerCount);
2180 if (__timerCount >= (__itemMaxCount - 1))
2185 __isTimerCanceled = false;
2186 __rearIndex = index;
2191 pPrevItem = GetItemAt(index);
2192 SysTryReturn(NID_UI_CTRL, pPrevItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2194 FloatRectangle boundsPrev = pPrevItem->GetItemBounds();
2195 if ((bounds.x + (__itemWidth / 2.0f)) > (boundsPrev.x + (__itemWidth / 2.0f)) && ((bounds.x + (__itemWidth / 2.0f)) < (boundsPrev.x + boundsPrev.width)))
2197 __pTimerInfo[__timerCount]->index = index;
2198 StartReorderTimer(__timerCount);
2200 if (__timerCount >= (__itemMaxCount - 1))
2205 __isTimerCanceled = false;
2206 __rearIndex = index;
2211 else //Scroll the entire tab when item moves beyond boundary
2213 if ((bounds.x + __itemWidth) > (__width - (__itemWidth / 2.0f)))
2215 if (__isDirectionRight)
2217 _TabItem *pLastItem = GetItemAt(__lastItemIndex);
2218 SysTryReturn(NID_UI_CTRL, pLastItem, false, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2220 if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) > __width)
2222 __isRightScrollable = true;
2223 StartScrollAnimationTimer();
2228 if (bounds.x < 0.0f)
2230 if (!__isDirectionRight)
2232 if (GetItemAt(__firstItemIndex)->GetItemBounds().x < __itemWidth)
2234 __isLeftScrollable = true;
2235 StartScrollAnimationTimer();
2241 SetEditItemBounds(movedPosition);
2242 __pTab->Invalidate();
2248 _TabPresenter::ShiftItems(void)
2250 int itemCount = GetItemCount();
2251 float fitDistance = 0.0f;
2252 _TabItem* pTabItem = null;
2253 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2255 pTabItem = GetItemAt(0);
2256 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2258 bounds = pTabItem->GetItemBounds();
2260 for (int i = 0; i < itemCount; i++)
2262 if (i == __editItemIndex)
2267 if (__isRightScrollable)
2269 if (i == __rearIndex + 1)
2271 fitDistance = -(2.0f * __itemWidth);
2276 fitDistance = -__itemWidth;
2281 if (i == __rearIndex - 1)
2283 fitDistance = (2.0f * __itemWidth);
2288 fitDistance = __itemWidth;
2292 pTabItem = GetItemAt(i);
2293 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2295 bounds = pTabItem->GetItemBounds();
2296 bounds.x = bounds.x + fitDistance;
2297 if ( i == __firstItemIndex && ( bounds.x ) >= (2.0f * __itemWidth))
2302 pTabItem->SetItemBounds(bounds);
2306 if (__isRightScrollable)
2311 if (__isLeftScrollable)
2321 _TabPresenter::OnLongPressGestureDetected(void)
2323 if (!__pTabModel->IsEditModeEnabled())
2328 const int index = GetItemIndexFromPosition(__currentTouchPosition);
2335 if (GetItemStatus(index) == _TABITEM_STATUS_PRESSED && GetSelectedItemIndex() != index)
2337 SetItemStatus(index, _TABITEM_STATUS_NORMAL);
2340 __isEditMode = true;
2341 __editItemIndex = index;
2343 if (__editItemIndex == __firstItemIndex)
2345 __firstItemIndex = __firstItemIndex + 1;
2348 if (__editItemIndex == __lastItemIndex)
2350 __lastItemIndex = __lastItemIndex - 1;
2353 __rearIndex = index;
2354 __pTab->Invalidate();
2360 _TabPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
2362 if (GetItemCount() == 0)
2372 if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT)
2377 float distanceX = 0.0f;
2378 float distanceY = 0.0f;
2379 float xPosition = 0.0f;
2380 int itemsBeyondScreen = 0;
2382 gesture.GetDistance(distanceX, distanceY);
2383 SetFirstLoadedItemIndex();
2384 SetLastLoadedItemIndex();
2385 int itemCount = GetItemCount();
2387 if (distanceX < 0.0f) //left
2389 itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex;
2390 xPosition = GetItemAt(__lastLoadedItemIndex)->GetItemBounds().x;
2391 if (xPosition < (3.0f * __itemWidth))
2393 __flickDistance = xPosition - (4.0f * __itemWidth);
2398 itemsBeyondScreen = __firstLoadedItemIndex;
2399 xPosition = GetItemAt(__firstLoadedItemIndex)->GetItemBounds().x;
2400 if (xPosition < 0.0f)
2402 __flickDistance = -xPosition;
2407 if (itemsBeyondScreen >= (__itemMaxCount - 1))
2409 __flickDistance = (3.0f * __itemWidth);
2413 __flickDistance = (itemsBeyondScreen * __itemWidth);
2416 if (distanceX < 0) //Left flick
2418 __flickMove = 0.006f;
2421 else if (distanceX > 0) //Right flick
2423 __flickMove = 0.006f;
2424 __flickDistance = -(__flickDistance);
2430 __flickDistance = 0.0f;
2432 __moveDistance = 0.0f;
2435 __isFlickEnabled = true;
2437 StartFlickAnimationTimer();
2443 _TabPresenter::StartFlickAnimation(void)
2445 float distance = CalculateProgress(__flickMove);
2446 __moveDistance = -(__flickDistance * distance);
2447 __flickDistance = (__flickDistance + __moveDistance);
2448 __flickMove = __flickMove + 0.006f;
2451 if (__flickFlag <= FLICK_ANIMATION_COUNT)
2453 StartFlickAnimationTimer();
2457 ResetFlickAnimationTimer();
2466 _TabPresenter::StartFlickAnimationTimer(void)
2468 result r = E_SUCCESS;
2470 if (__pFlickAnimationTimer == null)
2472 __pFlickAnimationTimer = new (std::nothrow) Timer;
2473 SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2475 r = __pFlickAnimationTimer->Construct(*this);
2476 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2480 __pFlickAnimationTimer->Cancel();
2483 r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD);
2484 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2489 ResetFlickAnimationTimer();
2494 _TabPresenter::StartScrollAnimationTimer(void)
2496 result r = E_SUCCESS;
2497 ResetReorderTimer();
2498 if (__pScrollAnimationTimer == null)
2500 __pScrollAnimationTimer = new (std::nothrow) Timer;
2501 SysTryReturn(NID_UI_CTRL, (__pScrollAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2503 r = __pScrollAnimationTimer->Construct(*this);
2504 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2508 __pScrollAnimationTimer->Cancel();
2511 r = __pScrollAnimationTimer->Start(SCROLL_ANIMATION_TIMER_PERIOD);
2512 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2517 ResetScrollAnimationTimer();
2522 _TabPresenter::ResetScrollAnimationTimer(void)
2524 if (__pScrollAnimationTimer)
2526 delete __pScrollAnimationTimer;
2527 __pScrollAnimationTimer = null;
2533 _TabPresenter::ResetFlickAnimationTimer(void)
2535 if (__pFlickAnimationTimer)
2537 delete __pFlickAnimationTimer;
2538 __pFlickAnimationTimer = null;
2541 __isFlickEnabled = false;
2542 __moveDistance = 0.0f;
2547 _TabPresenter::SetItemFit(int index)
2549 Point pt = Point(0, 0);
2550 int itemCount = GetItemCount();
2551 float fitDistance = 0.0f;
2552 _TabItem* pTabItem = null;
2553 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2555 pTabItem = GetItemAt(index);
2556 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2558 bounds = pTabItem->GetItemBounds();
2559 fitDistance = -bounds.x;
2561 for (int i = 0; i < itemCount; i++)
2563 pTabItem = GetItemAt(i);
2564 SysTryReturnVoidResult(NID_UI_CTRL, pTabItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2566 bounds = pTabItem->GetItemBounds();
2567 bounds.x = bounds.x + fitDistance;
2568 pTabItem->SetItemBounds(bounds);
2575 _TabPresenter::SetItemFitToLeft(void)
2577 SetItemFit(__firstLoadedItemIndex);
2582 _TabPresenter::SetItemFitToRight(void)
2584 SetItemFit(__lastLoadedItemIndex);
2589 _TabPresenter::OnTimerExpired(Timer& timer)
2591 if (&timer == __pFlickAnimationTimer)
2593 StartFlickAnimation();
2596 for (int i = 0; i < _TIMER_COUNT; i++)
2598 if (!__isTimerCanceled)
2600 if (&timer == __pTimerInfo[i]->pReorderTimer)
2602 StartReorderAnimation(__pTimerInfo[i]->index, i);
2607 if (&timer == __pScrollAnimationTimer)
2609 _TabItem* pLastItem = GetItemAt(__lastItemIndex);
2610 SysTryReturnVoidResult(NID_UI_CTRL, pLastItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2612 if ((GetItemAt(__firstItemIndex)->GetItemBounds().x >= __itemWidth))
2614 __isRightScrollable = false;
2615 __isLeftScrollable = false;
2618 if ((pLastItem->GetItemBounds().x + pLastItem->GetItemBounds().width) <= __width && __isDirectionRight)
2620 __isRightScrollable = false;
2621 __isLeftScrollable = false;
2624 if (__isRightScrollable || __isLeftScrollable)
2626 if ((__rearIndex - 1) == __editItemIndex && !__isDirectionRight)
2628 if (__isLeftScrollable)
2634 if ((__rearIndex + 1) == __editItemIndex && __isDirectionRight)
2636 if (__isRightScrollable)
2643 StartScrollAnimationTimer();
2647 ResetScrollAnimationTimer();
2654 _TabPresenter::CalculateProgress(float timeProgress) const
2656 const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}};
2657 float loc_5 = timeProgress / 1;
2658 int loc_6 = 3; //Length of the segments array
2659 int loc_9 = (int)floor(loc_6 * loc_5);
2664 float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
2666 for (int i = 0; i < 3; i++)
2668 loc_8[i] = segments[loc_9][i];
2670 float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
2675 _TabPresenter::StartReorderTimer(int index)
2678 result r = E_SUCCESS;
2679 if (__pTimerInfo[index]->pReorderTimer == null)
2681 __pTimerInfo[index]->pReorderTimer = new (std::nothrow) Timer;
2682 SysTryReturn(NID_UI_CTRL, (__pTimerInfo[index]->pReorderTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2684 r = __pTimerInfo[index]->pReorderTimer->Construct(*this);
2685 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2689 __pTimerInfo[index]->pReorderTimer->Cancel();
2692 r = __pTimerInfo[index]->pReorderTimer->Start(REORDER_TIMER_PERIOD);
2693 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2698 ResetReorderTimer();
2703 _TabPresenter::FreeHorizontalLineBitmap()
2705 if (__pHorizontalLineBitmap != null)
2707 delete __pHorizontalLineBitmap;
2708 __pHorizontalLineBitmap = null;
2715 _TabPresenter::ResetReorderTimer()
2717 for (int index = 0; index < (__pTab->GetItemCount()); index++)
2719 if (index < _TIMER_COUNT && __pTimerInfo[index])
2721 if (__pTimerInfo[index]->pReorderTimer)
2723 __pTimerInfo[index]->pReorderTimer->Cancel();
2727 if (__pAnimInfo[index])
2729 __pAnimInfo[index]->totalDistance = __itemWidth;
2730 __pAnimInfo[index]->move = 0.5f;
2731 __pAnimInfo[index]->reorderValue = 0;
2738 _TabPresenter::CancelReorderTimer(int index)
2740 __pAnimInfo[index]->totalDistance = __itemWidth;
2741 __pAnimInfo[index]->move = 0.5f;
2742 __pAnimInfo[index]->reorderValue = 0;
2744 for (int i = 0; i <_TIMER_COUNT; i++)
2746 if (__pTimerInfo[i])
2748 if (__pTimerInfo[i]->pReorderTimer)
2750 __pTimerInfo[i]->pReorderTimer->Cancel();
2758 _TabPresenter::StartReorderAnimation(int index, int timerIndex)
2760 float dist = CalculateProgress(__pAnimInfo[index]->move);
2761 __reorderDist = -(__pAnimInfo[index]->totalDistance * dist);
2763 __pAnimInfo[index]->move = __pAnimInfo[index]->move + 0.5f;
2764 __pAnimInfo[index]->totalDistance = (__pAnimInfo[index]->totalDistance + __reorderDist);
2766 if (!__isDirectionRight)
2768 __reorderDist = -__reorderDist;
2771 __pAnimInfo[index]->reorderValue++;
2773 if (__pAnimInfo[index]->reorderValue <= REORDER_ANIMATION_COUNT)
2775 SwapItems(index, __reorderDist);
2776 StartReorderTimer(timerIndex);
2781 CancelReorderTimer(index);
2791 _TabPresenter::SwapItems(int indexDest, float distance)
2794 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
2795 pItem = GetItemAt(indexDest);
2796 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2798 itemBounds = pItem->GetItemBounds();
2799 itemBounds.x = itemBounds.x + distance;
2800 SetFirstLoadedItemIndex();
2801 SetLastLoadedItemIndex();
2804 index = GetNextItemIndexFromPosition(FloatPoint(itemBounds.x,itemBounds.y), __editItemIndex);
2806 if (distance < 0.0f) //Moving Left
2808 animIndex = indexDest - __lastLoadedItemIndex;
2810 if (__pTab->GetItemCount() >= __itemMaxCount)
2812 animIndex = animIndex + (__itemMaxCount - 1);
2816 animIndex = animIndex + (__pTab->GetItemCount() - 1);
2819 if ((__lastLoadedItemIndex > __editItemIndex) && (indexDest < __editItemIndex))
2824 if ((itemBounds.x <= __pAnimInfo[animIndex]->xPosition) && (itemBounds.x >= __pAnimInfo[animIndex-1]->xPosition))
2826 if (index == -1 || index == indexDest) //to avoid overlaping of items on each other
2828 pItem->SetItemBounds(itemBounds);
2833 if (distance > 0.0f)
2835 animIndex = indexDest - __firstLoadedItemIndex;
2837 if ((__firstLoadedItemIndex < __editItemIndex) && (indexDest > __editItemIndex))
2842 if ((itemBounds.x >= __pAnimInfo[animIndex]->xPosition) && (itemBounds.x <= __pAnimInfo[animIndex+1]->xPosition))
2844 if (index == -1 || index == indexDest)
2846 pItem->SetItemBounds(itemBounds);
2857 _TabPresenter::GetNextItemIndexFromPosition(const FloatPoint& point, int curIndex) const
2859 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
2861 int itemIndex = GetFirstDrawnItemIndex();
2863 if ((point.x < 0.0f) || (point.x > __pTab->GetBoundsF().width))
2868 _TabItem* pItem = __pTab->GetItemAt(itemIndex);
2875 while (pItem != null)
2877 itemBounds = pItem->GetItemBounds();
2879 if ((point.x > itemBounds.x) && (point.x < itemBounds.x + itemBounds.width))
2881 if (curIndex != itemIndex)
2888 pItem = __pTab->GetItemAt(itemIndex);
2900 _TabPresenter::SetFirstLoadedItemIndex()
2902 for (int i = 0; i < __pTab->GetItemCount(); i++)
2904 if (__editItemIndex == i)
2909 if ((GetItemAt(i)->GetItemBounds().x + (__itemWidth / 2.0f)) <= __itemWidth)
2911 __firstLoadedItemIndex = i;
2918 _TabPresenter::SetLastLoadedItemIndex()
2920 for (int i = 0; i < __pTab->GetItemCount(); i++)
2922 int X = GetItemAt(i)->GetItemBounds().x;
2924 if (__editItemIndex == i)
2929 if ((X + (__itemWidth / 2.0f)) < __width)
2931 __lastLoadedItemIndex = i;
2938 _TabPresenter::OnFontChanged(Font* pFont)
2945 _TabPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2947 style = FONT_STYLE_BOLD;
2948 GET_SHAPE_CONFIG(TAB::FONT_SIZE_01, __pTab->GetOrientation(), size);
2953 _TabPresenter::OnBoundsChanged()
2955 FloatRectangle bounds = __pTab->GetBoundsF();
2957 if (bounds.width <= __tabMinimumSize)
2959 bounds.width = __tabMinimumSize;
2962 __pTab->SetBounds(bounds);
2963 SetRecalculateItemBounds(true);
2969 //_TabPresenter::SetOpacityVisualElement(float xPosition)
2971 // Canvas * pCanvas = null;
2972 // float bounceWidth = (__itemWidth / 2.0f);
2974 // if (__pScrollingEffectVe == null)
2976 // __pScrollingEffectVe = new (std::nothrow) _VisualElement();
2977 // SysTryReturnVoidResult(NID_UI_CTRL, __pScrollingEffectVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2979 // __pScrollingEffectVe->Construct();
2980 // __pScrollingEffectVe->SetName(L"Opacity");
2983 // __pScrollingEffectVe->SetBounds(FloatRectangle(xPosition, 0.0f, bounceWidth, __itemHeight));
2984 // __pScrollingEffectVe->SetShowState(true);
2985 // __pScrollingEffectVe->SetImplicitAnimationEnabled(true);
2986 // __pTab->GetVisualElement()->AttachChild(*__pScrollingEffectVe);
2987 // pCanvas = __pScrollingEffectVe->GetCanvasN();
2991 // __pScrollingEffectVe->Destroy();
2992 // __pScrollingEffectVe = null;
2994 // SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2998 // Color backgroundColor(0, 0, 0, 0);
2999 // pCanvas->SetBackgroundColor(backgroundColor);
3000 // pCanvas->Clear();
3001 // FloatRectangle rect(0.0f, 0.0f, bounceWidth, __itemHeight);
3003 // DrawResourceBitmap(*pCanvas, rect, __pScrollingEffectBitmap);
3010 //_TabPresenter::StartScrollingEffect(void)
3012 // float __startOpacity = 0.0f;
3013 // float __endOpacity = 1.0f;
3015 // VisualElementPropertyAnimation* pAnimation = new (std::nothrow) VisualElementPropertyAnimation();
3016 // SysTryReturnVoidResult(NID_UI_CTRL, pAnimation, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3018 // pAnimation->SetPropertyName(L"opacity");
3019 // pAnimation->SetStartValue(Variant(__startOpacity));
3020 // pAnimation->SetEndValue(Variant(__endOpacity));
3021 // pAnimation->SetDuration(OVERSCROLL_ANIMATION_DURATION);
3022 // pAnimation->SetVisualElementAnimationStatusEventListener(this);
3024 // String animationName3(L"opacity");
3025 // __pScrollingEffectVe->AddAnimation(animationName3, *pAnimation);
3027 // delete pAnimation;
3028 // __isScrollEffectStarted = true;
3034 _TabPresenter::OnChangeLayout(_ControlOrientation orientation)
3036 __isEditMode = false;
3037 __isTimerCanceled = true;
3038 __isRightScrollable = false;
3039 __isLeftScrollable = false;
3041 // if (__pScrollingEffectVe)
3043 // __pScrollingEffectVe->RemoveAllAnimations();
3044 // __pTab->GetVisualElement()->DetachChild(*__pScrollingEffectVe);
3045 // __pScrollingEffectVe->Destroy();
3046 // __pScrollingEffectVe = null;
3047 // __isScrollEffectEnded = false;
3048 // __isScrollEffectStarted = false;
3051 ResetScrollAnimationTimer();
3052 ResetReorderTimer();
3053 ResetFlickAnimationTimer();
3054 SetRecalculateItemBounds(true);
3060 _TabPresenter::MoveNext(void)
3062 __moveDistance = (__itemWidth) * (-1.0f);
3070 _TabPresenter::MovePrevious(void)
3072 __moveDistance = __itemWidth;
3080 _TabPresenter::MoveToFirst(void)
3082 SetRecalculateItemBounds(true);
3089 _TabPresenter::MoveToLast(int distance)
3091 __moveDistance = (distance - __itemWidth * (__itemMaxCount - 1)) * (-1.0f);
3099 _TabPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
3105 _TabPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
3111 _TabPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool isCompletedNormally)
3117 }}} // Tizen::Ui::Controls