Draw Bitmap changes to EditDate/EditTime/Pickers
authorBhavya Kumili <bhavya.k@samsung.com>
Wed, 25 Sep 2013 10:30:27 +0000 (16:00 +0530)
committerBhavya Kumili <bhavya.k@samsung.com>
Fri, 27 Sep 2013 06:31:08 +0000 (12:01 +0530)
Signed-off-by: Bhavya Kumili <bhavya.k@samsung.com>
Change-Id: I75935ff48d20d1f769edecfd73a71bf97edecc80

src/ui/controls/FUiCtrl_DateTimeDisplayBox.cpp
src/ui/controls/FUiCtrl_DateTimePresenter.cpp
src/ui/controls/FUiCtrl_EditDatePresenter.cpp
src/ui/controls/FUiCtrl_EditTimePresenter.cpp
src/ui/inc/FUiCtrl_EditDatePresenter.h
src/ui/inc/FUiCtrl_EditTimePresenter.h

index 492ff0a..040fa0c 100644 (file)
@@ -180,12 +180,15 @@ _DateTimeDisplayBox::DrawBackground(Canvas& canvas, DateTimePickerStatus status)
        {
                if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBackgroundNormalBitmap[status]))
                {
-                       r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundNormalBitmap[status]);
+                       r = canvas.DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, __windowBounds.width, __windowBounds.height), *__pBackgroundNormalBitmap[status]);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else
                {
-                       r = canvas.DrawBitmap(__windowBounds, *__pBackgroundNormalBitmap[status]);
+                       FloatPoint position(0.0f, 0.0f);
+                       position.x = (__windowBounds.width - __pBackgroundNormalBitmap[status]->GetWidthF()) / 2;
+                       position.y = (__windowBounds.height - __pBackgroundNormalBitmap[status]->GetHeightF()) / 2;
+                       r = canvas.DrawBitmap(position, *__pBackgroundNormalBitmap[status]);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
@@ -209,12 +212,12 @@ _DateTimeDisplayBox::DrawBackground(Canvas& canvas, DateTimePickerStatus status)
        {
                if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pBackgroundEffectBitmap[status]))
                {
-                       r = canvas.DrawNinePatchedBitmap(__windowBounds, *__pBackgroundEffectBitmap[status]);
+                       r = canvas.DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, __windowBounds.width, __windowBounds.height), *__pBackgroundEffectBitmap[status]);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else
                {
-                       r = canvas.DrawBitmap(__windowBounds, *__pBackgroundEffectBitmap[status]);
+                       r = canvas.DrawBitmap(FloatPoint(0.0f, 0.0f), *__pBackgroundEffectBitmap[status]);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
@@ -233,7 +236,7 @@ _DateTimeDisplayBox::DrawText(Canvas& canvas, DateTimePickerStatus status)
        r = __pTextObject->SetForegroundColor(__textColor[status], 0, __pTextObject->GetTextLength());
        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
 
-       r = __pTextObject->SetBounds(__windowBounds);
+       r = __pTextObject->SetBounds(FloatRectangle(0.0f, 0.0f, __windowBounds.width, __windowBounds.height));
        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
 
        r = __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas));
