From 64cabb0ad4afc8eee95dc36d410c88705016731f Mon Sep 17 00:00:00 2001 From: Bhavya Kumili Date: Mon, 24 Jun 2013 15:50:24 +0530 Subject: [PATCH] Modified calculation of visualelement bounds for EditDate while animation Change-Id: Ie8f6d77434b03881ce23907ac3831a429ca4eef3 --- src/ui/controls/FUiCtrl_EditDatePresenter.cpp | 61 ++++++++------------------ src/ui/inc/FUi_ResourceEditDateConfig.h | 1 + src/ui/resource/FUi_ResourceEditDateConfig.cpp | 2 +- 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp index bd40ac4..09b2d37 100644 --- a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp @@ -724,6 +724,9 @@ result _EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId) { Color textColor; + float contentTextMargin; + + GET_SHAPE_CONFIG(EDITDATE::CONTENT_TEXT_MARGIN, __pEditDate->GetOrientation(), contentTextMargin); if (!__pEditDate->IsEnabled()) { @@ -745,10 +748,10 @@ _EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const DrawContentBitmap(canvas, bounds, boxId); FloatRectangle drawAreaBounds(0.0f, 0.0f, 0.0f, 0.0f); - drawAreaBounds.x = bounds.x + 2.0f; - drawAreaBounds.y = bounds.y + 2.0f; - drawAreaBounds.width = bounds.width - 4.0f; - drawAreaBounds.height = bounds.height - 4.0f; + drawAreaBounds.x = bounds.x + contentTextMargin; + drawAreaBounds.y = bounds.y + contentTextMargin; + drawAreaBounds.width = bounds.width - (contentTextMargin * 2.0f); + drawAreaBounds.height = bounds.height - (contentTextMargin * 2.0f); TextSimple* pSimpleText = null; pSimpleText = new (std::nothrow)TextSimple((const_cast (text.GetPointer())), text.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); @@ -1321,6 +1324,7 @@ _EditDatePresenter::Animate(void) String yearString; String dayString; String newValue; + FloatPoint textPoint; TextSimple* pOldSimpleText = null; TextSimple* pNewSimpleText = null; @@ -1353,7 +1357,6 @@ _EditDatePresenter::Animate(void) FloatDimension newTextDim; FloatDimension oldTextDim; - FloatPoint textPoint; VisualElement* pNewVisualElement = null; VisualElement* pOldVisualElement = null; VisualElement* pEditDateElement = null; @@ -1362,9 +1365,11 @@ _EditDatePresenter::Animate(void) Canvas *pCanvas = null; Color contentBgColor; Color textPressedColor; + float contentTextMargin; GET_COLOR_CONFIG(EDITTIME::CONTENT_BG_PRESSED, contentBgColor); GET_COLOR_CONFIG(EDITTIME::TEXT_PRESSED, textPressedColor); + GET_SHAPE_CONFIG(EDITDATE::CONTENT_TEXT_MARGIN, __pEditDate->GetOrientation(), contentTextMargin); __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim); __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim); @@ -1428,37 +1433,10 @@ _EditDatePresenter::Animate(void) pNewVisualElement->SetShowState(true); pOldVisualElement->SetShowState(true); - __pContentProvider->SetBounds(FloatRectangle((rect.x + 2.0f), (rect.y + 2.0f), (rect.width - 4.0f), (rect.height - 4.0f))); - textPoint.x = (__pContentProvider->GetBounds().width - newTextDim.width) / 2.0f; - textPoint.y = (__pContentProvider->GetBounds().height - newTextDim.height) / 2.0f; - - if (textPoint.x < 0) - { - textPoint.x = 0.0f; - newTextDim.width = __pContentProvider->GetBounds().width; - } - - if (textPoint.y < 0) - { - textPoint.y = 0.0f; - } + __pContentProvider->SetBounds(FloatRectangle((rect.x + contentTextMargin), (rect.y + contentTextMargin), (rect.width - (contentTextMargin * 2.0f)), (rect.height - (contentTextMargin * 2.0f)))); - pNewVisualElement->SetBounds(FloatRectangle(textPoint.x, oldTextDim.height, newTextDim.width, newTextDim.height)); - textPoint.x = (__pContentProvider->GetBounds().width - oldTextDim.width) / 2.0f; - textPoint.y = (__pContentProvider->GetBounds().height - oldTextDim.height) / 2.0f; - - if (textPoint.x < 0) - { - textPoint.x = 0.0f; - oldTextDim.width = __pContentProvider->GetBounds().width; - } - - if (textPoint.y < 0) - { - textPoint.y = 0.0f; - } - - pOldVisualElement->SetBounds(FloatRectangle(textPoint.x, textPoint.y, oldTextDim.width, oldTextDim.height)); + pNewVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height)); + pOldVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height)); pCanvas = pEditDateElement->GetCanvasN(__pContentProvider->GetBounds()); pCanvas->SetBackgroundColor(contentBgColor); @@ -1467,7 +1445,6 @@ _EditDatePresenter::Animate(void) pCanvas = null; pEditDateElement->AttachChild(*__pContentProvider); - __pContentProvider->AttachChild(*pOldVisualElement); __pContentProvider->AttachChild(*pNewVisualElement); @@ -1476,8 +1453,8 @@ _EditDatePresenter::Animate(void) pNewBoundsAnimation->SetDuration(300); pNewBoundsAnimation->SetPropertyName("bounds.position"); - pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, oldTextDim.height * 1.0f))); - pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, 0.0f))); + pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x, oldTextDim.height))); + pNewBoundsAnimation->SetEndValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x, 0.0f))); pNewBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); pOldBoundsAnimation = new (std::nothrow) VisualElementPropertyAnimation(); @@ -1485,8 +1462,8 @@ _EditDatePresenter::Animate(void) pOldBoundsAnimation->SetDuration(300); pOldBoundsAnimation->SetPropertyName("bounds.position"); - pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, 0.0f))); - pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x * 1.0f, oldTextDim.height * -1.0f))); + pOldBoundsAnimation->SetStartValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x, 0.0f))); + pOldBoundsAnimation->SetEndValue(Variant(FloatPoint(pOldVisualElement->GetBounds().x, oldTextDim.height * -1.0f))); pOldBoundsAnimation->SetVisualElementAnimationStatusEventListener(this); pOldSimpleText = new (std::nothrow)TextSimple((const_cast (__lastSelectedValue.GetPointer())), __lastSelectedValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); @@ -1507,7 +1484,7 @@ _EditDatePresenter::Animate(void) __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength()); - __textObject.SetBounds(pCanvas->GetBounds()); + __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height)); __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas)); delete pCanvas; @@ -1531,7 +1508,7 @@ _EditDatePresenter::Animate(void) __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength()); - __textObject.SetBounds(pCanvas->GetBounds()); + __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height)); __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas)); delete pCanvas; diff --git a/src/ui/inc/FUi_ResourceEditDateConfig.h b/src/ui/inc/FUi_ResourceEditDateConfig.h index 252e2db..de1936e 100644 --- a/src/ui/inc/FUi_ResourceEditDateConfig.h +++ b/src/ui/inc/FUi_ResourceEditDateConfig.h @@ -58,6 +58,7 @@ DECLARE_UI_CONFIG(EDITDATE); DECLARE_SHAPE_CONFIG(DAY_ELEMENT_WIDTH,14); DECLARE_SHAPE_CONFIG(DAY_ELEMENT_MIN_WIDTH,15); DECLARE_SHAPE_CONFIG(MONTH_YEAR_ELEMENT_MIN_WIDTH,16); + DECLARE_SHAPE_CONFIG(CONTENT_TEXT_MARGIN,17); DECLARE_DIMENSION_CONFIG(MIN_SIZE,1); DECLARE_END_UI_CONFIG(EDITDATE); diff --git a/src/ui/resource/FUi_ResourceEditDateConfig.cpp b/src/ui/resource/FUi_ResourceEditDateConfig.cpp index a66186f..ba2a0e1 100644 --- a/src/ui/resource/FUi_ResourceEditDateConfig.cpp +++ b/src/ui/resource/FUi_ResourceEditDateConfig.cpp @@ -61,7 +61,7 @@ START_UI_CONFIG(EDITDATE); ADD_SHAPE_CONFIG(ELEMENT_MARGIN, 17); ADD_SHAPE_CONFIG(DAY_ELEMENT_WIDTH, 69); ADD_SHAPE_CONFIG(DAY_ELEMENT_MIN_WIDTH, 69); - + ADD_SHAPE_CONFIG(CONTENT_TEXT_MARGIN, 2); ADD_DIMENSION_CONFIG(MIN_SIZE, 345, 112); } END_UI_CONFIG_MODE(720x1280); -- 2.7.4