Merge Resource bitmap changes(SearchBar, Animation) to tizen
authorBhavya Kumili <bhavya.k@samsung.com>
Mon, 27 May 2013 06:25:33 +0000 (11:55 +0530)
committerBhavya Kumili <bhavya.k@samsung.com>
Mon, 27 May 2013 06:25:33 +0000 (11:55 +0530)
Change-Id: I5df6b7e3c9e4c6b4bd48aae7f0130126b36e3672

src/ui/controls/FUiCtrl_AnimationPresenter.cpp
src/ui/controls/FUiCtrl_SearchBarPresenter.cpp

index 5f17378..238a0e5 100644 (file)
@@ -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:
index eb885ec..2ff26e4 100644 (file)
@@ -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
        {