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)
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;
136 __pDividerVe->RemoveAllAnimations();
137 __pDividerVe->Destroy();
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);
314 else if(__pToolbar->IsHeader()) //All header styles
316 GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
320 GET_SHAPE_CONFIG(FOOTER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
323 FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height);
325 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
327 if (bounds.width > __portraitSize.width)
329 bounds.width = __portraitSize.width;
334 if (bounds.width > __landscapeSize.width)
336 bounds.width = __landscapeSize.width;
340 Canvas * pCanvas = null;
341 int Z_ORDER_GROUP_CONTROL = 2001;
343 if (__pDividerVe == null)
345 __pDividerVe = new (std::nothrow) VisualElement();
346 SysTryReturnVoidResult(NID_UI_CTRL, __pDividerVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
348 __pDividerVe->Construct();
349 __pDividerVe->SetName(L"DividerEffect");
352 __pDividerVe->SetBounds(FloatRectangle(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height));
353 __pDividerVe->SetShowState(true);
354 __pDividerVe->SetImplicitAnimationEnabled(false);
356 _VisualElementImpl::GetInstance(*__pDividerVe)->SetZOrderGroup(Z_ORDER_GROUP_CONTROL + 1);
357 __pToolbar->GetVisualElement()->AttachChild(*__pDividerVe);
359 pCanvas = __pDividerVe->GetCanvasN();
363 __pDividerVe->Destroy();
366 SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
371 Color backgroundColor(0, 0, 0, 0);
372 pCanvas->SetBackgroundColor(backgroundColor);
376 if (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED)
378 if (__pToolbar->GetButton(RIGHT_BUTTON))
380 if (__pToolbar->GetButton(LEFT_BUTTON))
382 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
383 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
385 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
386 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
387 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
391 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
392 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
397 if (__pToolbar->GetButton(LEFT_BUTTON))
399 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
400 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
404 else if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE)
406 if (__pToolbar->GetButton(RIGHT_BUTTON))
408 if (__pToolbar->GetButton(LEFT_BUTTON))
410 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
411 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
413 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
414 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
415 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
419 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
420 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
425 if (__pToolbar->GetButton(LEFT_BUTTON))
427 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
428 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
432 else if (style == TOOLBAR_TAB_WITH_TITLE)
434 if (__pToolbar->GetButton(RIGHT_BUTTON))
436 if (__pToolbar->GetButton(LEFT_BUTTON))
438 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
439 (dividerTopMargin - dividerHeight) / 2), pCanvas);
441 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap
442 - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
443 (dividerTopMargin - dividerHeight) / 2), pCanvas);
447 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
448 (dividerTopMargin - dividerHeight) / 2), pCanvas);
453 if (__pToolbar->GetButton(LEFT_BUTTON))
455 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
456 (dividerTopMargin - dividerHeight) / 2), pCanvas);
460 else if (style == TOOLBAR_SEGMENTED || style == TOOLBAR_TEXT || style == TOOLBAR_ICON || style == TOOLBAR_ICON_TEXT || style == TOOLBAR_COMMAND)
462 if (__pToolbar->GetButton(RIGHT_BUTTON))
464 DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap / 2,
465 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
468 if (__pToolbar->GetButton(LEFT_BUTTON))
470 DrawDividerLine(FloatPoint(__pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width + buttonItemGap / 2,
471 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
475 // Headeritem, FooterItemDivider
482 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
484 for (int i = 0; i < itemCount - 1 ; i++)
486 if (i < itemCount - 2)
488 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
489 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
491 else // i == (itemCount - 2)
493 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i + 1)->GetBoundsF().x,
494 dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas);
500 for (int i = 0; i < itemCount - 1 ; i++)
502 if (i < itemCount - 2)
504 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width,
505 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
507 else // i == (itemCount - 2)
509 DrawDividerLine(FloatPoint(__pToolbar->GetItem(i + 1)->GetBoundsF().x,
510 (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas);
522 _ToolbarPresenter::DrawBackground(void)
524 Canvas* pCanvas = __pToolbar->GetCanvasN();
528 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
533 ToolbarStyle style = __pToolbar->GetStyle();
535 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
538 if (style == TOOLBAR_SOFTKEY)
545 Bitmap* pReplacementColorBackgroundBitmap = null;
546 Bitmap* pBackgroundBitmap = null;
547 //Bitmap* pBackgroundEffectBitmap = null;
549 FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height);
551 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
552 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
554 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
556 if (bounds.width > __portraitSize.width)
558 bounds.width = __portraitSize.width;
563 if (bounds.width > __landscapeSize.width)
565 bounds.width = __landscapeSize.width;
569 pBackgroundBitmap = __pToolbar->GetBackgroundBitmap();
570 //pBackgroundEffectBitmap = __pToolbar->GetBackgroundEffectBitmap();
572 pReplacementColorBackgroundBitmap =
573 _BitmapImpl::GetColorReplacedBitmapN(*pBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
575 if (__pToolbar->IsUserBackgroundBitmap())
577 if (pBackgroundBitmap)
579 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap))
581 pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap);
585 pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundBitmap->GetWidthF(), pBackgroundBitmap->GetHeightF()));
590 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
595 if (pReplacementColorBackgroundBitmap)
597 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReplacementColorBackgroundBitmap))
599 pCanvas->DrawNinePatchedBitmap(bounds, *pReplacementColorBackgroundBitmap);
603 pCanvas->DrawBitmap(bounds, *pReplacementColorBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pReplacementColorBackgroundBitmap->GetWidthF(), pReplacementColorBackgroundBitmap->GetHeightF()));
608 pCanvas->FillRectangle(__pToolbar->GetColor(), bounds);
611 //if (pBackgroundEffectBitmap)
613 // if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundEffectBitmap))
615 // pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundEffectBitmap);
619 // pCanvas->DrawBitmap(bounds, *pBackgroundEffectBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundEffectBitmap->GetWidthF(), pBackgroundEffectBitmap->GetHeightF()));
624 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
626 Bitmap* pSubTitleEffectBitmap = null;
627 Color subTitleEffectColor;
628 float topMargin = 0.0f;
630 GET_BITMAP_CONFIG_N(HEADER::SUB_TITLE_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, pSubTitleEffectBitmap);
631 GET_COLOR_CONFIG(HEADER::SUB_TITLE_EFFECT_NORMAL, subTitleEffectColor);
632 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), topMargin);
634 FloatRectangle subTitleEffectBounds(0.0f, topMargin, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height - topMargin);
636 Bitmap* pReColorSubTitleEffectBitmap = null;
638 pReColorSubTitleEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSubTitleEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), subTitleEffectColor);
640 if (pReColorSubTitleEffectBitmap)
642 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorSubTitleEffectBitmap))
644 pCanvas->DrawNinePatchedBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap);
648 pCanvas->DrawBitmap(subTitleEffectBounds, *pReColorSubTitleEffectBitmap, FloatRectangle(0.0f, 0.0f, pReColorSubTitleEffectBitmap->GetWidthF(), pReColorSubTitleEffectBitmap->GetHeightF()));
652 delete pReColorSubTitleEffectBitmap;
656 delete pReplacementColorBackgroundBitmap;
662 _ToolbarPresenter::DrawDescriptionText(void)
664 result r = E_SUCCESS;
666 float textAreaHeight = 0.0f;
667 float fontSize = 0.0f;
668 float titleIconWidth = 0.0f;
670 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_HEIGHT, __pToolbar->GetOrientation(), textAreaHeight);
671 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
672 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), titleIconWidth);
674 __fontSize = fontSize;
676 __pTextFont = __pToolbar->GetFallbackFont();
678 SysTryReturnVoidResult(NID_UI_CTRL, __pTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
680 if (__pToolbar->GetTitleIcon() != null)
682 __descriptionRect.x = __toolbarUsableArea.x + titleIconWidth + __toolbarUsableArea.x;
686 __descriptionRect.x = __toolbarUsableArea.x;
689 __descriptionRect.y = __titleRect.y + __titleRect.height;
691 if(__titleText.IsEmpty())
693 __descriptionRect.width = __toolbarUsableArea.width;
697 __descriptionRect.width = __titleRect.width;
700 __descriptionRect.height = textAreaHeight;
702 Canvas* pCanvas = __pToolbar->GetCanvasN();
704 if (__pDescriptionTextObject)
706 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
707 __pDescriptionTextObject->SetForegroundColor(__pToolbar->GetDescriptionTextColor(), 0, __pDescriptionTextObject->GetTextLength());
708 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
709 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
710 __pDescriptionTextObject->SetBounds(__descriptionRect);
711 __pDescriptionTextObject->Compose();
712 __pDescriptionTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
721 _ToolbarPresenter::DrawEditItem(const FloatPoint& point)
723 if (__pEditItem == null )
728 FloatPoint anchor = FloatPoint(0.0f, 0.0f);
730 anchor.x = point.x - (__pEditItem->GetSizeF().width / 2);
731 anchor.y = point.y - (__pEditItem->GetSizeF().height / 2);
733 __pEditItem->SetPosition(anchor);
735 __pToolbar->Invalidate(true);
741 _ToolbarPresenter::DrawDividerLine(const FloatPoint& point, Canvas* pCanvas)
743 float dividerWidth = 0.0f;
744 float dividerHeight = 0.0f;
745 Color dividerLeftColor;
746 //Color dividerRightColor;
748 ToolbarStyle style = __pToolbar->GetStyle();
750 GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), dividerWidth);
752 if (style == TOOLBAR_TAB_LARGE)
754 GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
756 else if(__pToolbar->IsHeader()) //All header styles
758 GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
762 GET_SHAPE_CONFIG(FOOTER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight);
765 if (__pToolbar->IsHeader() == true)
767 if (!__pToolbar->IsTransparent())
769 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
770 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
774 GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
775 //GET_COLOR_CONFIG(HEADER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
780 if (!__pToolbar->IsTransparent())
782 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_NORMAL, dividerLeftColor);
783 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_NORMAL, dividerRightColor);
787 GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_LEFT_TRANSLUCENT_NORMAL, dividerLeftColor);
788 //GET_COLOR_CONFIG(FOOTER::DIVIDER_LINE_RIGHT_TRANSLUCENT_NORMAL, dividerRightColor);
792 pCanvas->SetForegroundColor(dividerLeftColor);
793 pCanvas->SetLineWidth(dividerWidth);
795 pCanvas->DrawLine(FloatPoint(point.x, point.y), FloatPoint(point.x, point.y + dividerHeight));
801 _ToolbarPresenter::DrawItems(void)
803 result r = E_SUCCESS;
805 Canvas* pCanvas = __pToolbar->GetCanvasN();
807 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_INVALID_STATE, "[E_INVALID_STATE] System error occurred.");
809 ToolbarStyle style = __pToolbar->GetStyle();
811 FloatRectangle usableArea = __toolbarUsableArea;
813 Bitmap* pTitleIcon = __pToolbar->GetTitleIcon();
815 _Label* pTitleBadgeIcon = __pToolbar->GetTitleBadgeIcon();
817 float iconWidth = 0.0f;
818 float iconRightMargin = 0.0f;
819 float titleDisplayHeight = 0.0f;
820 float leftMargin = 0.0f;
821 float headerTopMargin = 0.0f;
822 float processingAnimationIconSize = 0.0f;
823 float processingAnimationIconGap = 0.0f;
824 float titleCharacterCount = 0.0f;
825 float titleBadgeIconGap = 0.0f;
826 float titleBadgeIconTopMargin = 0.0f;
827 float fontSize = 0.0f;
828 FloatDimension titleTextDimension(0.0f, 0.0f);
829 float totalWidth = 0.0f;
830 float titleHeight = 0.0f;
832 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin);
833 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_SIZE, __pToolbar->GetOrientation(), processingAnimationIconSize);
834 GET_SHAPE_CONFIG(HEADER::PROCESSING_ANIMATION_ICON_GAP, __pToolbar->GetOrientation(), processingAnimationIconGap);
836 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_ICON_GAP, __pToolbar->GetOrientation(), titleBadgeIconGap);
837 GET_SHAPE_CONFIG(HEADER::TITLE_BADGE_TOP_MARGIN, __pToolbar->GetOrientation(), titleBadgeIconTopMargin);
839 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
841 GET_SHAPE_CONFIG(HEADER::TITLE_TOP_MARGIN_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), headerTopMargin);
842 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), titleDisplayHeight);
846 GET_SHAPE_CONFIG(HEADER::TOP_MARGIN, __pToolbar->GetOrientation(), headerTopMargin);
847 GET_SHAPE_CONFIG(HEADER::TITLE_DISPLAY_HEIGHT, __pToolbar->GetOrientation(), titleDisplayHeight);
850 GET_SHAPE_CONFIG(HEADER::ICON_WIDTH, __pToolbar->GetOrientation(), iconWidth);
851 GET_SHAPE_CONFIG(HEADER::ICON_RIGHT_MARGIN, __pToolbar->GetOrientation(), iconRightMargin);
853 if (!__titleText.IsEmpty())
855 titleCharacterCount = __titleText.GetLength(); // alphabet count
857 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
859 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_SEGMENTED, __pToolbar->GetOrientation(), fontSize);
861 else if (style == TOOLBAR_TITLE && __pToolbar->GetDescriptionText() != L""
862 && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) == ANIMATION_STOPPED)
864 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE_WITH_DESCRIPTION, __pToolbar->GetOrientation(), fontSize);
868 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
878 __fontSize = fontSize;
880 __pTitleTextFont = __pToolbar->GetFallbackFont();
882 SysTryReturnVoidResult(NID_UI_CTRL, __pTitleTextFont, r, "[%s] Propagating.", GetErrorMessage(r));
884 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
886 __pTitleTextFont->GetTextExtent(__titleText, titleCharacterCount, titleTextDimension);
888 totalWidth = titleTextDimension.width; // pixel
889 titleHeight = titleTextDimension.height; // pixel
891 __titleRect.height = _FontImpl::GetInstance(*__pTitleTextFont)->GetLeadingF();
895 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
900 totalWidth += (pTitleIcon->GetWidthF() + iconRightMargin);
906 totalWidth += pTitleBadgeIcon->GetBoundsF().width + titleBadgeIconGap;
908 else if ((__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE)) != ANIMATION_STOPPED)
910 totalWidth += processingAnimationIconSize + processingAnimationIconGap;
913 if (totalWidth > usableArea.width)
915 __titleRect.width = titleTextDimension.width - (totalWidth - usableArea.width);
919 pCanvas->DrawBitmap(FloatPoint(usableArea.x, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
921 __titleRect.x = usableArea.x + pTitleIcon->GetWidthF() + iconRightMargin;
922 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
924 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
926 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
927 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + processingAnimationIconGap,
928 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
933 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + __titleRect.width + titleBadgeIconGap,
934 titleBadgeIconTopMargin));
939 __titleRect.x = usableArea.x;
940 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
942 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
944 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
945 usableArea.x + __titleRect.width + processingAnimationIconGap,
946 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
951 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + __titleRect.width + titleBadgeIconGap, titleBadgeIconTopMargin));
957 __titleRect.width = usableArea.width;
961 __titleRect.x = leftMargin + pTitleIcon->GetWidthF() + iconRightMargin;
962 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
964 if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_CENTER)
966 leftMargin = (__titleRect.width - titleTextDimension.width) / 2;
968 else if(__pTitleTextObject->GetAlignment() & TEXT_OBJECT_ALIGNMENT_RIGHT)
970 leftMargin = __titleRect.width - titleTextDimension.width - iconRightMargin * 2;
973 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
975 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
977 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
978 usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + processingAnimationIconGap,
979 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
984 pTitleBadgeIcon->SetPosition(FloatPoint(usableArea.x + (pTitleIcon->GetWidthF() + processingAnimationIconGap) + titleTextDimension.width + titleBadgeIconGap,
985 titleBadgeIconTopMargin));
988 __titleRect.width -= (pTitleIcon->GetWidthF() + iconRightMargin);
992 __titleRect.x = leftMargin;
993 __titleRect.y = headerTopMargin + (titleDisplayHeight - titleHeight) / 2;
995 if (__pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
997 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
998 leftMargin + titleTextDimension.width + processingAnimationIconGap,
999 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
1002 if (pTitleBadgeIcon)
1004 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + titleTextDimension.width + titleBadgeIconGap, titleBadgeIconTopMargin));
1011 if (pTitleIcon && __pToolbar->GetWaitingAnimationStatus(TOOLBAR_ANIMATION_POSITION_TITLE) != ANIMATION_STOPPED)
1013 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
1015 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
1017 leftMargin = (leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize)) / 2;
1019 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
1021 leftMargin = leftMargin + usableArea.width - (pTitleIcon->GetWidthF() + processingAnimationIconGap + processingAnimationIconSize);
1024 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
1026 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
1027 leftMargin + processingAnimationIconGap + processingAnimationIconSize,
1028 headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
1030 if (pTitleBadgeIcon)
1032 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin + processingAnimationIconGap + titleBadgeIconGap, titleBadgeIconTopMargin));
1035 else if (pTitleIcon)
1037 pTitleIcon->Scale(FloatDimension(iconWidth, iconWidth));
1039 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
1041 leftMargin = usableArea.width / 2;
1043 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
1045 leftMargin = usableArea.width - pTitleIcon->GetWidthF();
1048 pCanvas->DrawBitmap(FloatPoint(leftMargin, headerTopMargin + (titleDisplayHeight - pTitleIcon->GetHeightF()) / 2), *(pTitleIcon));
1052 if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_CENTER)
1054 leftMargin = (usableArea.width - (processingAnimationIconGap + processingAnimationIconSize))/ 2;
1056 else if(__pToolbar->GetTitleTextHorizontalAlignment() == ALIGNMENT_RIGHT)
1058 leftMargin = usableArea.width - (processingAnimationIconGap + processingAnimationIconSize);
1061 __pToolbar->SetWaitingAnimationPosition(TOOLBAR_ANIMATION_POSITION_TITLE,
1062 leftMargin, headerTopMargin + (titleDisplayHeight - processingAnimationIconSize) / 2);
1064 if (pTitleBadgeIcon)
1066 pTitleBadgeIcon->SetPosition(FloatPoint(leftMargin, titleBadgeIconTopMargin));
1077 _ToolbarPresenter::DrawTitleText(Canvas* pCanvas)
1079 TimerForTitleSlideInit();
1081 if (__titleText.IsEmpty())
1086 __pTitleTextObject->SetForegroundColor(__pToolbar->GetTitleTextColor(), 0, __pTitleTextObject->GetTextLength());
1087 __pTitleTextObject->SetBounds(__titleRect);
1088 //__pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1089 __pTitleTextObject->Compose();
1091 if (__pTitleTextObject->IsActionOn() == true)
1093 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
1095 DrawTitleTextDimBitmap();
1097 TimerForTitleSlideStart();
1101 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1108 _ToolbarPresenter::GetSelectedItemIndex(void) const
1110 return __pToolbarModel->GetSelectedItemIndex();
1114 _ToolbarPresenter::IsInitialDraw(void) const
1116 return __initialDraw;
1120 _ToolbarPresenter::IsTabEditModeEnabled(void) const
1122 return __tabEditEnabled;
1126 _ToolbarPresenter::SetDescriptionText(const String& description)
1128 result r = E_SUCCESS;
1130 float length = description.GetLength();
1131 float fontSize = 0.0f;
1133 wchar_t* tempString = const_cast<wchar_t*>(description.GetPointer());
1136 if (__pDescriptionTextObject != null)
1138 delete __pDescriptionTextObject;
1139 __pDescriptionTextObject = null;
1142 __pDescriptionTextObject = new (std::nothrow) TextObject();
1144 if (__pDescriptionTextObject == null)
1146 return E_OUT_OF_MEMORY;
1148 __pDescriptionTextObject->Construct();
1150 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1152 pSimpleText->SetTextShadowEnabled(true);
1153 pSimpleText->SetTextShadowOffset(FloatPoint(0.0f, 2.0f));
1155 __pDescriptionTextObject->AppendElement(*pSimpleText);
1156 __pDescriptionTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1157 __pDescriptionTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1159 GET_SHAPE_CONFIG(HEADER::DESCRIPTION_TEXT_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1161 __fontSize = fontSize;
1163 __pTextFont = __pToolbar->GetFallbackFont();
1164 r = GetLastResult();
1165 SysTryReturn(NID_UI_CTRL, __pTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1167 __pDescriptionTextObject->SetFont(__pTextFont, 0, __pDescriptionTextObject->GetTextLength());
1173 _ToolbarPresenter::SetItemSelected(int itemIndex, bool adjust)
1177 ToolbarStyle style = __pToolbar->GetStyle();
1179 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1181 if (itemIndex <= __pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX)
1183 SetItemFit(itemIndex);
1187 SetItemFit(__pToolbar->GetItemCount() - SEGMENTED_ITEM_MAX);
1192 return __pToolbarModel->SetSelectedItemIndex(itemIndex);
1196 _ToolbarPresenter::SetInitialDrawState(bool state)
1198 //DrawBackground(); // remove since 2.1
1199 __initialDraw = state;
1201 __titlePressed = false;
1202 __titleSliding = false;
1203 __tabEditEnabled = false;
1205 __firstLoadedItemIndex = 0;
1206 __lastLoadedItemIndex = 0;
1212 _ToolbarPresenter::SetTabEditModeEnabled(bool enable)
1214 __tabEditEnabled = enable;
1220 _ToolbarPresenter::SetTitleText(const String& title, HorizontalAlignment alignment)
1222 result r = E_SUCCESS;
1224 float length = title.GetLength();
1226 __titleText = String(title);
1227 wchar_t* tempString = const_cast<wchar_t*>(__titleText.GetPointer());
1230 if (__pTitleTextObject != null)
1232 delete __pTitleTextObject;
1233 __pTitleTextObject = null;
1236 __pTitleTextObject = new (std::nothrow) TextObject();
1238 if (__pTitleTextObject == null)
1240 return E_OUT_OF_MEMORY;
1242 __pTitleTextObject->Construct();
1243 __pTitleTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_NONE);
1245 TextSimple* pSimpleText = new (std::nothrow) TextSimple(tempString, length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1247 pSimpleText->SetTextShadowEnabled(true);
1248 pSimpleText->SetTextShadowOffset(FloatPoint(0.0f, 2.0f));
1250 __pTitleTextObject->AppendElement(*pSimpleText);
1251 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1253 __titleSliding = false;
1257 case ALIGNMENT_LEFT:
1258 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1260 case ALIGNMENT_CENTER:
1261 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER);
1263 case ALIGNMENT_RIGHT:
1264 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_RIGHT);
1267 __pTitleTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_LEFT);
1271 float fontSize = 0.0f;
1273 r = GET_SHAPE_CONFIG(HEADER::TITLE_FONT_SIZE, __pToolbar->GetOrientation(), fontSize);
1275 __fontSize = fontSize;
1277 __pTitleTextFont = __pToolbar->GetFallbackFont();
1278 r = GetLastResult();
1279 SysTryReturn(NID_UI_CTRL, __pTitleTextFont, r, r, "[%s] Propagating.", GetErrorMessage(r));
1281 __pTitleTextObject->SetFont(__pTitleTextFont, 0, __pTitleTextObject->GetTextLength());
1283 //__pTitleTextObject->Compose();
1289 _ToolbarPresenter::SetUsableAreaBounds(const FloatRectangle& rect)
1291 __toolbarUsableArea = rect;
1297 _ToolbarPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1299 ResetFlickAnimationTimer();
1301 SetFirstLoadedItemIndex();
1302 SetLastLoadedItemIndex();
1304 __touchInitiatedInToolbar = true;
1306 __currentTouchPosition = touchinfo.GetCurrentPosition();
1308 ToolbarStyle style = __pToolbar->GetStyle();
1310 if (__titleRect.Contains(__currentTouchPosition)
1311 && (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE))
1313 __titlePressed = true;
1317 __titlePressed = false;
1320 __pressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1322 if (__pressedItemIndex == -1)
1324 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1328 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1330 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1332 if (pLabel == pTempBadgeIcon)
1334 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1338 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1340 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1342 if (pLabel == pTempBadgeIcon)
1344 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED, false);
1351 _Button* pPressedButton = __pToolbar->GetItem(__pressedItemIndex);
1353 __initialPressesItemStatus = pPressedButton->GetButtonStatus();
1355 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1360 pPressedButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1365 __pToolbar->Invalidate(false);
1369 __pToolbar->Invalidate(true);
1376 _ToolbarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1378 if (!__touchInitiatedInToolbar)
1383 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1385 if (__titlePressed && __titleRect.Contains(touchPoint))
1387 if (__titleSliding == true)
1389 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
1390 __pTitleTextObject->Compose();
1392 __titleSliding = false;
1396 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT);
1397 __pTitleTextObject->Compose();
1399 __titleSliding = true;
1401 TimerForTitleSlideStart();
1405 SetFirstLoadedItemIndex();
1406 SetLastLoadedItemIndex();
1408 ToolbarStyle style = __pToolbar->GetStyle();
1410 __touchInitiatedInToolbar = false;
1412 int releasedItemIndex = __pToolbar->GetItemIndexFromPosition(touchPoint);
1414 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1416 __beingEdited = false;
1418 if (releasedItemIndex == -1)
1422 __pToolbar->DetachChild(*__pEditItem);
1428 if (__pressedItemIndex != -1)
1430 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus);
1435 __pToolbar->MoveItem(__editItemIndex, releasedItemIndex);
1437 AdjustItemPositionX(-__pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x); // move auto focus
1441 __pToolbar->DetachChild(*__pEditItem);
1450 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE)
1451 && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1453 if (__pressedItemIndex != -1)
1455 if (releasedItemIndex == __pressedItemIndex)
1457 if (__initialPressesItemStatus != _BUTTON_STATUS_DISABLED && __tabMoved != true)
1459 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1463 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1468 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1474 if (__pressedItemIndex != -1 && (releasedItemIndex != __pressedItemIndex))
1476 __pToolbar->GetItem(__pressedItemIndex)->SetButtonStatus(__initialPressesItemStatus, false);
1480 if (__pressedItemIndex != -1 && __initialPressesItemStatus != _BUTTON_STATUS_DISABLED)
1482 if (style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE
1483 || style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_SEGMENTED || style == TOOLBAR_TAB_LARGE)
1485 __pToolbar->SetItemSelected(releasedItemIndex, true, false);
1489 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetItem(releasedItemIndex));
1490 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1491 __pToolbar->GetItem(releasedItemIndex)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1496 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1500 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1502 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1504 if (pLabel == pTempBadgeIcon)
1506 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1508 if (buttonItemBounds.Contains(touchPoint))
1510 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(LEFT_BUTTON));
1511 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1514 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1518 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1520 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1522 if (pLabel == pTempBadgeIcon)
1524 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1526 if (buttonItemBounds.Contains(touchPoint))
1528 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, __pToolbar->GetButton(RIGHT_BUTTON));
1529 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_SELECTED, true);
1532 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL, false);
1540 __pToolbar->Invalidate(false);
1544 __pToolbar->Invalidate(true);
1554 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1555 int itemCount = __pToolbar->GetItemCount();
1557 for (int j = 0; j < itemCount; j++)
1559 if (__pToolbar->GetItem(j) != null && __pToolbar->GetItem(j)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1561 __pToolbar->GetItem(j)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1568 __pToolbar->Invalidate(false);
1572 __pToolbar->Invalidate(true);
1579 _ToolbarPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1581 if (!__touchInitiatedInToolbar)
1586 SetFirstLoadedItemIndex();
1587 SetLastLoadedItemIndex();
1589 ToolbarStyle style = __pToolbar->GetStyle();
1590 FloatPoint touchPoint = touchinfo.GetCurrentPosition();
1592 if (__pressedItemIndex == -1)
1594 _Label* pLabel = dynamic_cast<_Label*>(const_cast<_Control*>(&source));
1598 if (__pToolbar->GetButton(LEFT_BUTTON) != null && __pToolbar->GetButton(LEFT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1600 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(LEFT_BUTTON)->GetChild(0));
1602 if (pLabel == pTempBadgeIcon)
1604 FloatRectangle buttonItemBounds = __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF();
1606 if (buttonItemBounds.Contains(touchPoint))
1608 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1612 __pToolbar->GetButton(LEFT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1617 if (__pToolbar->GetButton(RIGHT_BUTTON) != null && __pToolbar->GetButton(RIGHT_BUTTON)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
1619 _Label* pTempBadgeIcon = dynamic_cast<_Label*>(__pToolbar->GetButton(RIGHT_BUTTON)->GetChild(0));
1621 if (pLabel == pTempBadgeIcon)
1623 FloatRectangle buttonItemBounds = __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF();
1625 if (buttonItemBounds.Contains(touchPoint))
1627 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1631 __pToolbar->GetButton(RIGHT_BUTTON)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1639 __pToolbar->Invalidate(false);
1643 __pToolbar->Invalidate(true);
1649 _Button* pCurrentButton = __pToolbar->GetItem(__pressedItemIndex);
1651 if (pCurrentButton == null)
1656 FloatRectangle itemBounds = pCurrentButton->GetBoundsF();
1658 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __pToolbar->GetItemCount() > SEGMENTED_ITEM_MAX)
1660 if (itemBounds.Contains(touchPoint))
1666 if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) && __beingEdited == true)
1668 DrawEditItem(touchinfo.GetCurrentPosition());
1674 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1678 if (__initialPressesItemStatus == _BUTTON_STATUS_DISABLED)
1683 if (itemBounds.Contains(touchPoint))
1685 pCurrentButton->SetButtonStatus(_BUTTON_STATUS_PRESSED);
1689 pCurrentButton->SetButtonStatus(__initialPressesItemStatus, false);
1693 pCurrentButton->Invalidate(false);
1698 float distance = (touchinfo.GetCurrentPosition()).x - __currentTouchPosition.x;
1700 FloatRectangle clientBounds = __pToolbar->GetBoundsF();
1702 __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1703 __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width);
1705 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
1707 if (clientBounds.width > __portraitSize.width)
1709 clientBounds.width = __portraitSize.width;
1714 if (clientBounds.width > __landscapeSize.width)
1716 clientBounds.width = __landscapeSize.width;
1720 __currentTouchPosition = touchinfo.GetCurrentPosition();
1722 _Button* pItem = null;
1723 FloatRectangle itemBounds;
1724 int itemCount = __pToolbar->GetItemCount();
1726 if (distance > 0) // right move
1728 pItem = __pToolbar->GetItem(0);
1734 itemBounds = pItem->GetBoundsF();
1736 if (itemBounds.x + distance >= 0.0f && !__beingEdited)
1738 distance = 0.0f - itemBounds.x;
1741 else if (distance < 0)
1743 pItem = __pToolbar->GetItem(itemCount - 1);
1750 itemBounds = pItem->GetBoundsF();
1752 if (itemBounds.x + itemBounds.width + distance <= clientBounds.width && !__beingEdited)
1754 distance = clientBounds.width - (itemBounds.x + itemBounds.width);
1760 if (distance > 0) // right move
1762 __tabSlideRight = false;
1764 if (__pToolbar->GetItem(__lastLoadedItemIndex - 1)->GetBoundsF().x <= __pEditItem->GetBoundsF().x)
1766 __tabSlideLeft = true;
1769 if (__tabSlideLeft && __pToolbar->GetItem(itemCount-1)->GetBoundsF().x + __pToolbar->GetItem(itemCount-1)->GetBoundsF().width > clientBounds.width)
1771 AdjustItemPositionX(-distance * 5); // move auto focus
1774 else if (distance < 0)
1776 __tabSlideLeft = false;
1778 if (__pToolbar->GetItem(__firstLoadedItemIndex + 1)->GetBoundsF().x >= __pEditItem->GetBoundsF().x)
1780 __tabSlideRight = true;
1783 if (__tabSlideRight && __pToolbar->GetItem(0)->GetBoundsF().x < 0.0f)
1785 AdjustItemPositionX(-distance * 5); // move auto focus
1791 AdjustItemPositionX(distance);
1801 _ToolbarPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
1803 __touchInitiatedInToolbar = false;
1804 __beingEdited = false;
1806 // Restore status of other buttons to _BUTTON_STATUS_NORMAL // this can be removed
1807 int itemCount = __pToolbar->GetItemCount();
1809 for (int i = 0; i < itemCount; i++)
1811 if (__pToolbar->GetItem(i) != null && __pToolbar->GetItem(i)->GetButtonStatus() == _BUTTON_STATUS_PRESSED)
1813 __pToolbar->GetItem(i)->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1819 __pToolbar->DetachChild(*__pEditItem);
1828 __pToolbar->Invalidate(false);
1832 __pToolbar->Invalidate(true);
1839 _ToolbarPresenter::OnChangeLayout(Tizen::Ui::_ControlOrientation orientation)
1841 ResetFlickAnimationTimer();
1847 _ToolbarPresenter::OnLongPressGestureDetected(void)
1849 if (__pToolbar->IsTabEditModeEnabled() == true)
1851 int longPressedItemIndex = __pToolbar->GetItemIndexFromPosition(__currentTouchPosition);
1853 if (longPressedItemIndex == -1)
1858 _Button* pButton = null;
1859 pButton = __pToolbar->GetItem(longPressedItemIndex);
1860 SysTryReturn(NID_UI_CTRL, pButton, true, E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a button");
1862 if (pButton->GetButtonStatus() == _BUTTON_STATUS_DISABLED)
1867 __editItemIndex = longPressedItemIndex;
1868 __beingEdited = true;
1870 pButton->SetButtonStatus(_BUTTON_STATUS_NORMAL);
1872 FloatRectangle itemBounds = pButton->GetBoundsF();
1876 __pToolbar->DetachChild(*__pEditItem);
1882 __pEditItem = _Label::CreateLabelN();
1883 SysTryCatch(NID_UI_CTRL, __pEditItem, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1885 Canvas* pCanvas = pButton->GetCanvasN();
1886 SysTryCatch(NID_UI_CTRL, pCanvas, , E_INVALID_STATE, "[E_INVALID_STATE] Unable to retrieve a Canvas.");
1888 Bitmap* pEditItemBitmap = new (std::nothrow) Bitmap();
1889 result r = pEditItemBitmap->Construct(*pCanvas, FloatRectangle(0.0f, 0.0f, itemBounds.width, itemBounds.height));
1893 delete pEditItemBitmap;
1894 pEditItemBitmap = null;
1901 __pEditItem->SetBounds(itemBounds);
1902 __pEditItem->SetBackgroundBitmap(*pEditItemBitmap);
1905 delete pEditItemBitmap;
1907 __pToolbar->AttachChild(*__pEditItem);
1908 __pToolbar->SetChildAlwaysOnTop(*__pEditItem);
1926 _ToolbarPresenter::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1928 ToolbarStyle style = __pToolbar->GetStyle();
1930 if (!(style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE) || __pToolbar->GetItemCount() <= SEGMENTED_ITEM_MAX || __beingEdited == true || __tabMoved == false)
1935 if (gesture.GetDirection() != _FLICK_DIRECTION_RIGHT && gesture.GetDirection() != _FLICK_DIRECTION_LEFT)
1940 float distanceX = 0.0f;
1941 float distanceY = 0.0f;
1942 float xPosition = 0.0f;
1943 float itemsBeyondScreen = 0.0f;
1945 gesture.GetDistance(distanceX, distanceY);
1946 SetFirstLoadedItemIndex();
1947 SetLastLoadedItemIndex();
1948 int itemCount = __pToolbar->GetItemCount();
1949 float itemWidth = __pToolbar->GetItem(0)->GetBoundsF().width;
1951 if (distanceX < 0) //left
1953 itemsBeyondScreen = (itemCount - 1) - __lastLoadedItemIndex;
1954 xPosition = __pToolbar->GetItem(__lastLoadedItemIndex)->GetBoundsF().x;
1955 if (xPosition < (3 * itemWidth))
1957 __flickDistance = xPosition - (4 * itemWidth);
1962 itemsBeyondScreen = __firstLoadedItemIndex;
1963 xPosition = __pToolbar->GetItem(__firstLoadedItemIndex)->GetBoundsF().x;
1966 __flickDistance = -xPosition;
1971 int itemMaxCount = 4;
1973 if (itemsBeyondScreen >= (itemMaxCount - 1))
1975 __flickDistance = (3 * itemWidth);
1979 __flickDistance = (itemsBeyondScreen * itemWidth);
1982 if (distanceX < 0) //Left flick
1984 __flickMove = 0.006f;
1987 else if (distanceX > 0) //Right flick
1989 __flickMove = 0.006f;
1990 __flickDistance = -(__flickDistance);
1996 __flickDistance = 0.0f;
1998 __moveDistance = 0.0f;
2001 StartFlickAnimationTimer();
2007 _ToolbarPresenter::OnTimerExpired(Timer& timer)
2009 Timer* onTimer = &timer;
2011 if (onTimer == __pTitleSlideTimer)
2013 TimerForTitleSlideTimeout();
2016 if (onTimer == __pFlickAnimationTimer)
2018 StartFlickAnimation();
2025 _ToolbarPresenter::OnDrawFocus(void)
2031 _ToolbarPresenter::OnChildControlFocusMoved(const _Control& control)
2037 _ToolbarPresenter::IsChildControlFocusManage(void) const
2043 _ToolbarPresenter::OnFocusableStateChanged(bool focusalbeState)
2049 _ToolbarPresenter::OnFocusModeStateChanged(void)
2055 _ToolbarPresenter::OnFocusGained(const _Control& source)
2057 //__focusPrevStatus = __pButton->GetButtonStatus();
2058 //__pButton->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED);
2059 //__pButton->Invalidate();
2065 _ToolbarPresenter::OnFocusLost(const _Control& source)
2067 //__pButton->SetButtonStatus(__focusPrevStatus);
2068 //__pButton->Invalidate();
2074 _ToolbarPresenter::TimerForTitleSlideInit(void)
2076 result r = E_SUCCESS;
2078 if (__pTitleSlideTimer != null)
2080 delete __pTitleSlideTimer;
2081 __pTitleSlideTimer = null;
2088 _ToolbarPresenter::TimerForTitleSlideStart(void)
2090 result r = E_SUCCESS;
2092 if (__pTitleSlideTimer == null)
2094 __pTitleSlideTimer = new (std::nothrow) Timer();
2095 if (__pTitleSlideTimer == null)
2097 r = E_OUT_OF_MEMORY;
2101 r = __pTitleSlideTimer->Construct(*this);
2105 delete __pTitleSlideTimer;
2110 r = __pTitleSlideTimer->Start(100);
2122 _ToolbarPresenter::TimerForTitleSlideTimeout(void)
2124 Canvas* pCanvas = __pToolbar->GetCanvasN();
2125 SysTryReturnResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] pCanvas is invalid!");
2127 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
2128 pCanvas->Clear(__titleRect);
2130 if (__pTitleBackgroundBitmap)
2132 pCanvas->DrawBitmap(CoordinateSystem::AlignToDevice(__titleRect), *__pTitleBackgroundBitmap);
2135 if (__pTitleTextObject->IsChanged())
2137 DrawTitleText(pCanvas);
2140 if (__pTitleTextObject->IsActionOn() == true)
2142 __pTitleTextObject->DrawWithOffset(*_CanvasImpl::GetInstance(*pCanvas));
2144 DrawTitleTextDimBitmap();
2146 if (__pTitleTextObject->GetRepeatCount() < 3)
2148 TimerForTitleSlideStart();
2153 __pTitleTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
2162 _ToolbarPresenter::DrawTitleTextDimBitmap(void)
2164 if (__pToolbar->IsUserBackgroundBitmap())
2169 Canvas* pCanvas = __pToolbar->GetCanvasN();
2171 if (pCanvas == null)
2173 SysLog(NID_UI_CTRL, "Cannot get a canvas.");
2177 float textDimWidth = 0.0f;
2178 float textDimHeight = 0.0f;
2179 float leftMargin = 0.0f;
2181 GET_SHAPE_CONFIG(HEADER::TAB_TEXT_DIM_WIDTH, __pToolbar->GetOrientation(), textDimWidth);
2182 GET_SHAPE_CONFIG(HEADER::LEFT_MARGIN, __pToolbar->GetOrientation(), leftMargin);
2184 ToolbarStyle style = __pToolbar->GetStyle();
2186 if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE)
2188 GET_SHAPE_CONFIG(HEADER::TITLE_HEIGHT_WITH_SEGMENTED_ITEM, __pToolbar->GetOrientation(), textDimHeight);
2192 if (__pToolbar->GetDescriptionText() != L"")
2194 textDimHeight = __titleRect.height + __titleRect.y;
2198 textDimHeight = __pToolbar->GetBoundsF().height;
2202 //Color titleTextDimColor;
2203 //GET_COLOR_CONFIG(HEADER::TITLE_TEXT_DIM_NORMAL, titleTextDimColor);
2205 Bitmap* pTitleTextDimLeftBitmap = null;
2206 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_LEFT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimLeftBitmap);
2208 Bitmap* pReColorTitleTextDimLeftBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimLeftBitmap,
2209 Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
2211 if (pReColorTitleTextDimLeftBitmap)
2213 FloatRectangle bounds = FloatRectangle(0.0f, 0.0f, textDimWidth, textDimHeight);
2215 if (__pToolbar->GetTitleIcon() != null)
2217 bounds.x += __titleRect.x;
2220 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimLeftBitmap))
2222 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimLeftBitmap);
2226 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimLeftBitmap,
2227 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimLeftBitmap->GetWidthF(), pReColorTitleTextDimLeftBitmap->GetHeightF()));
2230 delete pReColorTitleTextDimLeftBitmap;
2233 Bitmap* pTitleTextDimRightBitmap = null;
2234 GET_BITMAP_CONFIG_N(HEADER::TITLE_TEXT_DIM_EFFECT_RIGHT, BITMAP_PIXEL_FORMAT_ARGB8888, pTitleTextDimRightBitmap);
2236 Bitmap* pReColorTitleTextDimRightBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTitleTextDimRightBitmap,
2237 Color::GetColor(COLOR_ID_MAGENTA), __pToolbar->GetColor());
2239 if (pReColorTitleTextDimRightBitmap)
2241 FloatRectangle bounds = FloatRectangle(__titleRect.width, 0.0f, textDimWidth, textDimHeight);
2243 if (__pToolbar->GetTitleIcon() != null)
2245 bounds.x += (__titleRect.x - leftMargin);
2248 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pReColorTitleTextDimRightBitmap))
2250 pCanvas->DrawNinePatchedBitmap(bounds, *pReColorTitleTextDimRightBitmap);
2254 pCanvas->DrawBitmap(bounds, *pReColorTitleTextDimRightBitmap,
2255 FloatRectangle(0.0f, 0.0f, pReColorTitleTextDimRightBitmap->GetWidthF(), pReColorTitleTextDimRightBitmap->GetHeightF()));
2258 delete pReColorTitleTextDimRightBitmap;
2267 _ToolbarPresenter::AdjustItemPositionX(float distance)
2270 int itemCount = __pToolbar->GetItemCount();
2271 _Button* pItem = __pToolbar->GetItem(index);
2273 FloatRectangle itemBounds(0.0f, 0.0f, 0.0f, 0.0f);
2281 itemBounds = __pToolbar->GetItem(0)->GetBoundsF();
2282 if (itemBounds.x + distance > 0.0f)
2289 itemBounds = __pToolbar->GetItem(itemCount - 4)->GetBoundsF();
2290 if (itemBounds.x + distance < 0.0f)
2296 while (pItem != null)
2298 FloatRectangle bounds = pItem->GetBoundsF();
2299 bounds.x += distance;
2300 pItem->SetBounds(bounds);
2303 if (index < itemCount)
2305 pItem = __pToolbar->GetItem(index);
2317 _ToolbarPresenter::GetTitleTextBoundsF(void) const
2323 _ToolbarPresenter::GetDescriptionBoundsF(void) const
2325 return __descriptionRect;
2329 _ToolbarPresenter::_SetModel(const _ToolbarModel& toolbarModel)
2331 __pToolbarModel = const_cast<_ToolbarModel*>(&toolbarModel);
2337 _ToolbarPresenter::OnFontChanged(Font* pFont)
2339 __pTextFont = pFont;
2340 __pTitleTextFont = pFont;
2346 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, int& size)
2348 style = __fontStyle;
2349 size = _CoordinateSystemUtils::ConvertToInteger(__fontSize);
2355 _ToolbarPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2357 style = __fontStyle;
2364 _ToolbarPresenter::OnAncestorVisibleStateChanged(const _Control& control)
2366 if (__pTitleTextObject != null)
2368 __pTitleTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
2369 __pTitleTextObject->Compose();
2372 __titleSliding = false;
2378 _ToolbarPresenter::SetFontInfo(unsigned long style, float size)
2380 __fontStyle = style;
2387 _ToolbarPresenter::StartFlickAnimation(void)
2389 float distance = CalculateProgress(__flickMove);
2391 __moveDistance = -(__flickDistance * distance);
2392 __flickDistance = (__flickDistance + __moveDistance);
2393 __flickMove = __flickMove + 0.006;
2396 if (__flickFlag <= FLICK_ANIMATION_COUNT)
2398 StartFlickAnimationTimer();
2402 ResetFlickAnimationTimer();
2403 SetItemFit(__firstLoadedItemIndex);
2406 AdjustItemPositionX(__moveDistance);
2408 SetFirstLoadedItemIndex();
2409 SetLastLoadedItemIndex();
2417 _ToolbarPresenter::StartFlickAnimationTimer(void)
2419 result r = E_SUCCESS;
2421 if (__pFlickAnimationTimer == null)
2423 __pFlickAnimationTimer = new (std::nothrow) Timer();
2424 SysTryReturn(NID_UI_CTRL, (__pFlickAnimationTimer != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2426 r = __pFlickAnimationTimer->Construct(*this);
2427 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2431 __pFlickAnimationTimer->Cancel();
2434 r = __pFlickAnimationTimer->Start(FLICK_ANIMATION_TIMER_PERIOD);
2435 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2440 ResetFlickAnimationTimer();
2445 _ToolbarPresenter::ResetFlickAnimationTimer(void)
2447 if (__pFlickAnimationTimer)
2449 delete __pFlickAnimationTimer;
2450 __pFlickAnimationTimer = null;
2453 __moveDistance = 0.0f;
2459 _ToolbarPresenter::SetFirstLoadedItemIndex(void)
2461 int itemCount = __pToolbar->GetItemCount();
2463 for (int i = 0; i < itemCount; i++)
2465 if (__pToolbar->GetItem(i)->GetBoundsF().x + (__pToolbar->GetItem(i)->GetBoundsF().width / 2) <= __pToolbar->GetItem(i)->GetBoundsF().width)
2467 __firstLoadedItemIndex = i;
2475 _ToolbarPresenter::GetFirstLoadedItemIndex(void)
2477 return __firstLoadedItemIndex;
2481 _ToolbarPresenter::SetLastLoadedItemIndex(void)
2484 int itemCount = __pToolbar->GetItemCount();
2486 if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT)
2488 width = __portraitSize.width;
2492 width = __landscapeSize.width;
2495 for (int i = 0; i < itemCount; i++)
2497 float X = __pToolbar->GetItem(i)->GetBoundsF().x;
2499 if ((X + (__pToolbar->GetItem(i)->GetBoundsF().width / 2)) < width)
2501 __lastLoadedItemIndex = i;
2509 _ToolbarPresenter::CalculateProgress(float timeProgress) const
2511 const float segments[3][3] = {{0.0f, 0.01f, 0.45f}, {0.45f, 0.80f, 0.908f}, {0.908f, 0.9999f, 1.0f}};
2512 float loc_5 = timeProgress / 1;
2513 int loc_6 = 3; //Length of the segments array
2514 int loc_9 = (int)floor(loc_6 * loc_5);
2521 float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
2524 for (int i = 0; i < 3; i++)
2526 loc_8[i] = segments[loc_9][i];
2529 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])));
2535 _ToolbarPresenter::SetItemFit(int index)
2542 FloatPoint pt(0.0f, 0.0f);
2543 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
2545 float fitDistance = 0.0f;
2546 int itemCount = __pToolbar->GetItemCount();
2548 _Button* pItem = __pToolbar->GetItem(index);
2549 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2551 bounds = pItem->GetBoundsF();
2553 fitDistance = -bounds.x;
2555 for (int i = 0; i < itemCount; i++)
2557 pItem = __pToolbar->GetItem(i);
2558 SysTryReturnVoidResult(NID_UI_CTRL, pItem, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
2560 bounds = pItem->GetBoundsF();
2561 bounds.x = bounds.x + fitDistance;
2562 pItem->SetBounds(bounds);
2565 SetFirstLoadedItemIndex();
2566 SetLastLoadedItemIndex();
2574 _ToolbarPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2580 _ToolbarPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2586 _ToolbarPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2591 }}} // Tizen::Ui::Controls