Commit 7c6e5f5fc21c97831378c0a83b6047f3daf8c2c4

Authored by Heeyong Song
Committed by Gerrit Code Review
2 parents 15b2dcc5 9c9290d3

Merge "Change visual animation code" into devel/master

examples/arc-visual/arc-visual-example.cpp
@@ -47,23 +47,6 @@ const Property::Value TEXT_BACKGROUND{ @@ -47,23 +47,6 @@ const Property::Value TEXT_BACKGROUND{
47 {DevelVisual::Property::CORNER_RADIUS, 0.5f}, 47 {DevelVisual::Property::CORNER_RADIUS, 0.5f},
48 {DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE}}; 48 {DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE}};
49 49
50 -const Property::Value TRANSITION_ANIMATOR{  
51 - {"timePeriod", Property::Map().Add("duration", ANIMATION_DURATION)}};  
52 -  
53 -const Property::Value TRANSITION_START_ANGLE{  
54 - {"target", "background"},  
55 - {"property", "startAngle"},  
56 - {"initialValue", START_ANGLE_INITIAL_VALUE},  
57 - {"targetValue", START_ANGLE_TARGET_VALUE},  
58 - {"animator", TRANSITION_ANIMATOR}};  
59 -  
60 -const Property::Value TRANSITION_SWEEP_ANGLE{  
61 - {"target", "background"},  
62 - {"property", "sweepAngle"},  
63 - {"initialValue", SWEEP_ANGLE_INITIAL_VALUE},  
64 - {"targetValue", SWEEP_ANGLE_TARGET_VALUE},  
65 - {"animator", TRANSITION_ANIMATOR}};  
66 -  
67 } // namespace 50 } // namespace
68 51
69 // This example shows the properties of the arc visual - thickness, startAngle and sweepAngle and animates them. 52 // This example shows the properties of the arc visual - thickness, startAngle and sweepAngle and animates them.
@@ -200,12 +183,13 @@ private: @@ -200,12 +183,13 @@ private:
200 { 183 {
201 if(touch.GetState(0) == PointState::UP) 184 if(touch.GetState(0) == PointState::UP)
202 { 185 {
203 - Property::Array array;  
204 - array.PushBack(TRANSITION_START_ANGLE);  
205 - array.PushBack(TRANSITION_SWEEP_ANGLE); 186 + DevelControl::DoAction(mControl, Control::Property::BACKGROUND, DevelArcVisual::Action::UPDATE_PROPERTY,
  187 + Property::Map().Add(DevelArcVisual::Property::START_ANGLE, START_ANGLE_INITIAL_VALUE)
  188 + .Add(DevelArcVisual::Property::SWEEP_ANGLE, SWEEP_ANGLE_INITIAL_VALUE));
206 189
207 - TransitionData transitionData = TransitionData::New(array);  
208 - Animation animation = DevelControl::CreateTransition(Toolkit::Internal::GetImplementation(mControl), transitionData); 190 + Animation animation = Animation::New(ANIMATION_DURATION);
  191 + animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::START_ANGLE), START_ANGLE_TARGET_VALUE);
  192 + animation.AnimateTo(DevelControl::GetVisualProperty(mControl, Control::Property::BACKGROUND, DevelArcVisual::Property::SWEEP_ANGLE), SWEEP_ANGLE_TARGET_VALUE);
209 animation.Play(); 193 animation.Play();
210 } 194 }
211 return true; 195 return true;
examples/color-visual/color-visual-example.cpp
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 17
18 #include <dali-toolkit/dali-toolkit.h> 18 #include <dali-toolkit/dali-toolkit.h>
19 #include <dali-toolkit/devel-api/controls/control-devel.h> 19 #include <dali-toolkit/devel-api/controls/control-devel.h>
20 -#include <dali-toolkit/devel-api/visual-factory/transition-data.h>  
21 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h> 20 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
22 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> 21 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
23 22
@@ -28,15 +27,18 @@ namespace @@ -28,15 +27,18 @@ namespace
28 { 27 {
29 const char* IMAGE_FILE(DEMO_IMAGE_DIR "gallery-medium-1.jpg"); 28 const char* IMAGE_FILE(DEMO_IMAGE_DIR "gallery-medium-1.jpg");
30 29
31 -const float BLUR_RADIUS_VALUE(10.0f);  
32 -const float NO_BLUR_VALUE(0.0f); 30 +const float BLUR_RADIUS_VALUE(15.0f);
  31 +const Vector2 BLUR_OFFSET_VALUE(0.05f, 0.05f);
  32 +const Vector2 BLUR_SIZE_VALUE(1.1f, 1.1f);
  33 +const Vector2 NO_BLUR_SIZE_VALUE(1.05f, 1.05f);
33 const float ANIMATION_DURATION(2.0f); 34 const float ANIMATION_DURATION(2.0f);
34 35
35 const Property::Value SHADOW{ 36 const Property::Value SHADOW{
36 {Visual::Property::TYPE, Visual::COLOR}, 37 {Visual::Property::TYPE, Visual::COLOR},
37 {Visual::Property::MIX_COLOR, Vector4(0.0f, 0.0f, 0.0f, 0.5f)}, 38 {Visual::Property::MIX_COLOR, Vector4(0.0f, 0.0f, 0.0f, 0.5f)},
38 - {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}}},  
39 - {DevelColorVisual::Property::BLUR_RADIUS, BLUR_RADIUS_VALUE}}; 39 + {Visual::Property::TRANSFORM, Property::Map{{Visual::Transform::Property::SIZE, NO_BLUR_SIZE_VALUE},
  40 + {Visual::Transform::Property::ORIGIN, Align::CENTER},
  41 + {Visual::Transform::Property::ANCHOR_POINT, Align::CENTER}}}};
