From 5350572a298a1bb994ae5b62af331d6f47b5c02c Mon Sep 17 00:00:00 2001 From: Bhavya Kumili Date: Thu, 11 Jul 2013 10:16:41 +0530 Subject: [PATCH] Fixing display errors in EditDate/EditTime Change-Id: I305353556281bfa602f6c54bdf0c80b7a364c8fc --- src/ui/controls/FUiCtrl_EditDatePresenter.cpp | 44 +++++++++- src/ui/controls/FUiCtrl_EditTimePresenter.cpp | 119 +++++++++++++++++--------- 2 files changed, 118 insertions(+), 45 deletions(-) diff --git a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp index 54c3687..a78027b 100644 --- a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp @@ -1353,6 +1353,7 @@ _EditDatePresenter::Animate(void) FloatPoint textPoint; TextSimple* pOldSimpleText = null; TextSimple* pNewSimpleText = null; + bool isCustomBitmap = false; _DateTimeUtils dateTimeUtils; monthString = dateTimeUtils.GetMonthString(GetMonth()); @@ -1389,6 +1390,7 @@ _EditDatePresenter::Animate(void) VisualElementPropertyAnimation* pNewBoundsAnimation = null; VisualElementPropertyAnimation* pOldBoundsAnimation = null; Canvas *pCanvas = null; + Canvas *pContentCanvas = null; Color contentBgColor; Color textPressedColor; float contentTextMargin; @@ -1459,17 +1461,50 @@ _EditDatePresenter::Animate(void) pNewVisualElement->SetShowState(true); pOldVisualElement->SetShowState(true); - __pContentProvider->SetBounds(FloatRectangle((rect.x + contentTextMargin), (rect.y + contentTextMargin), (rect.width - (contentTextMargin * 2.0f)), (rect.height - (contentTextMargin * 2.0f)))); + __pContentProvider->SetBounds(FloatRectangle((rect.x + contentTextMargin), (rect.y + (contentTextMargin * 2.0f)), (rect.width - (contentTextMargin * 2.0f)), (rect.height - (contentTextMargin * 4.0f)))); 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); + pContentCanvas = pEditDateElement->GetCanvasN(__pContentProvider->GetBounds()); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pContentCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + + pContentCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pContentCanvas->Clear(); + + pCanvas = pEditDateElement->GetCanvasN(rect); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); pCanvas->Clear(); + rect.x = 0.0f; + rect.y = 0.0f; + r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap); + isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED); + + if (!isCustomBitmap) + { + result res = DrawResourceBitmap(*pCanvas, rect, __pContentBgEffectPressedBitmap); + + if (res != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(res)); + } + } + delete pCanvas; pCanvas = null; + if (r != E_SUCCESS) + { + pContentCanvas->SetBackgroundColor(contentBgColor); + pContentCanvas->Clear(); + } + + delete pContentCanvas; + pContentCanvas = null; + pEditDateElement->AttachChild(*__pContentProvider); __pContentProvider->AttachChild(*pOldVisualElement); __pContentProvider->AttachChild(*pNewVisualElement); @@ -1568,6 +1603,9 @@ CATCH: delete pNewSimpleText; pNewSimpleText = null; + delete pContentCanvas; + pContentCanvas = null; + return; } diff --git a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp index 47de18b..9cbba23 100644 --- a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp @@ -1708,6 +1708,9 @@ _EditTimePresenter::Animate(void) String hourString; String minuteString; String newValue; + TextSimple* pOldSimpleText = null; + TextSimple* pNewSimpleText = null; + bool isCustomBitmap = false; _DateTimeUtils dateTimeUtils; int hours = GetHour(); @@ -1747,12 +1750,15 @@ _EditTimePresenter::Animate(void) VisualElementPropertyAnimation* pNewBoundsAnimation = null; VisualElementPropertyAnimation* pOldBoundsAnimation = null; Canvas *pCanvas = null; + Canvas *pContentCanvas = null; Color contentBgColor; Color textNormalColor; 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, __pEditTime->GetOrientation(), contentTextMargin); __pFont->GetTextExtent(newValue, newValue.GetLength(), newTextDim); __pFont->GetTextExtent(__lastSelectedValue, __lastSelectedValue.GetLength(), oldTextDim); @@ -1817,45 +1823,48 @@ _EditTimePresenter::Animate(void) pOldVisualElement->SetShowState(true); - if (newTextDim.width > oldTextDim.width) - { - textPoint.x = (rect.width - newTextDim.width) / 2.0f; - textPoint.y = (rect.height - newTextDim.height) / 2.0f; - __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); - pNewVisualElement->SetBounds(FloatRectangle(0.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + __pContentProvider->SetBounds(FloatRectangle((rect.x + contentTextMargin), (rect.y + (contentTextMargin * 2.0f)), (rect.width - (contentTextMargin * 2.0f)), (rect.height - (contentTextMargin * 4.0f)))); - rect.x = __pContentProvider->GetBounds().x; - rect.y = __pContentProvider->GetBounds().y; - rect.width = __pContentProvider->GetBounds().width; - rect.height = __pContentProvider->GetBounds().height; + pNewVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height)); + pOldVisualElement->SetBounds(FloatRectangle(0, 0, __pContentProvider->GetBounds().width, __pContentProvider->GetBounds().height)); - textPoint.x = (rect.width - oldTextDim.width) / 2.0f; - textPoint.y = (rect.height - oldTextDim.height) / 2.0f; + pContentCanvas = pEditTimeElement->GetCanvasN(__pContentProvider->GetBounds()); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pContentCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + pContentCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pContentCanvas->Clear(); - pOldVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); - } - else + pCanvas = pEditTimeElement->GetCanvasN(rect); + r = GetLastResult(); + SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); + pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); + pCanvas->Clear(); + rect.x = 0.0f; + rect.y = 0.0f; + r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap); + isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED); + + if (!isCustomBitmap) { - textPoint.x = (rect.width - oldTextDim.width) / 2.0f; - textPoint.y = (rect.height - oldTextDim.height) / 2.0f; - __pContentProvider->SetBounds(FloatRectangle((rect.x + textPoint.x) * 1.0f, (rect.y + textPoint.y) * 1.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); - pOldVisualElement->SetBounds(FloatRectangle(0.0f, 0.0f, oldTextDim.width * 1.0f, oldTextDim.height * 1.0f)); + result res = DrawResourceBitmap(*pCanvas, rect, __pContentBgEffectPressedBitmap); - rect.x = __pContentProvider->GetBounds().x; - rect.y = __pContentProvider->GetBounds().y; - rect.width = __pContentProvider->GetBounds().width; - rect.height = __pContentProvider->GetBounds().height; + if (res != E_SUCCESS) + { + SysLog(NID_UI_CTRL, "[%s] Propagating.", GetErrorMessage(res)); + } + } - textPoint.x = (rect.width - newTextDim.width) / 2.0f; - textPoint.y = (rect.height - newTextDim.height) / 2.0f; + delete pCanvas; + pCanvas = null; - pNewVisualElement->SetBounds(FloatRectangle(textPoint.x * 1.0f, newTextDim.height * 1.0f, newTextDim.width * 1.0f, newTextDim.height * 1.0f)); + if (r != E_SUCCESS) + { + pContentCanvas->SetBackgroundColor(contentBgColor); + pContentCanvas->Clear(); } - pCanvas = pEditTimeElement->GetCanvasN(rect); - pCanvas->SetBackgroundColor(contentBgColor); - pCanvas->Clear(); - delete pCanvas; + delete pContentCanvas; + pContentCanvas = null; pEditTimeElement->AttachChild(*__pContentProvider); @@ -1867,8 +1876,8 @@ _EditTimePresenter::Animate(void) pNewBoundsAnimation->SetDuration(300); pNewBoundsAnimation->SetPropertyName("bounds.position"); - pNewBoundsAnimation->SetStartValue(Variant(FloatPoint(pNewVisualElement->GetBounds().x * 1.0f, newTextDim.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(); @@ -1876,10 +1885,13 @@ _EditTimePresenter::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); + SysTryCatch(NID_UI_CTRL, (pOldSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pCanvas = pOldVisualElement->GetCanvasN(); r = GetLastResult(); SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); @@ -1887,13 +1899,23 @@ _EditTimePresenter::Animate(void) pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); pCanvas->Clear(); pCanvas->SetForegroundColor(textPressedColor); - (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD); - pCanvas->SetFont(*__pFont); - pCanvas->DrawText(FloatPoint(0.0f, 0.0f), __lastSelectedValue); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize); + (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN); + __textObject.RemoveAll(); + __textObject.AppendElement(*pOldSimpleText); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength()); + __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height)); + __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas)); delete pCanvas; pCanvas = null; + pNewSimpleText = new (std::nothrow)TextSimple((const_cast (newValue.GetPointer())), newValue.GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL); + SysTryCatch(NID_UI_CTRL, (pNewSimpleText != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pCanvas = pNewVisualElement->GetCanvasN(); r = GetLastResult(); SysTryCatch(NID_UI_CTRL, (pCanvas != null), , r, "[%s] Propagating.", GetErrorMessage(r)); @@ -1901,9 +1923,16 @@ _EditTimePresenter::Animate(void) pCanvas->SetBackgroundColor(Color(0, 0, 0, 0)); pCanvas->Clear(); pCanvas->SetForegroundColor(textPressedColor); - (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_BOLD); - pCanvas->SetFont(*__pFont); - pCanvas->DrawText(FloatPoint(0.0f, 0.0f), newValue); + + (_FontImpl::GetInstance(*__pFont))->SetSize(__timeFontSize); + (_FontImpl::GetInstance(*__pFont))->SetStyle(FONT_STYLE_PLAIN); + __textObject.RemoveAll(); + __textObject.AppendElement(*pNewSimpleText); + + __textObject.SetFont(__pFont, 0, __textObject.GetTextLength()); + __textObject.SetForegroundColor(textPressedColor, 0, __textObject.GetTextLength()); + __textObject.SetBounds(FloatRectangle(0, 0, pCanvas->GetBounds().width, pCanvas->GetBounds().height)); + __textObject.Draw(*_CanvasImpl::GetInstance(*pCanvas)); delete pCanvas; pCanvas = null; @@ -1930,8 +1959,14 @@ CATCH: delete pOldBoundsAnimation; pOldBoundsAnimation = null; - delete pCanvas; - pCanvas = null; + delete pOldSimpleText; + pOldSimpleText = null; + + delete pNewSimpleText; + pNewSimpleText = null; + + delete pContentCanvas; + pContentCanvas = null; return; } -- 2.7.4