From: Myung Jin Kim Date: Tue, 9 Jul 2013 17:53:15 +0000 (+0900) Subject: apply divider visualelement X-Git-Tag: accepted/tizen/20130924.144426~1^2~106^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ce86cb4a16845ed4c80221b1905af6f2d5c22f7;p=platform%2Fframework%2Fnative%2Fuifw.git apply divider visualelement Change-Id: I7cc44115d155f9d74bff68776371832049a33430 --- diff --git a/src/ui/controls/FUiCtrl_Toolbar.cpp b/src/ui/controls/FUiCtrl_Toolbar.cpp index 862c8ec..bfb7597 100644 --- a/src/ui/controls/FUiCtrl_Toolbar.cpp +++ b/src/ui/controls/FUiCtrl_Toolbar.cpp @@ -8433,7 +8433,7 @@ _Toolbar::RearrangeButtonItems(void) { if (__pButtonItems[RIGHT_BUTTON]) { - __pItems.at(0)->SetBounds(FloatRectangle(dividerWidth + tabLeftMargin + iconSize + itemButtonLeftGap, (GetSizeF().height - itemHeight) / 2, blockWidth[0] - dividerWidth, itemHeight)); + __pItems.at(0)->SetBounds(FloatRectangle(dividerWidth + tabLeftMargin + iconSize + itemButtonLeftGap, (GetSizeF().height - itemHeight) / 2, blockWidth[0] - dividerWidth * 2, itemHeight)); } else { diff --git a/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp b/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp index 26559e9..53f5529 100644 --- a/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp +++ b/src/ui/controls/FUiCtrl_ToolbarPresenter.cpp @@ -65,6 +65,7 @@ _ToolbarPresenter::_ToolbarPresenter(void) , __pTextFont(null) , __pDescriptionTextObject(null) , __pTitleTextObject(null) + , __pBouncingEffectVe(null) , __flickAnimation() , __moveDistance(0.0f) , __flickMove(0.0f) @@ -129,6 +130,13 @@ _ToolbarPresenter::~_ToolbarPresenter(void) delete __pTitleTextObject; __pTitleTextObject = null; } + + if (__pBouncingEffectVe) + { + __pBouncingEffectVe->RemoveAllAnimations(); + __pBouncingEffectVe->Destroy(); + __pBouncingEffectVe = null; + } } result @@ -194,55 +202,8 @@ _ToolbarPresenter::Draw(void) return E_SYSTEM; } - float buttonItemGap = 0.0f; - float dividerBaseHeight = 0.0f; - float dividerHeight = 0.0f; - - float footerButtonItemWidth = 0.0f; - float footerButtonItemHeight = 0.0f; float fontSize = 0.0f; - float dividerTopMargin = 0.0f; - float segmentedItemHeight = 0.0f; - - FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height); - - int itemCount = __pToolbar->GetItemCount(); - - __portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF(); - __landscapeSize = FloatDimension(__portraitSize.height, __portraitSize.width); - - if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) - { - if (bounds.width > __portraitSize.width) - { - bounds.width = __portraitSize.width; - } - } - else - { - if (bounds.width > __landscapeSize.width) - { - bounds.width = __landscapeSize.width; - } - } - - GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), buttonItemGap); - - if (style == TOOLBAR_TAB_LARGE) - { - GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight); - } - else - { - GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight); - } - - GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, __pToolbar->GetOrientation(), segmentedItemHeight); - - GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_WIDTH, __pToolbar->GetOrientation(), footerButtonItemWidth); - GET_SHAPE_CONFIG(FOOTER::BUTTON_ITEM_HEIGHT, __pToolbar->GetOrientation(), footerButtonItemHeight); - if (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE) { if (__pTitleBackgroundBitmap) @@ -293,6 +254,49 @@ _ToolbarPresenter::Draw(void) DrawTitleText(pCanvas); } + DrawDivider(); + + if (__initialDraw) + { + if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE + || style == TOOLBAR_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) + && __pToolbar->GetItemCount() > 0 && __pToolbarModel->GetSelectedItemIndex() == -1) + { + int firstEnabledItemIndex = __pToolbar->GetFirstEnabledItemIndex(); + + if(firstEnabledItemIndex != -1) + { + __pToolbar->SetItemSelected(firstEnabledItemIndex, true, false); + } + } + + __initialDraw = false; + } + + delete pCanvas; + + return E_SUCCESS; +} + +void +_ToolbarPresenter::DrawDivider(void) +{ + ToolbarStyle style = __pToolbar->GetStyle(); + + if (style == TOOLBAR_SOFTKEY) + { + return ; + } + + float buttonItemGap = 0.0f; + float dividerBaseHeight = 0.0f; + float dividerHeight = 0.0f; + float dividerTopMargin = 0.0f; + + int itemCount = __pToolbar->GetItemCount(); + + GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), buttonItemGap); + if (style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE || style == TOOLBAR_TAB_WITH_TITLE) { GET_SHAPE_CONFIG(HEADER::SEGMENTED_ITEM_HEIGHT, __pToolbar->GetOrientation(), dividerBaseHeight); @@ -303,22 +307,83 @@ _ToolbarPresenter::Draw(void) GET_SHAPE_CONFIG(HEADER::HEIGHT, __pToolbar->GetOrientation(), dividerBaseHeight); } + if (style == TOOLBAR_TAB_LARGE) + { + GET_SHAPE_CONFIG(HEADER::TAB_LARGE_DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight); + } + else + { + GET_SHAPE_CONFIG(HEADER::DIVIDER_HEIGHT, __pToolbar->GetOrientation(), dividerHeight); + } + + FloatRectangle bounds(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height); + + if (__pToolbar->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT) + { + if (bounds.width > __portraitSize.width) + { + bounds.width = __portraitSize.width; + } + } + else + { + if (bounds.width > __landscapeSize.width) + { + bounds.width = __landscapeSize.width; + } + } + + Canvas * pCanvas = null; + int Z_ORDER_GROUP_CONTROL = 2001; + + if (__pBouncingEffectVe == null) + { + __pBouncingEffectVe = new (std::nothrow) VisualElement(); + SysTryReturnVoidResult(NID_UI_CTRL, __pBouncingEffectVe, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + + __pBouncingEffectVe->Construct(); + __pBouncingEffectVe->SetName(L"BouncingEffect"); + } + + __pBouncingEffectVe->SetBounds(FloatRectangle(0.0f, 0.0f, __pToolbar->GetBoundsF().width, __pToolbar->GetBoundsF().height)); + __pBouncingEffectVe->SetShowState(true); + __pBouncingEffectVe->SetImplicitAnimationEnabled(false); + + _VisualElementImpl::GetInstance(*__pBouncingEffectVe)->SetZOrderGroup(Z_ORDER_GROUP_CONTROL + 1); + __pToolbar->GetVisualElement()->AttachChild(*__pBouncingEffectVe); + + pCanvas = __pBouncingEffectVe->GetCanvasN(); + + if (!pCanvas) + { + __pBouncingEffectVe->Destroy(); + __pBouncingEffectVe = null; + + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return; + } + + Color backgroundColor(0, 0, 0, 0); + pCanvas->SetBackgroundColor(backgroundColor); + pCanvas->Clear(); + if (style == TOOLBAR_TITLE || style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) { if (__pToolbar->GetButton(RIGHT_BUTTON)) { if (__pToolbar->GetButton(LEFT_BUTTON)) { - DrawDivider(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, + DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); - DrawDivider(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap + DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } else { - DrawDivider(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, + DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } } @@ -326,7 +391,7 @@ _ToolbarPresenter::Draw(void) { if (__pToolbar->GetButton(LEFT_BUTTON)) { - DrawDivider(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap, + DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width - buttonItemGap, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } } @@ -335,18 +400,17 @@ _ToolbarPresenter::Draw(void) { if (__pToolbar->GetButton(RIGHT_BUTTON)) { - DrawDivider(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, + DrawDividerLine(FloatPoint(bounds.width - __pToolbar->GetButton(RIGHT_BUTTON)->GetBoundsF().width - buttonItemGap, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } if (__pToolbar->GetButton(LEFT_BUTTON)) { - DrawDivider(FloatPoint(__pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width, + DrawDividerLine(FloatPoint(__pToolbar->GetButton(LEFT_BUTTON)->GetBoundsF().width, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } } - if (itemCount == 1) { ; // empty @@ -357,7 +421,7 @@ _ToolbarPresenter::Draw(void) { for (int i = 0; i < itemCount - 1 ; i++) { - DrawDivider(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width, + DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width, dividerTopMargin + (dividerBaseHeight - dividerHeight) / 2), pCanvas); } } @@ -365,32 +429,15 @@ _ToolbarPresenter::Draw(void) { for (int i = 0; i < itemCount - 1 ; i++) { - DrawDivider(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width, + DrawDividerLine(FloatPoint(__pToolbar->GetItem(i)->GetBoundsF().x + __pToolbar->GetItem(i)->GetBoundsF().width, (__pToolbar->GetBoundsF().height - dividerHeight) / 2), pCanvas); } } } - if (__initialDraw) - { - if ((style == TOOLBAR_TAB || style == TOOLBAR_TAB_WITH_TITLE || style == TOOLBAR_TAB_LARGE - || style == TOOLBAR_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED || style == TOOLBAR_HEADER_SEGMENTED_WITH_TITLE) - && __pToolbar->GetItemCount() > 0 && __pToolbarModel->GetSelectedItemIndex() == -1) - { - int firstEnabledItemIndex = __pToolbar->GetFirstEnabledItemIndex(); - - if(firstEnabledItemIndex != -1) - { - __pToolbar->SetItemSelected(firstEnabledItemIndex, true, false); - } - } - - __initialDraw = false; - } - delete pCanvas; - return E_SUCCESS; + return; } void @@ -613,20 +660,15 @@ _ToolbarPresenter::DrawEditItem(const FloatPoint& point) } void -_ToolbarPresenter::DrawDivider(const FloatPoint& point, Canvas* pCanvas) +_ToolbarPresenter::DrawDividerLine(const FloatPoint& point, Canvas* pCanvas) { - ToolbarStyle style = __pToolbar->GetStyle(); - - if (style == TOOLBAR_SOFTKEY) - { - return ; - } - float dividerWidth = 0.0f; float dividerHeight = 0.0f; Color dividerLeftColor; //Color dividerRightColor; + ToolbarStyle style = __pToolbar->GetStyle(); + GET_SHAPE_CONFIG(HEADER::DIVIDER_WIDTH, __pToolbar->GetOrientation(), dividerWidth); if (style == TOOLBAR_TAB_LARGE) @@ -670,11 +712,6 @@ _ToolbarPresenter::DrawDivider(const FloatPoint& point, Canvas* pCanvas) pCanvas->DrawLine(FloatPoint(point.x, point.y), FloatPoint(point.x, point.y + dividerHeight)); - //pCanvas->SetForegroundColor(dividerRightColor); - //pCanvas->SetLineWidth(dividerWidth/2); - - //pCanvas->DrawLine(FloatPoint(point.x + dividerWidth, point.y), FloatPoint(point.x + dividerWidth, point.y + dividerHeight)); - return; } diff --git a/src/ui/inc/FUiCtrl_ToolbarPresenter.h b/src/ui/inc/FUiCtrl_ToolbarPresenter.h index fc381cb..f9edb74 100644 --- a/src/ui/inc/FUiCtrl_ToolbarPresenter.h +++ b/src/ui/inc/FUiCtrl_ToolbarPresenter.h @@ -66,11 +66,13 @@ public: void DrawBackground(void); + void DrawDivider(void); + void DrawDescriptionText(void); void DrawEditItem(const Tizen::Graphics::FloatPoint& point); - void DrawDivider(const Tizen::Graphics::FloatPoint& point, Tizen::Graphics::Canvas* pCanvas); + void DrawDividerLine(const Tizen::Graphics::FloatPoint& point, Tizen::Graphics::Canvas* pCanvas); void DrawItems(void); @@ -208,6 +210,8 @@ private: Tizen::Graphics::_Text::TextObject* __pTitleTextObject; + Tizen::Ui::Animations::VisualElement* __pBouncingEffectVe; + _FlickAnimation __flickAnimation; static const int FLICK_ANIMATION_TIMER_PERIOD = 3;