40 42
41 } // namespace 43 } // namespace
42 44
@@ -47,7 +49,7 @@ class ColorVisualExample : public ConnectionTracker @@ -47,7 +49,7 @@ class ColorVisualExample : public ConnectionTracker
47 public: 49 public:
48 ColorVisualExample(Application& application) 50 ColorVisualExample(Application& application)
49 : mApplication(application), 51 : mApplication(application),
50 - mShadowVisible(true) 52 + mBlurEnabled(false)
51 { 53 {
52 // Connect to the Application's Init signal 54 // Connect to the Application's Init signal
53 mApplication.InitSignal().Connect(this, &ColorVisualExample::Create); 55 mApplication.InitSignal().Connect(this, &ColorVisualExample::Create);
@@ -83,23 +85,31 @@ public: @@ -83,23 +85,31 @@ public:
83 { 85 {
84 if(touch.GetState(0) == PointState::UP) 86 if(touch.GetState(0) == PointState::UP)
85 { 87 {
86 - float initialValue, targetValue;  
87 - if(!mShadowVisible) 88 + Animation animation = Animation::New(ANIMATION_DURATION);
  89 +
  90 + if(!mBlurEnabled)
88 { 91 {
89 - initialValue = NO_BLUR_VALUE;  
90 - targetValue = BLUR_RADIUS_VALUE; 92 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::MIX_COLOR), Vector3(1.0f, 0.0f, 0.0f));
  93 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::OPACITY), 0.5f);
  94 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, DevelVisual::Property::CORNER_RADIUS), 30.0f);
  95 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, ColorVisual::Property::MIX_COLOR), Vector3(0.0f, 0.0f, 1.0f));
  96 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, DevelColorVisual::Property::BLUR_RADIUS), BLUR_RADIUS_VALUE);
  97 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::OFFSET), BLUR_OFFSET_VALUE);
  98 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::SIZE), BLUR_SIZE_VALUE);
91 } 99 }
92 else 100 else
93 { 101 {
94 - initialValue = BLUR_RADIUS_VALUE;  
95 - targetValue = NO_BLUR_VALUE; 102 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::MIX_COLOR), Vector3(1.0f, 1.0f, 1.0f));
  103 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, Visual::Property::OPACITY), 1.0f);
  104 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, ImageView::Property::IMAGE, DevelVisual::Property::CORNER_RADIUS), 0.0f);
  105 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, ColorVisual::Property::MIX_COLOR), Vector3(0.0f, 0.0f, 0.0f));
  106 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, DevelColorVisual::Property::BLUR_RADIUS), 0.0f);
  107 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::OFFSET), Vector2::ZERO);
  108 + animation.AnimateTo(DevelControl::GetVisualProperty(mImageView, DevelControl::Property::SHADOW, Visual::Transform::Property::SIZE), NO_BLUR_SIZE_VALUE);
96 } 109 }
97 -  
98 - mShadowVisible = !mShadowVisible;  
99 -  
100 - 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)));  
101 - Animation animation = DevelControl::CreateTransition(Toolkit::Internal::GetImplementation(mImageView), transitionData);  
102 animation.Play(); 110 animation.Play();
  111 +
  112 + mBlurEnabled = !mBlurEnabled;
103 } 113 }
104 return true; 114 return true;
105 } 115 }
@@ -118,7 +128,7 @@ public: @@ -118,7 +128,7 @@ public:
118 private: 128 private:
119 Application& mApplication; 129 Application& mApplication;
120 ImageView mImageView; 130 ImageView mImageView;
121 - bool mShadowVisible; 131 + bool mBlurEnabled;
122 }; 132 };
123 133
124 int DALI_EXPORT_API main(int argc, char** argv) 134 int DALI_EXPORT_API main(int argc, char** argv)
examples/gradients/gradients-example.cpp
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 */ 16 */
17 17
18 #include <dali-toolkit/dali-toolkit.h> 18 #include <dali-toolkit/dali-toolkit.h>
  19 +#include <dali-toolkit/devel-api/controls/control-devel.h>
19 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> 20 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
20 #include "shared/view.h" 21 #include "shared/view.h"
21 22
@@ -132,10 +133,18 @@ public: @@ -132,10 +133,18 @@ public:
132 133
133 bool OnRoundedCornerClicked(Toolkit::Button button) 134 bool OnRoundedCornerClicked(Toolkit::Button button)
134 { 135 {
135 - mRoundedCorner = !mRoundedCorner;  
136 - mGradientMap[DevelVisual::Property::CORNER_RADIUS] = mRoundedCorner ? CORNER_RADIUS_VALUE : 0.0f; 136 + mRoundedCorner = !mRoundedCorner;
137 137
138 - UpdateGradientMap(); 138 + Animation animation = Animation::New(2.0f);
  139 + if(mRoundedCorner)
  140 + {
  141 + animation.AnimateTo(DevelControl::GetVisualProperty(mGradientControl, Control::Property::BACKGROUND, DevelVisual::Property::CORNER_RADIUS), CORNER_RADIUS_VALUE);
  142 + }
  143 + else
  144 + {
  145 + animation.AnimateTo(DevelControl::GetVisualProperty(mGradientControl, Control::Property::BACKGROUND, DevelVisual::Property::CORNER_RADIUS), 0.0f);
  146 + }
  147 + animation.Play();
139 148
140 return true; 149 return true;
141 } 150 }