From: Heeyong Song Date: Mon, 4 Jan 2021 14:41:35 +0000 (+0000) Subject: Merge "Change visual animation code" into devel/master X-Git-Tag: dali_2.0.8~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c6e5f5fc21c97831378c0a83b6047f3daf8c2c4;hp=15b2dcc5584bbd91668948108a4241f7ca3a742a;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Merge "Change visual animation code" into devel/master --- diff --git a/examples/arc-visual/arc-visual-example.cpp b/examples/arc-visual/arc-visual-example.cpp index 8ccb78a..ac60b7e 100644 --- a/examples/arc-visual/arc-visual-example.cpp +++ b/examples/arc-visual/arc-visual-example.cpp @@ -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; diff --git a/examples/color-visual/color-visual-example.cpp b/examples/color-visual/color-visual-example.cpp index a7d7104..d8e5d44 100644 --- a/examples/color-visual/color-visual-example.cpp +++ b/examples/color-visual/color-visual-example.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include @@ -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) diff --git a/examples/gradients/gradients-example.cpp b/examples/gradients/gradients-example.cpp index 85eba7c..77abb2c 100644 --- a/examples/gradients/gradients-example.cpp +++ b/examples/gradients/gradients-example.cpp @@ -16,6 +16,7 @@ */ #include +#include #include #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; }