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.
18 * @file FUiCtrl_ToolbarPresenter.cpp
19 * @brief This is the implementation file for the _ToolbarPresenter class.
22 #include <FBaseSysLog.h>
23 #include <FUiAnimVisualElementPropertyAnimation.h>
24 #include <FUiAnimVisualElement.h>
25 #include <FGrp_BitmapImpl.h>
26 #include <FGrp_CanvasImpl.h>
27 #include <FGrp_FontImpl.h>
28 #include <FGrp_TextCommon.h>
29 #include <FGrp_TextTextSimple.h>
30 #include "FUiAnim_VisualElementImpl.h"
31 #include "FUi_CoordinateSystemUtils.h"
32 #include "FUi_UiTouchEvent.h"
33 #include "FUi_ResourceManager.h"
34 #include "FUiCtrl_Label.h"
35 #include "FUiCtrl_ToolbarPresenter.h"
36 #include "FUiCtrl_ToolbarModel.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Runtime;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Graphics::_Text;
42 using namespace Tizen::Ui::Animations;
44 namespace Tizen { namespace Ui { namespace Controls
47 _ToolbarPresenter::_ToolbarPresenter(void)
49 , __pToolbarModel(null)
51 , __tabEditEnabled(false)
52 , __beingEdited(false)
53 , __touchInitiatedInToolbar(false)
55 , __pressedItemIndex(-1)
56 , __initialPressesItemStatus(_BUTTON_STATUS_NORMAL)
58 , __pTitleBackgroundBitmap(null)
59 , __pTitleSlideTimer(null)
60 , __pFlickAnimationTimer(null)
61 , __titleRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
62 , __descriptionRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
64 , __pTitleTextFont(null)
66 , __pDescriptionTextObject(null)
67 , __pTitleTextObject(null)
68 , __pBouncingEffectVe(null)
70 , __moveDistance(0.0f)
72 , __flickDistance(0.0f)
74 , __firstLoadedItemIndex(0)
75 , __lastLoadedItemIndex(0)
76 , __tabSlideLeft(false)
77 , __tabSlideRight(false)
78 , __portraitSize(FloatDimension(0.0f, 0.0f))
79 , __landscapeSize(FloatDimension(0.0f, 0.0f))
83 , __titlePressed(false)
84 , __titleSliding(false)
86 __currentTouchPosition = FloatPoint(0.0f, 0.0f);
89 _ToolbarPresenter::~_ToolbarPresenter(void)
93 delete __pToolbarModel;
94 __pToolbarModel = null;
99 __pToolbar->DetachChild(*__pEditItem);
104 if (__pTitleBackgroundBitmap)
106 delete __pTitleBackgroundBitmap;
107 __pTitleBackgroundBitmap = null;
110 if (__pTitleSlideTimer)
112 delete __pTitleSlideTimer;
113 __pTitleSlideTimer = null;
116 if (__pFlickAnimationTimer)
118 delete __pFlickAnimationTimer;
119 __pFlickAnimationTimer = null;
122 if (__pDescriptionTextObject)
124 delete __pDescriptionTextObject;
125 __pDescriptionTextObject = null;
128 if (__pTitleTextObject)
130 delete __pTitleTextObject;
131 __pTitleTextObject = null;
134 if (__pBouncingEffectVe)
136 __pBouncingEffectVe->RemoveAllAnimations();
137 __pBouncingEffectVe->Destroy();
138 __pBouncingEffectVe = null;
143 _ToolbarPresenter::Construct(const _Toolbar& toolbar)
145 __pToolbar = const_cast<_Toolbar*>(&toolbar);
150 __fontStyle = FONT_STYLE_BOLD;
152 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
153 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
155 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
157 width = __portraitSize.width;
158 height = __portraitSize.height;
162 width = __landscapeSize.width;
163 height = __landscapeSize.height;
166 __flickAnimation.SetSizeInformation(width, height, DEVICE_SIZE_HORIZONTAL, DEVICE_SIZE_VERTICAL);
167 __flickAnimation.SetSensitivity(FLICK_ANIMATION_FPS_TAB, FLICK_ANIMATION_SENSITIVITY_TAB);
168 __flickAnimation.SetDirection(FD_HORIZONTAL);
174 _ToolbarPresenter::Install(void)
176 _ToolbarModel* pModel = new (std::nothrow) _ToolbarModel();
180 result r = pModel->Construct();
186 _ToolbarPresenter::Draw(void)
188 result r = E_SUCCESS;
190 ToolbarStyle style = __pToolbar->GetStyle();
196 Canvas* pCanvas = __pToolbar->GetCanvasN();
200 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
205 float fontSize = 0.0f;
207 if (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
209 if (__pTitleBackgroundBitmap)
211 delete __pTitleBackgroundBitmap;
212 __pTitleBackgroundBitmap = null;
215 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
217 GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize);
219 if (!__titleText.IsEmpty())
221 __fontSize = fontSize;
223 __pTitleTextFont = __pToolbar->GetFallbackFont();
225 SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
227 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
230 else if (style == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L""
231 && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED)
233 GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_DESCRIPTION, __pToolbar->GetOrientation(), __titleRect.y);
234 __titleRect.height = _FontImpl::GetInstance(*__pTitleTextFont)->GetLeadingF();
235 GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize);
237 DrawDescriptionText();
239 if(!__titleText.IsEmpty())
241 __fontSize = fontSize;
243 __pTitleTextFont = __pToolbar->GetFallbackFont();
245 SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
247 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
251 __pTitleBackgroundBitmap = new (std::nothrow) Bitmap();
252 __pTitleBackgroundBitmap->Construct(*pCanvas, __titleRect);
254 DrawTitleText(pCanvas);
261 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE
262 || style == TOOLBAR_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
263 && __pToolbar->GetItemCount() > 0 && __pToolbarModel->GetSelectedItemIndex() == -1)
265 int firstEnabledItemIndex = __pToolbar->GetFirstEnabledItemIndex();
267 if(firstEnabledItemIndex != -1)
269 __pToolbar->SetItemSelected(firstEnabledItemIndex, true, false);
273 __initialDraw = false;
282 _ToolbarPresenter::DrawDivider(void)
284 ToolbarStyle style = __pToolbar->GetStyle();
286 if (style == TOOLBAR_SOFTKEY)
291 float buttonItemGap = 0.0f;
292 float dividerBaseHeight = 0.0f;
293 float dividerHeight = 0.0f;
294 float dividerTopMargin = 0.0f;
296 int itemCount = __pToolbar->GetItemCount();
298 GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), buttonItemGap);
300 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
302 GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, __pToolbar->GetOrientation(), dividerBaseHeight);
303 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), dividerTopMargin);
307 GET_SHAPE_CONFIG(HEADER::HEIGHT, __pToolbar->GetOrientation(), dividerBaseHeight);
310 if (style == TOOLBAR_TAB_LARGE)
312 GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
316 GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
319 FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height);
321 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
323 if (bounds.width > __portraitSize.width)
325 bounds.width = __portraitSize.width;
330 if (bounds.width > __landscapeSize.width)
332 bounds.width = __landscapeSize.width;
336 Canvas * pCanvas = null;
337 int Z_ORDER_GROUP_CONTROL = 2001;
339 if (__pBouncingEffectVe == null)
341 __pBouncingEffectVe = new (std::nothrow) VisualElement();
342 SysTryReturnVoidResult(NID_UI_CTRL, __pBouncingEffectVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
344 __pBouncingEffectVe->Construct();
345 __pBouncingEffectVe->SetName(L"BouncingEffect");
348 __pBouncingEffectVe->SetBounds(FloatRectangle(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height));
349 __pBouncingEffectVe->SetShowState(true);
350 __pBouncingEffectVe->SetImplicitAnimationEnabled(false);
352 _VisualElementImpl::GetInstance(*__pBouncingEffectVe)->SetZOrderGroup(Z_ORDER_GROUP_CONTROL + 1);
353 __pToolbar->GetVisualElement()->AttachChild(*__pBouncingEffectVe);
355 pCanvas = __pBouncingEffectVe->GetCanvasN();
359 __pBouncingEffectVe->Destroy();
360 __pBouncingEffectVe = null;
362 SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
367 Color backgroundColor(0, 0, 0, 0);
368 pCanvas->SetBackgroundColor(backgroundColor);
371 if (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
373 if (__pToolbar->GetButton(RIGHT_BUTTON))
375 if (__pToolbar->GetButton(LEFT_BUTTON))
377 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
378 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
380 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
381 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
382 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
386 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
387 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
392 if (__pToolbar->GetButton(LEFT_BUTTON))
394 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
395 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
399 else if (style == TOOLBAR_SEGMENTED || style == TOOLBAR_TEXT || style == TOOLBAR_ICON || style == TOOLBAR_ICON_TEXT || style == TOOLBAR_COMMAND)
401 if (__pToolbar->GetButton(RIGHT_BUTTON))
403 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
404 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
407 if (__pToolbar->GetButton(LEFT_BUTTON))
409 DrawDividerLine(FloatPoint(__pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width,
410 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
420 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
422 for (int i = 0; i < itemCount - 1 ; i++)
424 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
425 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
430 for (int i = 0; i < itemCount - 1 ; i++)
432 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
433 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
444 _ToolbarPresenter::DrawBackground(void)
446 Canvas* pCanvas = __pToolbar->GetCanvasN();
450 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
455 ToolbarStyle style = __pToolbar->GetStyle();
457 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
460 if (style == TOOLBAR_SOFTKEY)
467 Bitmap* pReplacementColorBackgroundBitmap = null;
468 Bitmap* pBackgroundBitmap = null;
469 //Bitmap* pBackgroundEffectBitmap = null;
471 FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height);
473 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
474 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
476 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
478 if (bounds.width > __portraitSize.width)
480 bounds.width = __portraitSize.width;
485 if (bounds.width > __landscapeSize.width)
487 bounds.width = __landscapeSize.width;
491 pBackgroundBitmap = __pToolbar->GetBackgroundBitmap();
492 //pBackgroundEffectBitmap = __pToolbar->GetBackgroundEffectBitmap();
494 pReplacementColorBackgroundBitmap =
495 _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
497 if (__pToolbar->IsUserBackgroundBitmap())
499 if (pBackgroundBitmap)
501 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap))
503 pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap);
507 pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundBitmap->GetWidthF(), pBackgroundBitmap->GetHeightF()));
512 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
517 if (pReplacementColorBackgroundBitmap)
519 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
521 pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap);
525 pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pReplacementColorBackgroundBitmap->GetWidthF(), pReplacementColorBackgroundBitmap->GetHeightF()));
530 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
533 //if (pBackgroundEffectBitmap)
535 // if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundEffectBitmap))
537 // pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap);
541 // pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundEffectBitmap->GetWidthF(), pBackgroundEffectBitmap->GetHeightF()));
546 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
548 Bitmap* pSubTitleEffectBitmap = null;
549 Color subTitleEffectColor;
550 float topMargin = 0.0f;
552 GET_BITMAP_CONFIG_N(HEADER::SUB_TITLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pSubTitleEffectBitmap);
553 GET_COLOR_CONFIG(HEADER::SUB_TITLE_EFFECT_NORMAL, subTitleEffectColor);
554 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), topMargin);
556 FloatRectangle subTitleEffectBounds(0.0f, topMargin, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height - topMargin);
558 Bitmap* pReColorSubTitleEffectBitmap = null;
560 pReColorSubTitleEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSubTitleEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), subTitleEffectColor);
562 if (pReColorSubTitleEffectBitmap)
564 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorSubTitleEffectBitmap))
566 pCanvas->DrawNinePatchedBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap);
570 pCanvas->DrawBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap, FloatRectangle(0.0f, 0.0f, pReColorSubTitleEffectBitmap->GetWidthF(), pReColorSubTitleEffectBitmap->GetHeightF()));
574 delete pReColorSubTitleEffectBitmap;
578 delete pReplacementColorBackgroundBitmap;
584 _ToolbarPresenter::DrawDescriptionText(void)
586 result r = E_SUCCESS;
588 float textAreaHeight = 0.0f;
589 float fontSize = 0.0f;
590 float titleIconWidth = 0.0f;
592 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_HEIGHT, __pToolbar->GetOrientation(), textAreaHeight);
593 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
594 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), titleIconWidth);
596 __fontSize = fontSize;
598 __pTextFont = __pToolbar->GetFallbackFont();
600 SysTryReturnVoidResult(NID_UI_CTRL, __pTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
602 if (__pToolbar->GetTitleIcon() != null)
604 __descriptionRect.x = __toolbarUsableArea.x + titleIconWidth + __toolbarUsableArea.x;
608 __descriptionRect.x = __toolbarUsableArea.x;
611 __descriptionRect.y = __titleRect.y + __titleRect.height;
613 if(__titleText.IsEmpty())
615 __descriptionRect.width = __toolbarUsableArea.width;
619 __descriptionRect.width = __titleRect.width;
622 __descriptionRect.height = textAreaHeight;
624 Canvas* pCanvas = __pToolbar->GetCanvasN();
626 if (__pDescriptionTextObject)
628 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
629 __pDescriptionTextObject->SetForegroundColor(__pToolbar->GetDescriptionTextColor(), 0, __pDescriptionTextObject->GetTextLength());
630 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
631 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
632 __pDescriptionTextObject->SetBounds(__descriptionRect);
633 __pDescriptionTextObject->Compose();
634 __pDescriptionTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
643 _ToolbarPresenter::DrawEditItem(const FloatPoint& point)
645 if (__pEditItem == null )
650 FloatPoint anchor = FloatPoint(0.0f, 0.0f);
652 anchor.x = point.x - (__pEditItem->GetSizeF().width / 2);
653 anchor.y = point.y - (__pEditItem->GetSizeF().height / 2);
655 __pEditItem->SetPosition(anchor);
657 __pToolbar->Invalidate(true);
663 _ToolbarPresenter::DrawDividerLine(const FloatPoint& point, Canvas* pCanvas)
665 float dividerWidth = 0.0f;
666 float dividerHeight = 0.0f;
667 Color dividerLeftColor;
668 //Color dividerRightColor;
670 ToolbarStyle style = __pToolbar->GetStyle();
672 GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), dividerWidth);
674 if (style == TOOLBAR_TAB_LARGE)
676 GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
680 GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
683 if (__pToolbar->IsHeader() == true)
685 if (!__pToolbar->IsTransparent())
687 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
688 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
692 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
693 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
698 if (!__pToolbar->IsTransparent())
700 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
701 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
705 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
706 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
710 pCanvas->SetForegroundColor(dividerLeftColor);
711 pCanvas->SetLineWidth(dividerWidth);
713 pCanvas->DrawLine(FloatPoint(point.x, point.y), FloatPoint(point.x, point.y + dividerHeight));
719 _ToolbarPresenter::DrawItems(void)
721 result r = E_SUCCESS;
723 Canvas* pCanvas = __pToolbar->GetCanvasN();
725 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_INVALID_STATE, "[E_INVALID_STATE] System error occurred.");
727 ToolbarStyle style = __pToolbar->GetStyle();
729 FloatRectangle usableArea = __toolbarUsableArea;
731 Bitmap* pTitleIcon = __pToolbar->GetTitleIcon();
733 _Label* pTitleBadgeIcon = __pToolbar->GetTitleBadgeIcon();
735 float iconWidth = 0.0f;
736 float titleDisplayHeight = 0.0f;
737 float leftMargin = 0.0f;
738 float headerTopMargin = 0.0f;
739 float processingAnimationIconSize = 0.0f;
740 float processingAnimationIconGap = 0.0f;
741 float titleCharacterCount = 0.0f;
742 float titleBadgeIconGap = 0.0f;
743 float titleBadgeIconTopMargin = 0.0f;
744 float fontSize = 0.0f;
745 FloatDimension titleTextDimension(0.0f, 0.0f);
746 float totalWidth = 0.0f;
747 float titleHeight = 0.0f;
749 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin);
750 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, __pToolbar->GetOrientation(), processingAnimationIconSize);
751 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_GAP, __pToolbar->GetOrientation(), processingAnimationIconGap);
753 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_ICON_GAP, __pToolbar->GetOrientation(), titleBadgeIconGap);
754 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_TOP_MARGIN, __pToolbar->GetOrientation(), titleBadgeIconTopMargin);
756 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
758 GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), headerTopMargin);
759 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), titleDisplayHeight);
763 GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, __pToolbar->GetOrientation(), headerTopMargin);
764 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT, __pToolbar->GetOrientation(), titleDisplayHeight);
767 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), iconWidth);
769 if (!__titleText.IsEmpty())
771 titleCharacterCount = __titleText.GetLength(); // alphabet count
773 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
775 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize);
777 else if (style == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L""
778 && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED)
780 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize);
784 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
794 __fontSize = fontSize;
796 __pTitleTextFont = __pToolbar->GetFallbackFont();
798 SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
800 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
802 __pTitleTextFont->GetTextExtent(__titleText, titleCharacterCount, titleTextDimension);
804 totalWidth = titleTextDimension.width; // pixel
805 titleHeight = titleTextDimension.height; // pixel
807 __titleRect.height = _FontImpl::GetInstance(*__pTitleTextFont)->GetLeadingF();
811 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
816 totalWidth += (pTitleIcon->GetWidthF() + usableArea.x);
822 totalWidth += pTitleBadgeIcon->GetBoundsF().width + titleBadgeIconGap;
824 else if ((__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE)) != ANIMATION_STOPPED)
826 totalWidth += processingAnimationIconSize + processingAnimationIconGap;
829 if (totalWidth > usableArea.width)
831 __titleRect.width = titleTextDimension.width - (totalWidth - usableArea.width);
835 pCanvas->DrawBitmap(FloatPoint(usableArea.x, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
837 __titleRect.x = usableArea.x + pTitleIcon->GetWidthF() + usableArea.x;
838 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
840 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
842 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
843 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + processingAnimationIconGap,
844 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
849 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + titleBadgeIconGap,
850 titleBadgeIconTopMargin));
855 __titleRect.x = usableArea.x;
856 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
858 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
860 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
861 usableArea.x + __titleRect.width + processingAnimationIconGap,
862 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
867 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + __titleRect.width + titleBadgeIconGap, titleBadgeIconTopMargin));
873 __titleRect.width = usableArea.width;
877 __titleRect.x = leftMargin + pTitleIcon->GetWidthF() + leftMargin;
878 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
880 if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_CENTER)
882 leftMargin = (__titleRect.width - titleTextDimension.width) / 2 - leftMargin;
884 else if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_RIGHT)
886 leftMargin = __titleRect.width - titleTextDimension.width - leftMargin * 3;
889 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
891 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
893 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
894 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + processingAnimationIconGap,
895 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
900 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + titleBadgeIconGap,
901 titleBadgeIconTopMargin));
904 __titleRect.width -= (pTitleIcon->GetWidthF() + usableArea.x);
908 __titleRect.x = leftMargin;
909 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
911 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
913 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
914 leftMargin + titleTextDimension.width + processingAnimationIconGap,
915 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
920 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + titleTextDimension.width + titleBadgeIconGap, titleBadgeIconTopMargin));
927 if (pTitleIcon && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
929 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
931 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
933 leftMargin = (leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize)) / 2;
935 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
937 leftMargin = leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize);
940 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
942 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
943 leftMargin + processingAnimationIconGap + processingAnimationIconSize,
944 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
948 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + processingAnimationIconGap + titleBadgeIconGap, titleBadgeIconTopMargin));
953 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
955 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
957 leftMargin = usableArea.width / 2;
959 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
961 leftMargin = usableArea.width - pTitleIcon->GetWidthF();
964 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
968 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
970 leftMargin = (usableArea.width - (processingAnimationIconGap + processingAnimationIconSize))/ 2;
972 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
974 leftMargin = usableArea.width - (processingAnimationIconGap + processingAnimationIconSize);
977 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
978 leftMargin, headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
982 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin, titleBadgeIconTopMargin));
993 _ToolbarPresenter::DrawTitleText(Canvas* pCanvas)
995 TimerForTitleSlideInit();
997 if (__titleText.IsEmpty())
1002 __pTitleTextObject->SetForegroundColor(__pToolbar->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
1003 __pTitleTextObject->SetBounds(__titleRect);
1004 //__pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1005 __pTitleTextObject->Compose();
1007 if (__pTitleTextObject->IsActionOn() == true)
1009 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1011 DrawTitleTextDimBitmap();
1013 TimerForTitleSlideStart();
1017 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1024 _ToolbarPresenter::GetSelectedItemIndex(void) const
1026 return __pToolbarModel->GetSelectedItemIndex();
1030 _ToolbarPresenter::IsInitialDraw(void) const
1032 return __initialDraw;
1036 _ToolbarPresenter::IsTabEditModeEnabled(void) const
1038 return __tabEditEnabled;
1042 _ToolbarPresenter::SetDescriptionText(const String& description)
1044 result r = E_SUCCESS;
1046 float length = description.GetLength();
1047 float fontSize = 0.0f;
1049 wchar_t* tempString = const_cast<wchar_t*>(description.GetPointer());
1052 if (__pDescriptionTextObject != null)
1054 delete __pDescriptionTextObject;
1055 __pDescriptionTextObject = null;
1058 __pDescriptionTextObject = new (std::nothrow) TextObject();
1060 if (__pDescriptionTextObject == null)
1062 return E_OUT_OF_MEMORY;
1064 __pDescriptionTextObject->Construct();
1065 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1066 __pDescriptionTextObject->AppendElement(*pSimpleText);
1067 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1068 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1070 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1072 __fontSize = fontSize;
1074 __pTextFont = __pToolbar->GetFallbackFont();
1075 r = GetLastResult();
1076 SysTryReturn(NID_UI_CTRL, __pTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1078 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
1084 _ToolbarPresenter::SetItemSelected(int itemIndex, bool adjust)
1088 ToolbarStyle style = __pToolbar->GetStyle();
1090 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1092 if (itemIndex <= __pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX)
1094 SetItemFit(itemIndex);
1098 SetItemFit(__pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX);
1103 return __pToolbarModel->SetSelectedItemIndex(itemIndex);
1107 _ToolbarPresenter::SetInitialDrawState(bool state)
1109 //DrawBackground(); // remove since 2.1
1110 __initialDraw = state;
1112 __titlePressed = false;
1113 __titleSliding = false;
1114 __tabEditEnabled = false;
1116 __firstLoadedItemIndex = 0;
1117 __lastLoadedItemIndex = 0;
1123 _ToolbarPresenter::SetTabEditModeEnabled(bool enable)
1125 __tabEditEnabled = enable;
1131 _ToolbarPresenter::SetTitleText(const String& title, HorizontalAlignment alignment)
1133 result r = E_SUCCESS;
1135 float length = title.GetLength();
1137 __titleText = String(title);
1138 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
1141 if (__pTitleTextObject != null)
1143 delete __pTitleTextObject;
1144 __pTitleTextObject = null;
1147 __pTitleTextObject = new (std::nothrow) TextObject();
1149 if (__pTitleTextObject == null)
1151 return E_OUT_OF_MEMORY;
1153 __pTitleTextObject->Construct();
1154 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1155 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1156 __pTitleTextObject->AppendElement(*pSimpleText);
1158 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1160 __titleSliding = false;
1164 case ALIGNMENT_LEFT:
1165 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1167 case ALIGNMENT_CENTER:
1168 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1170 case ALIGNMENT_RIGHT:
1171 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT);
1174 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1178 float fontSize = 0.0f;
1180 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1182 __fontSize = fontSize;
1184 __pTitleTextFont = __pToolbar->GetFallbackFont();
1185 r = GetLastResult();
1186 SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1188 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
1190 //__pTitleTextObject->Compose();
1196 _ToolbarPresenter::SetUsableAreaBounds(const FloatRectangle& rect)
1198 __toolbarUsableArea = rect;
1204 _ToolbarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1206 ResetFlickAnimationTimer();
1208 SetFirstLoadedItemIndex();
1209 SetLastLoadedItemIndex();
1211 __touchInitiatedInToolbar = true;
1213 __currentTouchPosition = touchinfo.GetCurrentPosition();
1215 ToolbarStyle style = __pToolbar->GetStyle();
1217 if (__titleRect.Contains(__currentTouchPosition)
1218 && (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE))
1220 __titlePressed = true;
1224 __titlePressed = false;
1227 __pressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1229 if (__pressedItemIndex == -1)
1231 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1235 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1237 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1239 if (pLabel == pTempBadgeIcon)
1241 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1245 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1247 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1249 if (pLabel == pTempBadgeIcon)
1251 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1258 _Button* pPressedButton = __pToolbar->GetItem(__pressedItemIndex);
1260 __initialPressesItemStatus = pPressedButton->GetButtonStatus();
1262 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1267 pPressedButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1270 __pToolbar->Invalidate(true);
1276 _ToolbarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1278 if (!__touchInitiatedInToolbar)
1283 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1285 if (__titlePressed && __titleRect.Contains(touchPoint))
1287 if (__titleSliding == true)
1289 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1290 __pTitleTextObject->Compose();
1292 __titleSliding = false;
1296 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1297 __pTitleTextObject->Compose();
1299 __titleSliding = true;
1301 TimerForTitleSlideStart();
1305 SetFirstLoadedItemIndex();
1306 SetLastLoadedItemIndex();
1308 ToolbarStyle style = __pToolbar->GetStyle();
1310 __touchInitiatedInToolbar = false;
1312 int releasedItemIndex = __pToolbar->GetItemIndexFromPosition(touchPoint);
1313 float tabLeftMargin = 0.0f;
1315 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
1317 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1319 __beingEdited = false;
1321 if (releasedItemIndex == -1)
1325 __pToolbar->DetachChild(*__pEditItem);
1331 if (__pressedItemIndex != -1)
1333 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus);
1338 __pToolbar->MoveItem(__editItemIndex, releasedItemIndex);
1340 AdjustItemPositionX(-__pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x + tabLeftMargin); // move auto focus
1344 __pToolbar->DetachChild(*__pEditItem);
1353 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE)
1354 && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1356 if (__pressedItemIndex != -1)
1358 if (releasedItemIndex == __pressedItemIndex)
1360 if (__initialPressesItemStatus != _BUTTON_STATUS_DISABLED && __tabMoved != true)
1362 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1366 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1371 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1377 if (__pressedItemIndex != -1 && (releasedItemIndex != __pressedItemIndex))
1379 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1383 if (__pressedItemIndex != -1 && __initialPressesItemStatus != _BUTTON_STATUS_DISABLED)
1385 if (style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE
1386 || style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_SEGMENTED || style == TOOLBAR_TAB_LARGE)
1388 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1392 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetItem(releasedItemIndex));
1393 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1394 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1399 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1403 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1405 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1407 if (pLabel == pTempBadgeIcon)
1409 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1411 if (buttonItemBounds.Contains(touchPoint))
1413 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(LEFT_BUTTON));
1414 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1417 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1421 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1423 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1425 if (pLabel == pTempBadgeIcon)
1427 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1429 if (buttonItemBounds.Contains(touchPoint))
1431 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(RIGHT_BUTTON));
1432 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1435 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1441 __pToolbar->Invalidate(true);
1450 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1451 int itemCount = __pToolbar->GetItemCount();
1453 for (int j = 0; j < itemCount; j++)
1455 if (__pToolbar->GetItem(j) != null && __pToolbar->GetItem(j)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1457 __pToolbar->GetItem(j)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1462 __pToolbar->Invalidate(true);
1468 _ToolbarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1470 if (!__touchInitiatedInToolbar)
1475 SetFirstLoadedItemIndex();
1476 SetLastLoadedItemIndex();
1478 ToolbarStyle style = __pToolbar->GetStyle();
1479 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1481 if (__pressedItemIndex == -1)
1483 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1487 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1489 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1491 if (pLabel == pTempBadgeIcon)
1493 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1495 if (buttonItemBounds.Contains(touchPoint))
1497 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1501 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1506 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1508 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1510 if (pLabel == pTempBadgeIcon)
1512 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1514 if (buttonItemBounds.Contains(touchPoint))
1516 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1520 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1526 __pToolbar->Invalidate(true);
1531 _Button* pCurrentButton = __pToolbar->GetItem(__pressedItemIndex);
1533 if (pCurrentButton == null)
1538 FloatRectangle itemBounds = pCurrentButton->GetBoundsF();
1540 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1542 if (itemBounds.Contains(touchPoint))
1548 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1550 DrawEditItem(touchinfo.GetCurrentPosition());
1556 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1560 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1565 if (itemBounds.Contains(touchPoint))
1567 pCurrentButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1571 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1575 pCurrentButton->Invalidate(false);
1580 float distance = (touchinfo.GetCurrentPosition()).x - __currentTouchPosition.x;
1581 float sideMargin = 0.0f;
1583 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), sideMargin);
1585 FloatRectangle clientBounds = __pToolbar->GetBoundsF();
1587 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1588 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
1590 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
1592 if (clientBounds.width > __portraitSize.width)
1594 clientBounds.width = __portraitSize.width;
1599 if (clientBounds.width > __landscapeSize.width)
1601 clientBounds.width = __landscapeSize.width;
1605 __currentTouchPosition = touchinfo.GetCurrentPosition();
1607 _Button* pItem = null;
1608 FloatRectangle itemBounds;
1609 int itemCount = __pToolbar->GetItemCount();
1611 if (distance > 0) // right move
1613 pItem = __pToolbar->GetItem(0);
1619 itemBounds = pItem->GetBoundsF();
1621 if (itemBounds.x + distance >= sideMargin && !__beingEdited)
1623 distance = sideMargin - itemBounds.x;
1626 else if (distance < 0)
1628 pItem = __pToolbar->GetItem(itemCount - 1);
1635 itemBounds = pItem->GetBoundsF();
1637 if (itemBounds.x + itemBounds.width + distance <= clientBounds.width - sideMargin && !__beingEdited)
1639 distance = (clientBounds.width - sideMargin) - (itemBounds.x + itemBounds.width);
1644 float tabLeftMargin = 0.0f;
1646 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
1648 if (distance > 0) // right move
1650 __tabSlideRight = false;
1652 if (__pToolbar->GetItem(__lastLoadedItemIndex - 1)->GetBoundsF().x <= __pEditItem->GetBoundsF().x)
1654 __tabSlideLeft = true;
1657 if (__tabSlideLeft && __pToolbar->GetItem(itemCount-1)->GetBoundsF().x + __pToolbar->GetItem(itemCount-1)->GetBoundsF().width > clientBounds.width - tabLeftMargin)
1659 AdjustItemPositionX(-distance * 5); // move auto focus
1662 else if (distance < 0)
1664 __tabSlideLeft = false;
1666 if (__pToolbar->GetItem(__firstLoadedItemIndex + 1)->GetBoundsF().x >= __pEditItem->GetBoundsF().x)
1668 __tabSlideRight = true;
1671 if (__tabSlideRight && __pToolbar->GetItem(0)->GetBoundsF().x < tabLeftMargin)
1673 AdjustItemPositionX(-distance * 5); // move auto focus
1679 AdjustItemPositionX(distance);
1689 _ToolbarPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1691 __touchInitiatedInToolbar = false;
1692 __beingEdited = false;
1694 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1695 int itemCount = __pToolbar->GetItemCount();
1697 for (int i = 0; i < itemCount; i++)
1699 if (__pToolbar->GetItem(i) != null && __pToolbar->GetItem(i)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1701 __pToolbar->GetItem(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1707 __pToolbar->DetachChild(*__pEditItem);
1714 __pToolbar->Invalidate(true);
1720 _ToolbarPresenter::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation)
1722 ResetFlickAnimationTimer();
1728 _ToolbarPresenter::OnLongPressGestureDetected(void)
1730 if (__pToolbar->IsTabEditModeEnabled() == true)
1732 int longPressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1734 if (longPressedItemIndex == -1)
1739 _Button* pButton = null;
1740 pButton = __pToolbar->GetItem(longPressedItemIndex);
1741 SysTryReturn(NID_UI_CTRL, pButton, true, E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a button");
1743 if (pButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED)
1748 __editItemIndex = longPressedItemIndex;
1749 __beingEdited = true;
1751 pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1753 FloatRectangle itemBounds = pButton->GetBoundsF();
1757 __pToolbar->DetachChild(*__pEditItem);
1763 __pEditItem = _Label::CreateLabelN();
1764 SysTryCatch(NID_UI_CTRL, __pEditItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1766 Canvas* pCanvas = pButton->GetCanvasN();
1767 SysTryCatch(NID_UI_CTRL, pCanvas, , E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a Canvas.");
1769 Bitmap* pEditItemBitmap = new (std::nothrow) Bitmap();
1770 result r = pEditItemBitmap->Construct(*pCanvas, FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height));
1774 delete pEditItemBitmap;
1775 pEditItemBitmap = null;
1782 __pEditItem->SetBounds(itemBounds);
1783 __pEditItem->SetBackgroundBitmap(*pEditItemBitmap);
1786 delete pEditItemBitmap;
1788 __pToolbar->AttachChild(*__pEditItem);
1789 __pToolbar->SetChildAlwaysOnTop(*__pEditItem);
1807 _ToolbarPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1809 ToolbarStyle style = __pToolbar->GetStyle();
1811 if (!(style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) || __pToolbar->GetItemCount() <= SEGMENTED_ITEM_MAX || __beingEdited == true || __tabMoved == false)
1816 if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT)
1821 float distanceX = 0.0f;
1822 float distanceY = 0.0f;
1823 float xPosition = 0.0f;
1824 float itemsBeyondScreen = 0.0f;
1826 gesture.GetDistance(distanceX, distanceY);
1827 SetFirstLoadedItemIndex();
1828 SetLastLoadedItemIndex();
1829 int itemCount = __pToolbar->GetItemCount();
1830 float itemWidth = __pToolbar->GetItem(0)->GetBoundsF().width;
1832 if (distanceX < 0) //left
1834 itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex;
1835 xPosition = __pToolbar->GetItem(__lastLoadedItemIndex)->GetBoundsF().x;
1836 if (xPosition < (3 * itemWidth))
1838 __flickDistance = xPosition - (4 * itemWidth);
1843 itemsBeyondScreen = __firstLoadedItemIndex;
1844 xPosition = __pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x;
1847 __flickDistance = -xPosition;
1852 int itemMaxCount = 4;
1854 if (itemsBeyondScreen >= (itemMaxCount - 1))
1856 __flickDistance = (3 * itemWidth);
1860 __flickDistance = (itemsBeyondScreen * itemWidth);
1863 if (distanceX < 0) //Left flick
1865 __flickMove = 0.006f;
1868 else if (distanceX > 0) //Right flick
1870 __flickMove = 0.006f;
1871 __flickDistance = -(__flickDistance);
1877 __flickDistance = 0.0f;
1879 __moveDistance = 0.0f;
1882 StartFlickAnimationTimer();
1888 _ToolbarPresenter::OnTimerExpired(Timer& timer)
1890 Timer* onTimer = &timer;
1892 if (onTimer == __pTitleSlideTimer)
1894 TimerForTitleSlideTimeout();
1897 if (onTimer == __pFlickAnimationTimer)
1899 StartFlickAnimation();
1906 _ToolbarPresenter::OnDrawFocus(void)
1912 _ToolbarPresenter::OnChildControlFocusMoved(const _Control& control)
1918 _ToolbarPresenter::IsChildControlFocusManage(void) const
1924 _ToolbarPresenter::OnFocusableStateChanged(bool focusalbeState)
1930 _ToolbarPresenter::OnFocusModeStateChanged(void)
1936 _ToolbarPresenter::OnFocusGained(const _Control& source)
1938 //__focusPrevStatus = __pButton->GetButtonStatus();
1939 //__pButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1940 //__pButton->Invalidate();
1946 _ToolbarPresenter::OnFocusLost(const _Control& source)
1948 //__pButton->SetButtonStatus(__focusPrevStatus);
1949 //__pButton->Invalidate();
1955 _ToolbarPresenter::TimerForTitleSlideInit(void)
1957 result r = E_SUCCESS;
1959 if (__pTitleSlideTimer != null)
1961 delete __pTitleSlideTimer;
1962 __pTitleSlideTimer = null;
1969 _ToolbarPresenter::TimerForTitleSlideStart(void)
1971 result r = E_SUCCESS;
1973 if (__pTitleSlideTimer == null)
1975 __pTitleSlideTimer = new (std::nothrow) Timer();
1976 if (__pTitleSlideTimer == null)
1978 r = E_OUT_OF_MEMORY;
1982 r = __pTitleSlideTimer->Construct(*this);
1986 delete __pTitleSlideTimer;
1991 r = __pTitleSlideTimer->Start(100);
2003 _ToolbarPresenter::TimerForTitleSlideTimeout(void)
2005 Canvas* pCanvas = __pToolbar->GetCanvasN();
2006 SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pCanvas is invalid!");
2008 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2009 pCanvas->Clear(__titleRect);
2011 if (__pTitleBackgroundBitmap)
2013 pCanvas->DrawBitmap(CoordinateSystem::AlignToDevice(__titleRect), *__pTitleBackgroundBitmap);
2016 if (__pTitleTextObject->IsChanged())
2018 DrawTitleText(pCanvas);
2021 if (__pTitleTextObject->IsActionOn() == true)
2023 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
2025 DrawTitleTextDimBitmap();
2027 if (__pTitleTextObject->GetRepeatCount() < 3)
2029 TimerForTitleSlideStart();
2034 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
2043 _ToolbarPresenter::DrawTitleTextDimBitmap(void)
2045 if (__pToolbar->IsUserBackgroundBitmap())
2050 float textDimWidth = 0.0f;
2051 float textDimHeight = 0.0f;
2053 GET_SHAPE_CONFIG(HEADER::TAB_TEXT_DIM_WIDTH, __pToolbar->GetOrientation(), textDimWidth);
2055 ToolbarStyle style = __pToolbar->GetStyle();
2057 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
2059 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), textDimHeight);
2063 if (__pToolbar->GetDescriptionText() != L"")
2065 textDimHeight = __titleRect.height;
2069 textDimHeight = __pToolbar->GetBoundsF().height;
2073 Color titleTextDimColor;
2074 GET_COLOR_CONFIG(HEADER::TITLE_TEXT_DIM_NORMAL, titleTextDimColor);
2076 Bitmap* pTitleTextDimLeftBitmap = null;
2077 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimLeftBitmap);
2079 Bitmap* pReColorTitleTextDimLeftBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimLeftBitmap,
2080 Color::GetColor(COLOR_ID_MAGENTA), titleTextDimColor);
2082 if (pReColorTitleTextDimLeftBitmap)
2084 Canvas* pCanvas = __pToolbar->GetCanvasN();
2085 FloatRectangle bounds = FloatRectangle(0.0f, 0.0f, textDimWidth, textDimHeight);
2087 if (pCanvas == null)
2089 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
2093 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimLeftBitmap))
2095 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimLeftBitmap);
2099 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimLeftBitmap,
2100 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimLeftBitmap->GetWidthF(), pReColorTitleTextDimLeftBitmap->GetHeightF()));
2103 delete pTitleTextDimLeftBitmap;
2104 delete pReColorTitleTextDimLeftBitmap;
2108 Bitmap* pTitleTextDimRightBitmap = null;
2109 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimRightBitmap);
2111 Bitmap* pReColorTitleTextDimRightBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimRightBitmap,
2112 Color::GetColor(COLOR_ID_MAGENTA), titleTextDimColor);
2114 if (pReColorTitleTextDimRightBitmap)
2116 Canvas* pCanvas = __pToolbar->GetCanvasN();
2117 FloatRectangle bounds = FloatRectangle(__titleRect.width, 0.0f, textDimWidth, textDimHeight);
2119 if (pCanvas == null)
2121 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
2125 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimRightBitmap))
2127 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimRightBitmap);
2131 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimRightBitmap,
2132 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimRightBitmap->GetWidthF(), pReColorTitleTextDimRightBitmap->GetHeightF()));
2135 delete pTitleTextDimRightBitmap;
2136 delete pReColorTitleTextDimRightBitmap;
2144 _ToolbarPresenter::AdjustItemPositionX(float distance)
2147 int itemCount = __pToolbar->GetItemCount();
2148 _Button* pItem = __pToolbar->GetItem(index);
2150 while (pItem != null)
2152 FloatRectangle bounds = pItem->GetBoundsF();
2153 bounds.x += distance;
2154 pItem->SetBounds(bounds);
2157 if (index < itemCount)
2159 pItem = __pToolbar->GetItem(index);
2171 _ToolbarPresenter::GetTitleTextBoundsF(void) const
2177 _ToolbarPresenter::GetDescriptionBoundsF(void) const
2179 return __descriptionRect;
2183 _ToolbarPresenter::_SetModel(const _ToolbarModel& toolbarModel)
2185 __pToolbarModel = const_cast<_ToolbarModel*>(&toolbarModel);
2191 _ToolbarPresenter::OnFontChanged(Font* pFont)
2193 __pTextFont = pFont;
2194 __pTitleTextFont = pFont;
2200 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, int& size)
2202 style = __fontStyle;
2203 size = _CoordinateSystemUtils::ConvertToInteger(__fontSize);
2209 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2211 style = __fontStyle;
2218 _ToolbarPresenter::OnAncestorVisibleStateChanged(const _Control& control)
2220 if (__pTitleTextObject != null)
2222 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2223 __pTitleTextObject->Compose();
2226 __titleSliding = false;
2232 _ToolbarPresenter::SetFontInfo(unsigned long style, float size)
2234 __fontStyle = style;
2241 _ToolbarPresenter::StartFlickAnimation(void)
2243 float distance = CalculateProgress(__flickMove);
2245 __moveDistance = -(__flickDistance * distance);
2246 __flickDistance = (__flickDistance + __moveDistance);
2247 __flickMove = __flickMove + 0.006;
2250 if (__flickFlag <= FLICK_ANIMATION_COUNT)
2252 StartFlickAnimationTimer();
2256 ResetFlickAnimationTimer();
2257 SetItemFit(__firstLoadedItemIndex);
2260 AdjustItemPositionX(__moveDistance);
2262 SetFirstLoadedItemIndex();
2263 SetLastLoadedItemIndex();
2271 _ToolbarPresenter::StartFlickAnimationTimer(void)
2273 result r = E_SUCCESS;
2275 if (__pFlickAnimationTimer == null)
2277 __pFlickAnimationTimer = new (std::nothrow) Timer();
2278 SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2280 r = __pFlickAnimationTimer->Construct(*this);
2281 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2285 __pFlickAnimationTimer->Cancel();
2288 r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD);
2289 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2294 ResetFlickAnimationTimer();
2299 _ToolbarPresenter::ResetFlickAnimationTimer(void)
2301 if (__pFlickAnimationTimer)
2303 delete __pFlickAnimationTimer;
2304 __pFlickAnimationTimer = null;
2307 __moveDistance = 0.0f;
2313 _ToolbarPresenter::SetFirstLoadedItemIndex(void)
2315 int itemCount = __pToolbar->GetItemCount();
2317 for (int i = 0; i < itemCount; i++)
2319 if (__pToolbar->GetItem(i)->GetBoundsF().x + (__pToolbar->GetItem(i)->GetBoundsF().width / 2) <= __pToolbar->GetItem(i)->GetBoundsF().width)
2321 __firstLoadedItemIndex = i;
2329 _ToolbarPresenter::GetFirstLoadedItemIndex(void)
2331 return __firstLoadedItemIndex;
2335 _ToolbarPresenter::SetLastLoadedItemIndex(void)
2338 int itemCount = __pToolbar->GetItemCount();
2340 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
2342 width = __portraitSize.width;
2346 width = __landscapeSize.width;
2349 for (int i = 0; i < itemCount; i++)
2351 float X = __pToolbar->GetItem(i)->GetBoundsF().x;
2353 if ((X + (__pToolbar->GetItem(i)->GetBoundsF().width / 2)) < width)
2355 __lastLoadedItemIndex = i;
2363 _ToolbarPresenter::CalculateProgress(float timeProgress) const
2365 const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}};
2366 float loc_5 = timeProgress / 1;
2367 int loc_6 = 3; //Length of the segments array
2368 int loc_9 = (int)floor(loc_6 * loc_5);
2375 float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
2378 for (int i = 0; i < 3; i++)
2380 loc_8[i] = segments[loc_9][i];
2383 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])));
2389 _ToolbarPresenter::SetItemFit(int index)
2396 FloatPoint pt(0.0f, 0.0f);
2397 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2399 float fitDistance = 0.0f;
2400 float tabLeftMargin = 0.0f;
2401 int itemCount = __pToolbar->GetItemCount();
2403 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
2405 _Button* pItem = __pToolbar->GetItem(index);
2406 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2408 bounds = pItem->GetBoundsF();
2410 fitDistance = -bounds.x + tabLeftMargin;
2412 for (int i = 0; i < itemCount; i++)
2414 pItem = __pToolbar->GetItem(i);
2415 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2417 bounds = pItem->GetBoundsF();
2418 bounds.x = bounds.x + fitDistance;
2419 pItem->SetBounds(bounds);
2422 SetFirstLoadedItemIndex();
2423 SetLastLoadedItemIndex();
2431 _ToolbarPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2437 _ToolbarPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2443 _ToolbarPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2448 }}} // Tizen::Ui::Controls