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)
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 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
380 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
381 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
382 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
386 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
387 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
392 if (__pToolbar->GetButton(LEFT_BUTTON))
394 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
395 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
399 else if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
401 if (__pToolbar->GetButton(RIGHT_BUTTON))
403 if (__pToolbar->GetButton(LEFT_BUTTON))
405 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
406 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
408 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
409 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
410 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
414 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
415 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
420 if (__pToolbar->GetButton(LEFT_BUTTON))
422 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap,
423 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
427 else if (style == TOOLBAR_SEGMENTED || style == TOOLBAR_TEXT || style == TOOLBAR_ICON || style == TOOLBAR_ICON_TEXT || style == TOOLBAR_COMMAND)
429 if (__pToolbar->GetButton(RIGHT_BUTTON))
431 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap,
432 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
435 if (__pToolbar->GetButton(LEFT_BUTTON))
437 DrawDividerLine(FloatPoint(__pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width,
438 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
448 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
450 for (int i = 0; i < itemCount - 1 ; i++)
452 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
453 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
458 for (int i = 0; i < itemCount - 1 ; i++)
460 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
461 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
472 _ToolbarPresenter::DrawBackground(void)
474 Canvas* pCanvas = __pToolbar->GetCanvasN();
478 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
483 ToolbarStyle style = __pToolbar->GetStyle();
485 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
488 if (style == TOOLBAR_SOFTKEY)
495 Bitmap* pReplacementColorBackgroundBitmap = null;
496 Bitmap* pBackgroundBitmap = null;
497 //Bitmap* pBackgroundEffectBitmap = null;
499 FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height);
501 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
502 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
504 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
506 if (bounds.width > __portraitSize.width)
508 bounds.width = __portraitSize.width;
513 if (bounds.width > __landscapeSize.width)
515 bounds.width = __landscapeSize.width;
519 pBackgroundBitmap = __pToolbar->GetBackgroundBitmap();
520 //pBackgroundEffectBitmap = __pToolbar->GetBackgroundEffectBitmap();
522 pReplacementColorBackgroundBitmap =
523 _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
525 if (__pToolbar->IsUserBackgroundBitmap())
527 if (pBackgroundBitmap)
529 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap))
531 pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap);
535 pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundBitmap->GetWidthF(), pBackgroundBitmap->GetHeightF()));
540 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
545 if (pReplacementColorBackgroundBitmap)
547 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
549 pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap);
553 pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pReplacementColorBackgroundBitmap->GetWidthF(), pReplacementColorBackgroundBitmap->GetHeightF()));
558 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
561 //if (pBackgroundEffectBitmap)
563 // if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundEffectBitmap))
565 // pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap);
569 // pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundEffectBitmap->GetWidthF(), pBackgroundEffectBitmap->GetHeightF()));
574 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
576 Bitmap* pSubTitleEffectBitmap = null;
577 Color subTitleEffectColor;
578 float topMargin = 0.0f;
580 GET_BITMAP_CONFIG_N(HEADER::SUB_TITLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pSubTitleEffectBitmap);
581 GET_COLOR_CONFIG(HEADER::SUB_TITLE_EFFECT_NORMAL, subTitleEffectColor);
582 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), topMargin);
584 FloatRectangle subTitleEffectBounds(0.0f, topMargin, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height - topMargin);
586 Bitmap* pReColorSubTitleEffectBitmap = null;
588 pReColorSubTitleEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSubTitleEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), subTitleEffectColor);
590 if (pReColorSubTitleEffectBitmap)
592 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorSubTitleEffectBitmap))
594 pCanvas->DrawNinePatchedBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap);
598 pCanvas->DrawBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap, FloatRectangle(0.0f, 0.0f, pReColorSubTitleEffectBitmap->GetWidthF(), pReColorSubTitleEffectBitmap->GetHeightF()));
602 delete pReColorSubTitleEffectBitmap;
606 delete pReplacementColorBackgroundBitmap;
612 _ToolbarPresenter::DrawDescriptionText(void)
614 result r = E_SUCCESS;
616 float textAreaHeight = 0.0f;
617 float fontSize = 0.0f;
618 float titleIconWidth = 0.0f;
620 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_HEIGHT, __pToolbar->GetOrientation(), textAreaHeight);
621 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
622 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), titleIconWidth);
624 __fontSize = fontSize;
626 __pTextFont = __pToolbar->GetFallbackFont();
628 SysTryReturnVoidResult(NID_UI_CTRL, __pTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
630 if (__pToolbar->GetTitleIcon() != null)
632 __descriptionRect.x = __toolbarUsableArea.x + titleIconWidth + __toolbarUsableArea.x;
636 __descriptionRect.x = __toolbarUsableArea.x;
639 __descriptionRect.y = __titleRect.y + __titleRect.height;
641 if(__titleText.IsEmpty())
643 __descriptionRect.width = __toolbarUsableArea.width;
647 __descriptionRect.width = __titleRect.width;
650 __descriptionRect.height = textAreaHeight;
652 Canvas* pCanvas = __pToolbar->GetCanvasN();
654 if (__pDescriptionTextObject)
656 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
657 __pDescriptionTextObject->SetForegroundColor(__pToolbar->GetDescriptionTextColor(), 0, __pDescriptionTextObject->GetTextLength());
658 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
659 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
660 __pDescriptionTextObject->SetBounds(__descriptionRect);
661 __pDescriptionTextObject->Compose();
662 __pDescriptionTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
671 _ToolbarPresenter::DrawEditItem(const FloatPoint& point)
673 if (__pEditItem == null )
678 FloatPoint anchor = FloatPoint(0.0f, 0.0f);
680 anchor.x = point.x - (__pEditItem->GetSizeF().width / 2);
681 anchor.y = point.y - (__pEditItem->GetSizeF().height / 2);
683 __pEditItem->SetPosition(anchor);
685 __pToolbar->Invalidate(true);
691 _ToolbarPresenter::DrawDividerLine(const FloatPoint& point, Canvas* pCanvas)
693 float dividerWidth = 0.0f;
694 float dividerHeight = 0.0f;
695 Color dividerLeftColor;
696 //Color dividerRightColor;
698 ToolbarStyle style = __pToolbar->GetStyle();
700 GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), dividerWidth);
702 if (style == TOOLBAR_TAB_LARGE)
704 GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
708 GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
711 if (__pToolbar->IsHeader() == true)
713 if (!__pToolbar->IsTransparent())
715 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
716 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
720 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
721 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
726 if (!__pToolbar->IsTransparent())
728 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
729 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
733 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
734 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
738 pCanvas->SetForegroundColor(dividerLeftColor);
739 pCanvas->SetLineWidth(dividerWidth);
741 pCanvas->DrawLine(FloatPoint(point.x, point.y), FloatPoint(point.x, point.y + dividerHeight));
747 _ToolbarPresenter::DrawItems(void)
749 result r = E_SUCCESS;
751 Canvas* pCanvas = __pToolbar->GetCanvasN();
753 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_INVALID_STATE, "[E_INVALID_STATE] System error occurred.");
755 ToolbarStyle style = __pToolbar->GetStyle();
757 FloatRectangle usableArea = __toolbarUsableArea;
759 Bitmap* pTitleIcon = __pToolbar->GetTitleIcon();
761 _Label* pTitleBadgeIcon = __pToolbar->GetTitleBadgeIcon();
763 float iconWidth = 0.0f;
764 float titleDisplayHeight = 0.0f;
765 float leftMargin = 0.0f;
766 float headerTopMargin = 0.0f;
767 float processingAnimationIconSize = 0.0f;
768 float processingAnimationIconGap = 0.0f;
769 float titleCharacterCount = 0.0f;
770 float titleBadgeIconGap = 0.0f;
771 float titleBadgeIconTopMargin = 0.0f;
772 float fontSize = 0.0f;
773 FloatDimension titleTextDimension(0.0f, 0.0f);
774 float totalWidth = 0.0f;
775 float titleHeight = 0.0f;
777 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin);
778 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, __pToolbar->GetOrientation(), processingAnimationIconSize);
779 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_GAP, __pToolbar->GetOrientation(), processingAnimationIconGap);
781 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_ICON_GAP, __pToolbar->GetOrientation(), titleBadgeIconGap);
782 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_TOP_MARGIN, __pToolbar->GetOrientation(), titleBadgeIconTopMargin);
784 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
786 GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), headerTopMargin);
787 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), titleDisplayHeight);
791 GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, __pToolbar->GetOrientation(), headerTopMargin);
792 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT, __pToolbar->GetOrientation(), titleDisplayHeight);
795 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), iconWidth);
797 if (!__titleText.IsEmpty())
799 titleCharacterCount = __titleText.GetLength(); // alphabet count
801 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
803 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize);
805 else if (style == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L""
806 && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED)
808 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize);
812 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
822 __fontSize = fontSize;
824 __pTitleTextFont = __pToolbar->GetFallbackFont();
826 SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
828 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
830 __pTitleTextFont->GetTextExtent(__titleText, titleCharacterCount, titleTextDimension);
832 totalWidth = titleTextDimension.width; // pixel
833 titleHeight = titleTextDimension.height; // pixel
835 __titleRect.height = _FontImpl::GetInstance(*__pTitleTextFont)->GetLeadingF();
839 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
844 totalWidth += (pTitleIcon->GetWidthF() + usableArea.x);
850 totalWidth += pTitleBadgeIcon->GetBoundsF().width + titleBadgeIconGap;
852 else if ((__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE)) != ANIMATION_STOPPED)
854 totalWidth += processingAnimationIconSize + processingAnimationIconGap;
857 if (totalWidth > usableArea.width)
859 __titleRect.width = titleTextDimension.width - (totalWidth - usableArea.width);
863 pCanvas->DrawBitmap(FloatPoint(usableArea.x, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
865 __titleRect.x = usableArea.x + pTitleIcon->GetWidthF() + usableArea.x;
866 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
868 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
870 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
871 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + processingAnimationIconGap,
872 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
877 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + titleBadgeIconGap,
878 titleBadgeIconTopMargin));
883 __titleRect.x = usableArea.x;
884 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
886 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
888 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
889 usableArea.x + __titleRect.width + processingAnimationIconGap,
890 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
895 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + __titleRect.width + titleBadgeIconGap, titleBadgeIconTopMargin));
901 __titleRect.width = usableArea.width;
905 __titleRect.x = leftMargin + pTitleIcon->GetWidthF() + leftMargin;
906 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
908 if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_CENTER)
910 leftMargin = (__titleRect.width - titleTextDimension.width) / 2 - leftMargin;
912 else if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_RIGHT)
914 leftMargin = __titleRect.width - titleTextDimension.width - leftMargin * 3;
917 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
919 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
921 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
922 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + processingAnimationIconGap,
923 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
928 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + titleBadgeIconGap,
929 titleBadgeIconTopMargin));
932 __titleRect.width -= (pTitleIcon->GetWidthF() + usableArea.x);
936 __titleRect.x = leftMargin;
937 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
939 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
941 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
942 leftMargin + titleTextDimension.width + processingAnimationIconGap,
943 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
948 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + titleTextDimension.width + titleBadgeIconGap, titleBadgeIconTopMargin));
955 if (pTitleIcon && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
957 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
959 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
961 leftMargin = (leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize)) / 2;
963 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
965 leftMargin = leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize);
968 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
970 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
971 leftMargin + processingAnimationIconGap + processingAnimationIconSize,
972 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
976 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + processingAnimationIconGap + titleBadgeIconGap, titleBadgeIconTopMargin));
981 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
983 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
985 leftMargin = usableArea.width / 2;
987 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
989 leftMargin = usableArea.width - pTitleIcon->GetWidthF();
992 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
996 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
998 leftMargin = (usableArea.width - (processingAnimationIconGap + processingAnimationIconSize))/ 2;
1000 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
1002 leftMargin = usableArea.width - (processingAnimationIconGap + processingAnimationIconSize);
1005 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
1006 leftMargin, headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
1008 if (pTitleBadgeIcon)
1010 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin, titleBadgeIconTopMargin));
1021 _ToolbarPresenter::DrawTitleText(Canvas* pCanvas)
1023 TimerForTitleSlideInit();
1025 if (__titleText.IsEmpty())
1030 __pTitleTextObject->SetForegroundColor(__pToolbar->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
1031 __pTitleTextObject->SetBounds(__titleRect);
1032 //__pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1033 __pTitleTextObject->Compose();
1035 if (__pTitleTextObject->IsActionOn() == true)
1037 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1039 DrawTitleTextDimBitmap();
1041 TimerForTitleSlideStart();
1045 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1052 _ToolbarPresenter::GetSelectedItemIndex(void) const
1054 return __pToolbarModel->GetSelectedItemIndex();
1058 _ToolbarPresenter::IsInitialDraw(void) const
1060 return __initialDraw;
1064 _ToolbarPresenter::IsTabEditModeEnabled(void) const
1066 return __tabEditEnabled;
1070 _ToolbarPresenter::SetDescriptionText(const String& description)
1072 result r = E_SUCCESS;
1074 float length = description.GetLength();
1075 float fontSize = 0.0f;
1077 wchar_t* tempString = const_cast<wchar_t*>(description.GetPointer());
1080 if (__pDescriptionTextObject != null)
1082 delete __pDescriptionTextObject;
1083 __pDescriptionTextObject = null;
1086 __pDescriptionTextObject = new (std::nothrow) TextObject();
1088 if (__pDescriptionTextObject == null)
1090 return E_OUT_OF_MEMORY;
1092 __pDescriptionTextObject->Construct();
1093 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1094 __pDescriptionTextObject->AppendElement(*pSimpleText);
1095 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1096 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1098 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1100 __fontSize = fontSize;
1102 __pTextFont = __pToolbar->GetFallbackFont();
1103 r = GetLastResult();
1104 SysTryReturn(NID_UI_CTRL, __pTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1106 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
1112 _ToolbarPresenter::SetItemSelected(int itemIndex, bool adjust)
1116 ToolbarStyle style = __pToolbar->GetStyle();
1118 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1120 if (itemIndex <= __pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX)
1122 SetItemFit(itemIndex);
1126 SetItemFit(__pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX);
1131 return __pToolbarModel->SetSelectedItemIndex(itemIndex);
1135 _ToolbarPresenter::SetInitialDrawState(bool state)
1137 //DrawBackground(); // remove since 2.1
1138 __initialDraw = state;
1140 __titlePressed = false;
1141 __titleSliding = false;
1142 __tabEditEnabled = false;
1144 __firstLoadedItemIndex = 0;
1145 __lastLoadedItemIndex = 0;
1151 _ToolbarPresenter::SetTabEditModeEnabled(bool enable)
1153 __tabEditEnabled = enable;
1159 _ToolbarPresenter::SetTitleText(const String& title, HorizontalAlignment alignment)
1161 result r = E_SUCCESS;
1163 float length = title.GetLength();
1165 __titleText = String(title);
1166 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
1169 if (__pTitleTextObject != null)
1171 delete __pTitleTextObject;
1172 __pTitleTextObject = null;
1175 __pTitleTextObject = new (std::nothrow) TextObject();
1177 if (__pTitleTextObject == null)
1179 return E_OUT_OF_MEMORY;
1181 __pTitleTextObject->Construct();
1182 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1183 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1184 __pTitleTextObject->AppendElement(*pSimpleText);
1186 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1188 __titleSliding = false;
1192 case ALIGNMENT_LEFT:
1193 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1195 case ALIGNMENT_CENTER:
1196 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1198 case ALIGNMENT_RIGHT:
1199 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT);
1202 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1206 float fontSize = 0.0f;
1208 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1210 __fontSize = fontSize;
1212 __pTitleTextFont = __pToolbar->GetFallbackFont();
1213 r = GetLastResult();
1214 SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1216 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
1218 //__pTitleTextObject->Compose();
1224 _ToolbarPresenter::SetUsableAreaBounds(const FloatRectangle& rect)
1226 __toolbarUsableArea = rect;
1232 _ToolbarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1234 ResetFlickAnimationTimer();
1236 SetFirstLoadedItemIndex();
1237 SetLastLoadedItemIndex();
1239 __touchInitiatedInToolbar = true;
1241 __currentTouchPosition = touchinfo.GetCurrentPosition();
1243 ToolbarStyle style = __pToolbar->GetStyle();
1245 if (__titleRect.Contains(__currentTouchPosition)
1246 && (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE))
1248 __titlePressed = true;
1252 __titlePressed = false;
1255 __pressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1257 if (__pressedItemIndex == -1)
1259 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1263 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1265 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1267 if (pLabel == pTempBadgeIcon)
1269 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1273 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1275 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1277 if (pLabel == pTempBadgeIcon)
1279 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1286 _Button* pPressedButton = __pToolbar->GetItem(__pressedItemIndex);
1288 __initialPressesItemStatus = pPressedButton->GetButtonStatus();
1290 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1295 pPressedButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1298 __pToolbar->Invalidate(true);
1304 _ToolbarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1306 if (!__touchInitiatedInToolbar)
1311 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1313 if (__titlePressed && __titleRect.Contains(touchPoint))
1315 if (__titleSliding == true)
1317 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1318 __pTitleTextObject->Compose();
1320 __titleSliding = false;
1324 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1325 __pTitleTextObject->Compose();
1327 __titleSliding = true;
1329 TimerForTitleSlideStart();
1333 SetFirstLoadedItemIndex();
1334 SetLastLoadedItemIndex();
1336 ToolbarStyle style = __pToolbar->GetStyle();
1338 __touchInitiatedInToolbar = false;
1340 int releasedItemIndex = __pToolbar->GetItemIndexFromPosition(touchPoint);
1341 float tabLeftMargin = 0.0f;
1343 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
1345 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1347 __beingEdited = false;
1349 if (releasedItemIndex == -1)
1353 __pToolbar->DetachChild(*__pEditItem);
1359 if (__pressedItemIndex != -1)
1361 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus);
1366 __pToolbar->MoveItem(__editItemIndex, releasedItemIndex);
1368 AdjustItemPositionX(-__pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x + tabLeftMargin); // move auto focus
1372 __pToolbar->DetachChild(*__pEditItem);
1381 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE)
1382 && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1384 if (__pressedItemIndex != -1)
1386 if (releasedItemIndex == __pressedItemIndex)
1388 if (__initialPressesItemStatus != _BUTTON_STATUS_DISABLED && __tabMoved != true)
1390 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1394 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1399 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1405 if (__pressedItemIndex != -1 && (releasedItemIndex != __pressedItemIndex))
1407 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1411 if (__pressedItemIndex != -1 && __initialPressesItemStatus != _BUTTON_STATUS_DISABLED)
1413 if (style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE
1414 || style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_SEGMENTED || style == TOOLBAR_TAB_LARGE)
1416 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1420 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetItem(releasedItemIndex));
1421 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1422 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1427 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1431 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1433 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1435 if (pLabel == pTempBadgeIcon)
1437 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1439 if (buttonItemBounds.Contains(touchPoint))
1441 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(LEFT_BUTTON));
1442 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1445 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1449 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1451 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1453 if (pLabel == pTempBadgeIcon)
1455 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1457 if (buttonItemBounds.Contains(touchPoint))
1459 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(RIGHT_BUTTON));
1460 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1463 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1469 __pToolbar->Invalidate(true);
1478 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1479 int itemCount = __pToolbar->GetItemCount();
1481 for (int j = 0; j < itemCount; j++)
1483 if (__pToolbar->GetItem(j) != null && __pToolbar->GetItem(j)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1485 __pToolbar->GetItem(j)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1490 __pToolbar->Invalidate(true);
1496 _ToolbarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1498 if (!__touchInitiatedInToolbar)
1503 SetFirstLoadedItemIndex();
1504 SetLastLoadedItemIndex();
1506 ToolbarStyle style = __pToolbar->GetStyle();
1507 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1509 if (__pressedItemIndex == -1)
1511 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1515 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1517 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1519 if (pLabel == pTempBadgeIcon)
1521 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1523 if (buttonItemBounds.Contains(touchPoint))
1525 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1529 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1534 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1536 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1538 if (pLabel == pTempBadgeIcon)
1540 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1542 if (buttonItemBounds.Contains(touchPoint))
1544 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1548 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1554 __pToolbar->Invalidate(true);
1559 _Button* pCurrentButton = __pToolbar->GetItem(__pressedItemIndex);
1561 if (pCurrentButton == null)
1566 FloatRectangle itemBounds = pCurrentButton->GetBoundsF();
1568 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1570 if (itemBounds.Contains(touchPoint))
1576 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1578 DrawEditItem(touchinfo.GetCurrentPosition());
1584 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1588 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1593 if (itemBounds.Contains(touchPoint))
1595 pCurrentButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1599 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1603 pCurrentButton->Invalidate(false);
1608 float distance = (touchinfo.GetCurrentPosition()).x - __currentTouchPosition.x;
1609 float sideMargin = 0.0f;
1611 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), sideMargin);
1613 FloatRectangle clientBounds = __pToolbar->GetBoundsF();
1615 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1616 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
1618 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
1620 if (clientBounds.width > __portraitSize.width)
1622 clientBounds.width = __portraitSize.width;
1627 if (clientBounds.width > __landscapeSize.width)
1629 clientBounds.width = __landscapeSize.width;
1633 __currentTouchPosition = touchinfo.GetCurrentPosition();
1635 _Button* pItem = null;
1636 FloatRectangle itemBounds;
1637 int itemCount = __pToolbar->GetItemCount();
1639 if (distance > 0) // right move
1641 pItem = __pToolbar->GetItem(0);
1647 itemBounds = pItem->GetBoundsF();
1649 if (itemBounds.x + distance >= sideMargin && !__beingEdited)
1651 distance = sideMargin - itemBounds.x;
1654 else if (distance < 0)
1656 pItem = __pToolbar->GetItem(itemCount - 1);
1663 itemBounds = pItem->GetBoundsF();
1665 if (itemBounds.x + itemBounds.width + distance <= clientBounds.width - sideMargin && !__beingEdited)
1667 distance = (clientBounds.width - sideMargin) - (itemBounds.x + itemBounds.width);
1672 float tabLeftMargin = 0.0f;
1674 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
1676 if (distance > 0) // right move
1678 __tabSlideRight = false;
1680 if (__pToolbar->GetItem(__lastLoadedItemIndex - 1)->GetBoundsF().x <= __pEditItem->GetBoundsF().x)
1682 __tabSlideLeft = true;
1685 if (__tabSlideLeft && __pToolbar->GetItem(itemCount-1)->GetBoundsF().x + __pToolbar->GetItem(itemCount-1)->GetBoundsF().width > clientBounds.width - tabLeftMargin)
1687 AdjustItemPositionX(-distance * 5); // move auto focus
1690 else if (distance < 0)
1692 __tabSlideLeft = false;
1694 if (__pToolbar->GetItem(__firstLoadedItemIndex + 1)->GetBoundsF().x >= __pEditItem->GetBoundsF().x)
1696 __tabSlideRight = true;
1699 if (__tabSlideRight && __pToolbar->GetItem(0)->GetBoundsF().x < tabLeftMargin)
1701 AdjustItemPositionX(-distance * 5); // move auto focus
1707 AdjustItemPositionX(distance);
1717 _ToolbarPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1719 __touchInitiatedInToolbar = false;
1720 __beingEdited = false;
1722 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1723 int itemCount = __pToolbar->GetItemCount();
1725 for (int i = 0; i < itemCount; i++)
1727 if (__pToolbar->GetItem(i) != null && __pToolbar->GetItem(i)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1729 __pToolbar->GetItem(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1735 __pToolbar->DetachChild(*__pEditItem);
1742 __pToolbar->Invalidate(true);
1748 _ToolbarPresenter::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation)
1750 ResetFlickAnimationTimer();
1756 _ToolbarPresenter::OnLongPressGestureDetected(void)
1758 if (__pToolbar->IsTabEditModeEnabled() == true)
1760 int longPressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1762 if (longPressedItemIndex == -1)
1767 _Button* pButton = null;
1768 pButton = __pToolbar->GetItem(longPressedItemIndex);
1769 SysTryReturn(NID_UI_CTRL, pButton, true, E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a button");
1771 if (pButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED)
1776 __editItemIndex = longPressedItemIndex;
1777 __beingEdited = true;
1779 pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1781 FloatRectangle itemBounds = pButton->GetBoundsF();
1785 __pToolbar->DetachChild(*__pEditItem);
1791 __pEditItem = _Label::CreateLabelN();
1792 SysTryCatch(NID_UI_CTRL, __pEditItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
1794 Canvas* pCanvas = pButton->GetCanvasN();
1795 SysTryCatch(NID_UI_CTRL, pCanvas, , E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a Canvas.");
1797 Bitmap* pEditItemBitmap = new (std::nothrow) Bitmap();
1798 result r = pEditItemBitmap->Construct(*pCanvas, FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height));
1802 delete pEditItemBitmap;
1803 pEditItemBitmap = null;
1810 __pEditItem->SetBounds(itemBounds);
1811 __pEditItem->SetBackgroundBitmap(*pEditItemBitmap);
1814 delete pEditItemBitmap;
1816 __pToolbar->AttachChild(*__pEditItem);
1817 __pToolbar->SetChildAlwaysOnTop(*__pEditItem);
1835 _ToolbarPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1837 ToolbarStyle style = __pToolbar->GetStyle();
1839 if (!(style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) || __pToolbar->GetItemCount() <= SEGMENTED_ITEM_MAX || __beingEdited == true || __tabMoved == false)
1844 if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT)
1849 float distanceX = 0.0f;
1850 float distanceY = 0.0f;
1851 float xPosition = 0.0f;
1852 float itemsBeyondScreen = 0.0f;
1854 gesture.GetDistance(distanceX, distanceY);
1855 SetFirstLoadedItemIndex();
1856 SetLastLoadedItemIndex();
1857 int itemCount = __pToolbar->GetItemCount();
1858 float itemWidth = __pToolbar->GetItem(0)->GetBoundsF().width;
1860 if (distanceX < 0) //left
1862 itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex;
1863 xPosition = __pToolbar->GetItem(__lastLoadedItemIndex)->GetBoundsF().x;
1864 if (xPosition < (3 * itemWidth))
1866 __flickDistance = xPosition - (4 * itemWidth);
1871 itemsBeyondScreen = __firstLoadedItemIndex;
1872 xPosition = __pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x;
1875 __flickDistance = -xPosition;
1880 int itemMaxCount = 4;
1882 if (itemsBeyondScreen >= (itemMaxCount - 1))
1884 __flickDistance = (3 * itemWidth);
1888 __flickDistance = (itemsBeyondScreen * itemWidth);
1891 if (distanceX < 0) //Left flick
1893 __flickMove = 0.006f;
1896 else if (distanceX > 0) //Right flick
1898 __flickMove = 0.006f;
1899 __flickDistance = -(__flickDistance);
1905 __flickDistance = 0.0f;
1907 __moveDistance = 0.0f;
1910 StartFlickAnimationTimer();
1916 _ToolbarPresenter::OnTimerExpired(Timer& timer)
1918 Timer* onTimer = &timer;
1920 if (onTimer == __pTitleSlideTimer)
1922 TimerForTitleSlideTimeout();
1925 if (onTimer == __pFlickAnimationTimer)
1927 StartFlickAnimation();
1934 _ToolbarPresenter::OnDrawFocus(void)
1940 _ToolbarPresenter::OnChildControlFocusMoved(const _Control& control)
1946 _ToolbarPresenter::IsChildControlFocusManage(void) const
1952 _ToolbarPresenter::OnFocusableStateChanged(bool focusalbeState)
1958 _ToolbarPresenter::OnFocusModeStateChanged(void)
1964 _ToolbarPresenter::OnFocusGained(const _Control& source)
1966 //__focusPrevStatus = __pButton->GetButtonStatus();
1967 //__pButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
1968 //__pButton->Invalidate();
1974 _ToolbarPresenter::OnFocusLost(const _Control& source)
1976 //__pButton->SetButtonStatus(__focusPrevStatus);
1977 //__pButton->Invalidate();
1983 _ToolbarPresenter::TimerForTitleSlideInit(void)
1985 result r = E_SUCCESS;
1987 if (__pTitleSlideTimer != null)
1989 delete __pTitleSlideTimer;
1990 __pTitleSlideTimer = null;
1997 _ToolbarPresenter::TimerForTitleSlideStart(void)
1999 result r = E_SUCCESS;
2001 if (__pTitleSlideTimer == null)
2003 __pTitleSlideTimer = new (std::nothrow) Timer();
2004 if (__pTitleSlideTimer == null)
2006 r = E_OUT_OF_MEMORY;
2010 r = __pTitleSlideTimer->Construct(*this);
2014 delete __pTitleSlideTimer;
2019 r = __pTitleSlideTimer->Start(100);
2031 _ToolbarPresenter::TimerForTitleSlideTimeout(void)
2033 Canvas* pCanvas = __pToolbar->GetCanvasN();
2034 SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pCanvas is invalid!");
2036 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2037 pCanvas->Clear(__titleRect);
2039 if (__pTitleBackgroundBitmap)
2041 pCanvas->DrawBitmap(CoordinateSystem::AlignToDevice(__titleRect), *__pTitleBackgroundBitmap);
2044 if (__pTitleTextObject->IsChanged())
2046 DrawTitleText(pCanvas);
2049 if (__pTitleTextObject->IsActionOn() == true)
2051 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
2053 DrawTitleTextDimBitmap();
2055 if (__pTitleTextObject->GetRepeatCount() < 3)
2057 TimerForTitleSlideStart();
2062 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
2071 _ToolbarPresenter::DrawTitleTextDimBitmap(void)
2073 if (__pToolbar->IsUserBackgroundBitmap())
2078 float textDimWidth = 0.0f;
2079 float textDimHeight = 0.0f;
2080 float leftMargin = 0.0f;
2082 GET_SHAPE_CONFIG(HEADER::TAB_TEXT_DIM_WIDTH, __pToolbar->GetOrientation(), textDimWidth);
2083 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin);
2085 ToolbarStyle style = __pToolbar->GetStyle();
2087 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
2089 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), textDimHeight);
2093 if (__pToolbar->GetDescriptionText() != L"")
2095 textDimHeight = __titleRect.height + __titleRect.y;
2099 textDimHeight = __pToolbar->GetBoundsF().height;
2103 //Color titleTextDimColor;
2104 //GET_COLOR_CONFIG(HEADER::TITLE_TEXT_DIM_NORMAL, titleTextDimColor);
2106 Bitmap* pTitleTextDimLeftBitmap = null;
2107 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimLeftBitmap);
2109 Bitmap* pReColorTitleTextDimLeftBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimLeftBitmap,
2110 Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
2112 if (pReColorTitleTextDimLeftBitmap)
2114 Canvas* pCanvas = __pToolbar->GetCanvasN();
2115 FloatRectangle bounds = FloatRectangle(0.0f, 0.0f, textDimWidth, textDimHeight);
2117 if (__pToolbar->GetTitleIcon() != null)
2119 bounds.x += __titleRect.x;
2122 if (pCanvas == null)
2124 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
2126 delete pReColorTitleTextDimLeftBitmap;
2131 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimLeftBitmap))
2133 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimLeftBitmap);
2137 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimLeftBitmap,
2138 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimLeftBitmap->GetWidthF(), pReColorTitleTextDimLeftBitmap->GetHeightF()));
2141 delete pReColorTitleTextDimLeftBitmap;
2145 Bitmap* pTitleTextDimRightBitmap = null;
2146 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimRightBitmap);
2148 Bitmap* pReColorTitleTextDimRightBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimRightBitmap,
2149 Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
2151 if (pReColorTitleTextDimRightBitmap)
2153 Canvas* pCanvas = __pToolbar->GetCanvasN();
2154 FloatRectangle bounds = FloatRectangle(__titleRect.width, 0.0f, textDimWidth, textDimHeight);
2156 if (__pToolbar->GetTitleIcon() != null)
2158 bounds.x += (__titleRect.x - leftMargin);
2161 if (pCanvas == null)
2163 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
2165 delete pReColorTitleTextDimRightBitmap;
2169 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimRightBitmap))
2171 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimRightBitmap);
2175 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimRightBitmap,
2176 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimRightBitmap->GetWidthF(), pReColorTitleTextDimRightBitmap->GetHeightF()));
2179 delete pReColorTitleTextDimRightBitmap;
2187 _ToolbarPresenter::AdjustItemPositionX(float distance)
2190 int itemCount = __pToolbar->GetItemCount();
2191 _Button* pItem = __pToolbar->GetItem(index);
2193 while (pItem != null)
2195 FloatRectangle bounds = pItem->GetBoundsF();
2196 bounds.x += distance;
2197 pItem->SetBounds(bounds);
2200 if (index < itemCount)
2202 pItem = __pToolbar->GetItem(index);
2214 _ToolbarPresenter::GetTitleTextBoundsF(void) const
2220 _ToolbarPresenter::GetDescriptionBoundsF(void) const
2222 return __descriptionRect;
2226 _ToolbarPresenter::_SetModel(const _ToolbarModel& toolbarModel)
2228 __pToolbarModel = const_cast<_ToolbarModel*>(&toolbarModel);
2234 _ToolbarPresenter::OnFontChanged(Font* pFont)
2236 __pTextFont = pFont;
2237 __pTitleTextFont = pFont;
2243 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, int& size)
2245 style = __fontStyle;
2246 size = _CoordinateSystemUtils::ConvertToInteger(__fontSize);
2252 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2254 style = __fontStyle;
2261 _ToolbarPresenter::OnAncestorVisibleStateChanged(const _Control& control)
2263 if (__pTitleTextObject != null)
2265 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2266 __pTitleTextObject->Compose();
2269 __titleSliding = false;
2275 _ToolbarPresenter::SetFontInfo(unsigned long style, float size)
2277 __fontStyle = style;
2284 _ToolbarPresenter::StartFlickAnimation(void)
2286 float distance = CalculateProgress(__flickMove);
2288 __moveDistance = -(__flickDistance * distance);
2289 __flickDistance = (__flickDistance + __moveDistance);
2290 __flickMove = __flickMove + 0.006;
2293 if (__flickFlag <= FLICK_ANIMATION_COUNT)
2295 StartFlickAnimationTimer();
2299 ResetFlickAnimationTimer();
2300 SetItemFit(__firstLoadedItemIndex);
2303 AdjustItemPositionX(__moveDistance);
2305 SetFirstLoadedItemIndex();
2306 SetLastLoadedItemIndex();
2314 _ToolbarPresenter::StartFlickAnimationTimer(void)
2316 result r = E_SUCCESS;
2318 if (__pFlickAnimationTimer == null)
2320 __pFlickAnimationTimer = new (std::nothrow) Timer();
2321 SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2323 r = __pFlickAnimationTimer->Construct(*this);
2324 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2328 __pFlickAnimationTimer->Cancel();
2331 r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD);
2332 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2337 ResetFlickAnimationTimer();
2342 _ToolbarPresenter::ResetFlickAnimationTimer(void)
2344 if (__pFlickAnimationTimer)
2346 delete __pFlickAnimationTimer;
2347 __pFlickAnimationTimer = null;
2350 __moveDistance = 0.0f;
2356 _ToolbarPresenter::SetFirstLoadedItemIndex(void)
2358 int itemCount = __pToolbar->GetItemCount();
2360 for (int i = 0; i < itemCount; i++)
2362 if (__pToolbar->GetItem(i)->GetBoundsF().x + (__pToolbar->GetItem(i)->GetBoundsF().width / 2) <= __pToolbar->GetItem(i)->GetBoundsF().width)
2364 __firstLoadedItemIndex = i;
2372 _ToolbarPresenter::GetFirstLoadedItemIndex(void)
2374 return __firstLoadedItemIndex;
2378 _ToolbarPresenter::SetLastLoadedItemIndex(void)
2381 int itemCount = __pToolbar->GetItemCount();
2383 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
2385 width = __portraitSize.width;
2389 width = __landscapeSize.width;
2392 for (int i = 0; i < itemCount; i++)
2394 float X = __pToolbar->GetItem(i)->GetBoundsF().x;
2396 if ((X + (__pToolbar->GetItem(i)->GetBoundsF().width / 2)) < width)
2398 __lastLoadedItemIndex = i;
2406 _ToolbarPresenter::CalculateProgress(float timeProgress) const
2408 const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}};
2409 float loc_5 = timeProgress / 1;
2410 int loc_6 = 3; //Length of the segments array
2411 int loc_9 = (int)floor(loc_6 * loc_5);
2418 float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
2421 for (int i = 0; i < 3; i++)
2423 loc_8[i] = segments[loc_9][i];
2426 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])));
2432 _ToolbarPresenter::SetItemFit(int index)
2439 FloatPoint pt(0.0f, 0.0f);
2440 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2442 float fitDistance = 0.0f;
2443 float tabLeftMargin = 0.0f;
2444 int itemCount = __pToolbar->GetItemCount();
2446 GET_SHAPE_CONFIG(HEADER::TAB_LEFT_MARGIN, __pToolbar->GetOrientation(), tabLeftMargin);
2448 _Button* pItem = __pToolbar->GetItem(index);
2449 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2451 bounds = pItem->GetBoundsF();
2453 fitDistance = -bounds.x + tabLeftMargin;
2455 for (int i = 0; i < itemCount; i++)
2457 pItem = __pToolbar->GetItem(i);
2458 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2460 bounds = pItem->GetBoundsF();
2461 bounds.x = bounds.x + fitDistance;
2462 pItem->SetBounds(bounds);
2465 SetFirstLoadedItemIndex();
2466 SetLastLoadedItemIndex();
2474 _ToolbarPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2480 _ToolbarPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2486 _ToolbarPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2491 }}} // Tizen::Ui::Controls