Change visual animation code 43/249243/3
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 9 Dec 2020 07:45:51 +0000 (16:45 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 30 Dec 2020 06:56:41 +0000 (15:56 +0900)
Change-Id: I926b26102db20d08af8fc8b7eec72e21f70fd51a

examples/arc-visual/arc-visual-example.cpp
examples/color-visual/color-visual-example.cpp
examples/gradients/gradients-example.cpp

index 8ccb78adae08e62025e5e7e1566f3359e418606f..ac60b7e6d52a9f96b4efa9c9e227b91243b57a15 100644 (file)
@@ -47,23 +47,6 @@ const Property::Value TEXT_BACKGROUND{
   {DevelVisual::Property::CORNER_RADIUS, 0.5f},
   {DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE}};
 
-const Property::Value TRANSITION_ANIMATOR{
-  {"timePeriod", Property::Map().Add("duration", ANIMATION_DURATION)}};
-
-const Property::Value TRANSITION_START_ANGLE{
-  {"target", "background"},
-  {"property", "startAngle"},
-  {"initialValue", START_ANGLE_INITIAL_VALUE},
-  {"targetValue", START_ANGLE_TARGET_VALUE},
-  {"animator", TRANSITION_ANIMATOR}};
-
-const Property::Value TRANSITION_SWEEP_ANGLE{
-  {"target", "background"},
-  {"property", "sweepAngle"},
-  {"initialValue", SWEEP_ANGLE_INITIAL_VALUE},
-  {"targetValue", SWEEP_ANGLE_TARGET_VALUE},
-  {"animator", TRANSITION_ANIMATOR}};
-
 } // namespace
 
 // This example shows the properties of the arc visual - thickness, startAngle and sweepAngle and animates them.
@@ -200,12 +183,13 @@ private:
   {
     if(touch.GetState(0) == PointState::UP)
     {
-      Property::Array array;
-      array.PushBack(TRANSITION_START_ANGLE);
-      array.PushBack(TRANSITION_SWEEP_ANGLE);
+      DevelControl::DoAction(mControl, Control::Property::BACKGROUND, DevelArcVisual::Action::UPDATE_PROPERTY,
+                             Property::Map().Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE)
+                                            .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE));
 
-      TransitionData transitionData = TransitionData::New(array);
-      Animation      animation      = DevelControl::CreateTransition(Toolkit::Internal::GetImplementation(mControl), transitionData);
+      Animation animation = Animation::New(ANIMATION_DURATION);
+      animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::START_ANGLE), START_ANGLE_TARGET_VALUE);
+      animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::SWEEP_ANGLE), SWEEP_ANGLE_TARGET_VALUE);
       animation.Play();
     }
     return true;
index a7d7104b039dc425df968aa968b4281c76557bf6..d8e5d44f026b2e3862eeb4995c4ac98036316ef8 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 
@@ -28,15 +27,18 @@ namespace
 {
 const char* IMAGE_FILE(DEMO_IMAGE_DIR "gallery-medium-1.jpg");
 
-const float BLUR_RADIUS_VALUE(10.0f);
-const float NO_BLUR_VALUE(0.0f);
+const float BLUR_RADIUS_VALUE(15.0f);
+const Vector2 BLUR_OFFSET_VALUE(0.05f, 0.05f);
+const Vector2 BLUR_SIZE_VALUE(1.1f, 1.1f);
+const Vector2 NO_BLUR_SIZE_VALUE(1.05f, 1.05f);
 const float ANIMATION_DURATION(2.0f);
 
 const Property::Value SHADOW{
   {Visual::Property::TYPE, Visual::COLOR},
   {Visual::Property::MIX_COLOR, Vector4(0.0f, 0.0f, 0.0f, 0.5f)},
-  {Visual::Property::TRANSFORM, Property::Map{{Visual::Transform::Property::OFFSET, Vector2(0.05f, 0.05f)}, {Visual::Transform::Property::SIZE, Vector2(1.05f, 1.05f)}, {Visual::Transform::Property::ORIGIN, Align::CENTER}, {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}},
-  {DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_VALUE}};
+  {Visual::Property::TRANSFORM, Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE},
+                                              {Visual::Transform::Property::ORIGIN, Align::CENTER},
+                                              {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}};
 
 } // namespace
 