index 855111c..c092f96 100644 (file)
@@ -457,21 +457,34 @@ _DateTimePresenter::Draw(void)
 
        for (int i = 0; i < __outputBoxMaxCount; i++)
        {
-               DrawDateTimeDisplayBox(*pCanvas, i);
+               Canvas *pBoxCanvas = pVisualElement->GetCanvasN(__pDisplayBox[i]->GetDisplayBoxBounds());
+               SysTryReturnResult(NID_UI_CTRL, (pBoxCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               DrawDateTimeDisplayBox(*pBoxCanvas, i);
+               delete pBoxCanvas;
+       }
+
+       Canvas *pAmPmCanvas = null;
+       if (__pPmBox != null)
+       {
+               pAmPmCanvas = pVisualElement->GetCanvasN(__pPmBox->GetDisplayBoxBounds());
+               SysTryReturnResult(NID_UI_CTRL, (pAmPmCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
        }
 
        if ((__pickerStyle & DATETIME_OUTPUT_STYLE_DATE) && (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME))
        {
                DrawDividers(*pCanvas);
                DrawColon(*pCanvas);
-               DrawPm(*pCanvas);
+               DrawPm(*pAmPmCanvas);
        }
        else if (__pickerStyle & DATETIME_OUTPUT_STYLE_TIME)
        {
                DrawColon(*pCanvas);
-               DrawPm(*pCanvas);
+               DrawPm(*pAmPmCanvas);
        }
 
+       delete pAmPmCanvas;
+
        if (unlikely(_AccessibilityManager::IsActivated()))
        {
                SetAccessibilityElementText();
@@ -1795,7 +1808,7 @@ _DateTimePresenter::DrawBackground(Canvas& canvas)
                }
                else
                {
-                       canvas.DrawBitmap(bounds, *__pBgNormalBitmap);
+                       canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), *__pBgNormalBitmap);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
@@ -1809,7 +1822,7 @@ _DateTimePresenter::DrawBackground(Canvas& canvas)
                }
                else
                {
-                       canvas.DrawBitmap(bounds, *__pBgEffectBitmap);
+                       canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), *__pBgEffectBitmap);
                        SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
index 10e56d9..b87a0bb 100644 (file)
@@ -572,8 +572,9 @@ _EditDatePresenter::DrawFocus(void)
 {
        FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
 
+       Canvas* pContentCanvas = null;
        Canvas* pCanvas = __pEditDate->GetCanvasN();
-       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        if (__focusId == DATETIME_ID_DAY)
        {
@@ -597,9 +598,16 @@ _EditDatePresenter::DrawFocus(void)
        }
        else
        {
-               r = pCanvas->DrawBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
+               pContentCanvas = __pEditDate->GetCanvasN(bounds);
+               SysTryCatch(NID_UI_CTRL, (pContentCanvas != null), , GetLastResult(), "[%s]Propagating.", GetErrorMessage(GetLastResult()));
+
+               bounds.x = (bounds.width - __pContentBgHighlightedColorReplacementBitmap->GetWidthF()) / 2;
+               bounds.y = (bounds.height - __pContentBgHighlightedColorReplacementBitmap->GetHeightF()) / 2;
+
+               r = pContentCanvas->DrawBitmap(FloatPoint(bounds.x, bounds.y), *__pContentBgHighlightedColorReplacementBitmap);
                SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
 
+               delete pContentCanvas;
        }
 
        delete pCanvas;
@@ -607,6 +615,7 @@ _EditDatePresenter::DrawFocus(void)
 
 CATCH:
        delete pCanvas;
+       delete pContentCanvas;
        return r;
 }
 
@@ -783,7 +792,7 @@ _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& boun
                pEffectBitmap = __pContentBgEffectPressedBitmap;
        }
 
-       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
+       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap, isCustomBitmap);
        SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (!isCustomBitmap)
@@ -796,7 +805,7 @@ _EditDatePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& boun
 }
 
 result
-_EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
+_EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap, bool isCustomBitmap)
 {
        result r = E_SUCCESS;
 
@@ -812,7 +821,23 @@ _EditDatePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bou
        }
        else
        {
-               r = canvas.DrawBitmap(bounds, *pBitmap);
+               if (isCustomBitmap)
+               {
+                       Canvas *pContentCanvas = __pEditDate->GetCanvasN(bounds);
+                       SysTryReturnResult(NID_UI_CTRL, (pContentCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       FloatPoint position;
+
+                       position.x = (bounds.width - pBitmap->GetWidthF()) / 2;
+                       position.y = (bounds.height - pBitmap->GetHeightF()) / 2;
+                       r = pContentCanvas->DrawBitmap(position, *pBitmap);
+                       delete pContentCanvas;
+               }
+               else
+               {
+                       r = canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), *pBitmap);
+               }
+
                SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
@@ -1488,8 +1513,8 @@ _EditDatePresenter::Animate(void)
        pCanvas->Clear();
        rect.x = 0.0f;
        rect.y = 0.0f;
-       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap);
        isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
+       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap, isCustomBitmap);
 
        if (!isCustomBitmap)
        {
index f87364f..970c7e0 100644 (file)
@@ -604,7 +604,7 @@ CATCH:
 }
 
 result
