From: Bhavya Kumili Date: Mon, 27 May 2013 06:25:33 +0000 (+0530) Subject: Merge Resource bitmap changes(SearchBar, Animation) to tizen X-Git-Tag: submit/tizen_2.2/20130714.153149~700^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f62e02bf3dd307e68fbbf126444cc6bfadd97760;p=framework%2Fosp%2Fuifw.git Merge Resource bitmap changes(SearchBar, Animation) to tizen Change-Id: I5df6b7e3c9e4c6b4bd48aae7f0130126b36e3672 --- diff --git a/src/ui/controls/FUiCtrl_AnimationPresenter.cpp b/src/ui/controls/FUiCtrl_AnimationPresenter.cpp index 5f17378..238a0e5 100644 --- a/src/ui/controls/FUiCtrl_AnimationPresenter.cpp +++ b/src/ui/controls/FUiCtrl_AnimationPresenter.cpp @@ -353,6 +353,7 @@ _AnimationPresenter::Draw(void) Canvas* pCanvas = null; AnimationFrame* pFrame = null; Bitmap* pBitmap = null; + String imagePath = L""; pFrame = GetCurrentFrame(); SysTryCatch(NID_UI_CTRL, pFrame != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the current animation frame."); @@ -361,23 +362,37 @@ _AnimationPresenter::Draw(void) if (pBitmap != null) { - pCanvas = __pAnimation->GetCanvasN(); - - SysTryReturnResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "A system error has occurred. Failed to get the animation canvas."); - - pCanvas->SetBackgroundColor(Color()); - pCanvas->Clear(); + if (!_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap)) + { + imagePath = _BitmapImpl::GetInstance(*pBitmap)->GetFileName(); + } - if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap)) + if(!imagePath.IsEmpty()) { - r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pBitmap); + __pVisualElement->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255)); + __pVisualElement->SetImageSource(imagePath); } else { - r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pBitmap); - } + __pVisualElement->SetImageSource(L""); + pCanvas = __pAnimation->GetCanvasN(); + + SysTryReturnResult(NID_UI_CTRL, pCanvas != null, E_SYSTEM, "A system error has occurred. Failed to get the animation canvas."); + + pCanvas->SetBackgroundColor(Color()); + pCanvas->Clear(); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw the bitmap", GetErrorMessage(r)); + if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap)) + { + r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pBitmap); + } + else + { + r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *pBitmap); + } + + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw the bitmap", GetErrorMessage(r)); + } } CATCH: diff --git a/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp index eb885ec..2ff26e4 100644 --- a/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp +++ b/src/ui/controls/FUiCtrl_SearchBarPresenter.cpp @@ -292,23 +292,39 @@ _SearchBarPresenter::Draw(void) if (pBackgroundBitmap) { - Canvas* pCanvas = __pSearchBar->GetCanvasN(); - r = GetLastResult(); - SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); + String imagePath = L""; - pCanvas->SetBackgroundColor(bgColor); - pCanvas->Clear(); + if (!_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap)) + { + imagePath = _BitmapImpl::GetInstance(*pBackgroundBitmap)->GetFileName(); + } - if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap)) + if(!imagePath.IsEmpty()) { - pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + __pSearchBar->GetVisualElement()->SetBackgroundColor(_Colorf((float)bgColor.GetRed() / 255, (float)bgColor.GetGreen() / 255, (float)bgColor.GetBlue() / 255, (float)bgColor.GetAlpha() / 255)); + __pSearchBar->GetVisualElement()->SetImageSource(imagePath); } else { - pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundBitmap->GetWidthF(), pBackgroundBitmap->GetHeightF())); - } + __pSearchBar->GetVisualElement()->SetImageSource(L""); + Canvas* pCanvas = __pSearchBar->GetCanvasN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r)); - delete pCanvas; + pCanvas->SetBackgroundColor(bgColor); + pCanvas->Clear(); + + if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBackgroundBitmap)) + { + pCanvas->DrawNinePatchedBitmap(bounds, *pBackgroundBitmap); + } + else + { + pCanvas->DrawBitmap(bounds, *pBackgroundBitmap, FloatRectangle(0.0f, 0.0f, pBackgroundBitmap->GetWidthF(), pBackgroundBitmap->GetHeightF())); + } + + delete pCanvas; + } } else {