From: Agnelo Vaz Date: Fri, 28 Jul 2017 13:19:08 +0000 (+0100) Subject: Animate Text Color of TextLabel X-Git-Tag: dali_1.2.51~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0732ea82cec951e4aa3adf34f0e577e684caade3;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Animate Text Color of TextLabel Change-Id: If1cf3c6bd484f9b2ce64b0fba79dbef0c23cb9fb --- diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index 85c51eb..d7c7315 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -22,6 +22,7 @@ // EXTERNAL INCLUDES #include +#include #include #include @@ -39,6 +40,7 @@ const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "grab-handle.png"; const unsigned int KEY_ZERO = 10; const unsigned int KEY_ONE = 11; +const unsigned int KEY_A = 38; const unsigned int KEY_F = 41; const unsigned int KEY_H = 43; const unsigned int KEY_V = 55; @@ -163,7 +165,7 @@ public: mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); - mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE ); + mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE ); mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); mLabel.SetBackgroundColor( Color::WHITE ); @@ -183,6 +185,12 @@ public: anim.SetLooping(true); anim.Play(); + // Animate the text color 3 times from source color to RED + Animation animation = Animation::New( 2.f ); + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN ); + animation.SetLoopCount( 3 ); + animation.Play(); + Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl; } @@ -240,6 +248,14 @@ public: mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); break; } + case KEY_A: // Animate text colour + { + Animation animation = Animation::New( 2.f ); + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN ); + animation.SetLooping( true ); + animation.Play(); + break; + } case KEY_F: // Fill vertically { if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) )