@@ -47,7 +49,7 @@ class ColorVisualExample : public ConnectionTracker
 public:
   ColorVisualExample(Application& application)
   : mApplication(application),
-    mShadowVisible(true)
+    mBlurEnabled(false)
   {
     // Connect to the Application's Init signal
     mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
@@ -83,23 +85,31 @@ public:
   {
     if(touch.GetState(0) == PointState::UP)
     {
-      float initialValue, targetValue;
-      if(!mShadowVisible)
+      Animation animation = Animation::New(ANIMATION_DURATION);
+
+      if(!mBlurEnabled)
       {
-        initialValue = NO_BLUR_VALUE;
-        targetValue  = BLUR_RADIUS_VALUE;
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::MIX_COLOR), Vector3(1.0f, 0.0f, 0.0f));
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::OPACITY), 0.5f);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, DevelVisual::Property::CORNER_RADIUS), 30.0f);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, ColorVisual::Property::MIX_COLOR), Vector3(0.0f, 0.0f, 1.0f));
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, DevelColorVisual::Property::BLUR_RADIUS), BLUR_RADIUS_VALUE);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::OFFSET), BLUR_OFFSET_VALUE);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::SIZE), BLUR_SIZE_VALUE);
       }
       else
       {
-        initialValue = BLUR_RADIUS_VALUE;
-        targetValue  = NO_BLUR_VALUE;
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::MIX_COLOR), Vector3(1.0f, 1.0f, 1.0f));
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::OPACITY), 1.0f);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, DevelVisual::Property::CORNER_RADIUS), 0.0f);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, ColorVisual::Property::MIX_COLOR), Vector3(0.0f, 0.0f, 0.0f));
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, DevelColorVisual::Property::BLUR_RADIUS), 0.0f);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::OFFSET), Vector2::ZERO);
+        animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::SIZE), NO_BLUR_SIZE_VALUE);
       }
-
-      mShadowVisible = !mShadowVisible;
-
-      TransitionData transitionData = TransitionData::New(Property::Map().Add("target", "shadow").Add("property", "blurRadius").Add("initialValue", initialValue).Add("targetValue", targetValue).Add("animator", Property::Map().Add("duration", ANIMATION_DURATION)));
-      Animation      animation      = DevelControl::CreateTransition(Toolkit::Internal::GetImplementation(mImageView), transitionData);
       animation.Play();
+
+      mBlurEnabled = !mBlurEnabled;
     }
     return true;
   }
@@ -118,7 +128,7 @@ public:
 private:
   Application& mApplication;
   ImageView    mImageView;
-  bool         mShadowVisible;
+  bool         mBlurEnabled;
 };
 
 int DALI_EXPORT_API main(int argc, char** argv)
index 85eba7cad1d4c2c24643f0bb824c9432a6dd1335..77abb2c5e862222801195b8fad40d1a8ed30bd14 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include "shared/view.h"
 
@@ -132,10 +133,18 @@ public:
 
   bool OnRoundedCornerClicked(Toolkit::Button button)
   {
-    mRoundedCorner                                     = !mRoundedCorner;
-    mGradientMap[DevelVisual::Property::CORNER_RADIUS] = mRoundedCorner ? CORNER_RADIUS_VALUE : 0.0f;
+    mRoundedCorner = !mRoundedCorner;
 
-    UpdateGradientMap();
+    Animation animation = Animation::New(2.0f);
+    if(mRoundedCorner)
+    {
+      animation.AnimateTo(DevelControl::GetVisualProperty(mGradientControl, Control::Property::BACKGROUND, DevelVisual::Property::CORNER_RADIUS), CORNER_RADIUS_VALUE);
+    }
+    else
+    {
+      animation.AnimateTo(DevelControl::GetVisualProperty(mGradientControl, Control::Property::BACKGROUND, DevelVisual::Property::CORNER_RADIUS), 0.0f);
+    }
+    animation.Play();
 
     return true;
   }