Fix jira issue about N_SE-41614 and modify animation effect
authorWoowon <woowon.park@samsung.com>
Mon, 17 Jun 2013 11:49:55 +0000 (20:49 +0900)
committerWoowon <woowon.park@samsung.com>
Mon, 17 Jun 2013 11:49:55 +0000 (20:49 +0900)
Change-Id: I75b14c96993348167e6352f38453058643ceeda2
Signed-off-by: Woowon <woowon.park@samsung.com>
src/nfc-push-ui-app-control/src/NfcPushUiForm.cpp

index 85ce850..341023c 100644 (file)
@@ -27,6 +27,8 @@
 #include <FAppAppControlProviderManager.h>
 #include <FUiAnimVisualElement.h>
 #include <FUiSystemUtil.h>
+#include <FUiAnimAnimationTransaction.h>
+#include <FUiAnimEaseInOutTimingFunction.h>
 #include <FUiAnimVisualElementPropertyAnimation.h>
 #include <FBaseSysLog.h>
 #include <FBaseColAllElementsDeleter.h>
@@ -44,10 +46,10 @@ using namespace Tizen::Graphics;
 using namespace Tizen::Net::Nfc;
 using namespace Tizen::Media;
 
-const int NfcPushUiForm::_DURATION_GROW_ = 500;
-const int NfcPushUiForm::_DURATION_OPACITY_ = 500;
-const int NfcPushUiForm::_DURATION_REPEAT_ = 500;
-const int NfcPushUiForm::_DURATION_OPACITY2_ = 500;
+const int NfcPushUiForm::_DURATION_GROW_ = 667;
+const int NfcPushUiForm::_DURATION_OPACITY_ = 497;
+const int NfcPushUiForm::_DURATION_REPEAT_ = 516;
+const int NfcPushUiForm::_DURATION_OPACITY2_ = 431;
 
 NfcPushUiForm::NfcPushUiForm(void)
        : __reqId(-1)
@@ -177,9 +179,6 @@ NfcPushUiForm::OnInitializing(void)
 
        __pVisualElementBounds->SetBounds(__startRect);
 
-       SysLog(NID_NET_NFC, "start to play animation");
-       PlayBoundsAnimation(L"grow", 1, _DURATION_GROW_);
-
        ////////////////////////////////////////////////////////////////////////////////
        // Opacity rectangle
        ////////////////////////////////////////////////////////////////////////////////
@@ -212,12 +211,20 @@ NfcPushUiForm::OnInitializing(void)
        __endOpacity = 1.0f;
 
        // draw the bitmap
+       pCanvas->SetBackgroundColor(Color(0x00000000));
+       pCanvas->Clear();
        r = pCanvas->DrawBitmap(Point(__rect.x, __rect.y), *pBitmap);
        SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Failed to draw the bitmap.");
 
        // set an opacity level
        __pVisualElementOpacity->SetOpacity(__startOpacity);
 
+       SysLog(NID_NET_NFC, "start to play animation");
+       AnimationTransaction::Begin();
+       PlayBoundsAnimation(L"grow", 1, _DURATION_GROW_);
+       PlayOpacityAnimation(L"opacity", _DURATION_OPACITY_);
+       AnimationTransaction::Commit();
+
        return r;
 }
 
@@ -415,6 +422,8 @@ NfcPushUiForm::PlayBoundsAnimation(const Tizen::Base::String& animationName, int
        std::unique_ptr<VisualElementPropertyAnimation> pAnimation(new (std::nothrow) VisualElementPropertyAnimation());
        SysTryReturnVoidResult(NID_NET_NFC, pAnimation != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
+       Tizen::Ui::Animations::EaseInOutTimingFunction* pTimingFunction = new EaseInOutTimingFunction();
+
        // bounds
        pAnimation->SetPropertyName(L"bounds");
        pAnimation->SetStartValue(Variant(__startRect));
@@ -423,6 +432,10 @@ NfcPushUiForm::PlayBoundsAnimation(const Tizen::Base::String& animationName, int
        pAnimation->SetRepeatCount(repeatCount);
        pAnimation->SetAutoReverseEnabled(autoReverse);
        pAnimation->SetVisualElementAnimationStatusEventListener(this);
+       if (animationName == L"grow" || animationName == L"shrink")
+       {
+               pAnimation->SetTimingFunction(pTimingFunction);
+       }
 
        __pVisualElementBounds->AddAnimation(animationName, *pAnimation);
 }
@@ -439,6 +452,10 @@ NfcPushUiForm::PlayOpacityAnimation(const Tizen::Base::String& animationName, in
        pAnimation->SetEndValue(Variant(__endOpacity));
        pAnimation->SetDuration(duration);
        pAnimation->SetVisualElementAnimationStatusEventListener(this);
+       if (animationName == L"opacity")
+       {
+               pAnimation->SetDelay(247);
+       }
 
        __pVisualElementOpacity->AddAnimation(animationName, *pAnimation);
 }
@@ -462,11 +479,7 @@ NfcPushUiForm::OnVisualElementAnimationFinished(const VisualElementAnimation& an
 {
        if(completedNormally)
        {
-               if(keyName == L"grow")
-               {
-                       PlayOpacityAnimation(L"opacity", _DURATION_OPACITY_);
-               }
-               else if (keyName == L"opacity")
+               if (keyName == L"opacity")
                {
                        float margin = (__endRect.width * 0.2f) / 2;
                        __startRect = __endRect;
@@ -491,11 +504,6 @@ NfcPushUiForm::OnVisualElementAnimationFinished(const VisualElementAnimation& an
 
                        FinishAppControl(__reqId, APP_CTRL_RESULT_SUCCEEDED);
                }
-               else if (keyName == L"opacity2")
-               {
-
-
-               }
        }
 }
 
@@ -505,14 +513,16 @@ NfcPushUiForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Gr
 {
        __startOpacity = __endOpacity;
        __endOpacity = 0.0f;
-       PlayOpacityAnimation(L"opacity2", _DURATION_OPACITY2_);
 
        // reset the circles size
        __startRect = __endRect;
        __endRect = FloatRectangle(__startRect.x + 90.0f, __startRect.y + 90.0f, 0, 0);
 
        // play animation
+       AnimationTransaction::Begin();
+       PlayOpacityAnimation(L"opacity2", _DURATION_OPACITY2_);
        PlayBoundsAnimation(L"shrink", 1, 667, false);
+       AnimationTransaction::Commit();
 }
 
 // INfcDeviceDiscoveryEventListener