-_EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
+_EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap, bool isCustomBitmap)
 {
        result r = E_SUCCESS;
 
@@ -620,7 +620,23 @@ _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bou
        }
        else
        {
-               r = canvas.DrawBitmap(bounds, *pBitmap);
+               if (isCustomBitmap)
+               {
+                       Canvas *pContentCanvas = __pEditTime->GetCanvasN(bounds);
+                       SysTryReturnResult(NID_UI_CTRL, (pContentCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+                       FloatPoint position;
+
+                       position.x = (bounds.width - pBitmap->GetWidthF()) / 2;
+                       position.y = (bounds.height - pBitmap->GetHeightF()) / 2;
+                       r = pContentCanvas->DrawBitmap(position, *pBitmap);
+                       delete pContentCanvas;
+               }
+               else
+               {
+                       r = canvas.DrawBitmap(FloatPoint(bounds.x, bounds.y), *pBitmap);
+               }
+
                SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
        }
 
@@ -808,7 +824,7 @@ _EditTimePresenter::Draw(void)
 
        if (!__24hours)
        {
-               r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap);
+               r = DrawResourceBitmap(*pCanvas, ampmBounds, pReplacementBitmap, isCustomBitmap);
                SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
 
                if (!isCustomBitmap)
@@ -831,8 +847,9 @@ _EditTimePresenter::DrawFocus(void)
 {
        FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
 
+       Canvas* pContentCanvas = null;
        Canvas* pCanvas = __pEditTime->GetCanvasN();
-       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create canvas.");
+       SysTryReturnResult(NID_UI_CTRL, (pCanvas != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        if (__focusId == DATETIME_ID_HOUR)
        {
@@ -855,8 +872,15 @@ _EditTimePresenter::DrawFocus(void)
        }
        else
        {
-               r = pCanvas->DrawBitmap(bounds, *__pContentBgHighlightedColorReplacementBitmap);
+               pContentCanvas = __pEditTime->GetCanvasN(bounds);
+               SysTryCatch(NID_UI_CTRL, (pContentCanvas != null), , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+               bounds.x = (bounds.width - __pContentBgHighlightedColorReplacementBitmap->GetWidthF()) / 2;
+               bounds.y = (bounds.height - __pContentBgHighlightedColorReplacementBitmap->GetHeightF()) / 2;
+
+               r = pContentCanvas->DrawBitmap(FloatPoint(bounds.x, bounds.y), *__pContentBgHighlightedColorReplacementBitmap);
                SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+               delete pContentCanvas;
        }
 
        delete pCanvas;
@@ -864,6 +888,7 @@ _EditTimePresenter::DrawFocus(void)
 
 CATCH:
        delete pCanvas;
+       delete pContentCanvas;
        return r;
 }
 
@@ -931,7 +956,7 @@ _EditTimePresenter::DrawContentBitmap(Canvas& canvas, const FloatRectangle& boun
                pEffectBitmap = __pContentBgEffectPressedBitmap;
        }
 
-       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap);
+       r = DrawResourceBitmap(canvas, bounds, pReplacementBitmap, isCustomBitmap);
        SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        if (!isCustomBitmap)
@@ -1831,8 +1856,8 @@ _EditTimePresenter::Animate(void)
        pCanvas->Clear();
        rect.x = 0.0f;
        rect.y = 0.0f;
-       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap);
        isCustomBitmap = IS_CUSTOM_BITMAP(EDITTIME::CONTENT_BG_PRESSED);
+       r = DrawResourceBitmap(*pCanvas, rect, __pContentBgPressedColorReplacementBitmap, isCustomBitmap);
 
        if (!isCustomBitmap)
        {
index 714e950..d3a9fbc 100644 (file)
@@ -99,7 +99,7 @@ private:
        result DrawTitle(Tizen::Graphics::Canvas& canvas);
        result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Base::String& text, _DateTimeId boxId = DATETIME_ID_NONE);
        result DrawContentBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, _DateTimeId displayBoxId);
-       result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap);
+       result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap, bool isCustomBitmap = false);
        _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::FloatPoint& point) const;
 
 private:
index bbb2d7e..e6b515b 100644 (file)
@@ -106,7 +106,7 @@ private:
        result DrawColon(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds);
        _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::FloatPoint& point) const;
        result LoadResource(void);
-       result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap);
+       result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap, bool isCustomBitmap = false);
        float GetTimeElementWidth(void) const;
 
 private: