Commit 0732ea82cec951e4aa3adf34f0e577e684caade3

Authored by Agnelo Vaz
1 parent 4650fc43

Animate Text Color of TextLabel

Change-Id: If1cf3c6bd484f9b2ce64b0fba79dbef0c23cb9fb
examples/text-label/text-label-example.cpp
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 22
23 // EXTERNAL INCLUDES 23 // EXTERNAL INCLUDES
24 #include <dali/devel-api/object/handle-devel.h> 24 #include <dali/devel-api/object/handle-devel.h>
  25 +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/dali-toolkit.h> 26 #include <dali-toolkit/dali-toolkit.h>
26 #include <iostream> 27 #include <iostream>
27 28
@@ -39,6 +40,7 @@ const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR &quot;grab-handle.png&quot;; @@ -39,6 +40,7 @@ const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR &quot;grab-handle.png&quot;;
39 40
40 const unsigned int KEY_ZERO = 10; 41 const unsigned int KEY_ZERO = 10;
41 const unsigned int KEY_ONE = 11; 42 const unsigned int KEY_ONE = 11;
  43 +const unsigned int KEY_A = 38;
42 const unsigned int KEY_F = 41; 44 const unsigned int KEY_F = 41;
43 const unsigned int KEY_H = 43; 45 const unsigned int KEY_H = 43;
44 const unsigned int KEY_V = 55; 46 const unsigned int KEY_V = 55;
@@ -163,7 +165,7 @@ public: @@ -163,7 +165,7 @@ public:
163 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); 165 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
164 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); 166 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
165 mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); 167 mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
166 - mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE ); 168 + mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
167 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); 169 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
168 mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); 170 mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
169 mLabel.SetBackgroundColor( Color::WHITE ); 171 mLabel.SetBackgroundColor( Color::WHITE );
@@ -183,6 +185,12 @@ public: @@ -183,6 +185,12 @@ public:
183 anim.SetLooping(true); 185 anim.SetLooping(true);
184 anim.Play(); 186 anim.Play();
185 187
  188 + // Animate the text color 3 times from source color to RED
  189 + Animation animation = Animation::New( 2.f );
  190 + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN );
  191 + animation.SetLoopCount( 3 );
  192 + animation.Play();
  193 +
186 Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); 194 Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT );
187 std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl; 195 std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl;
188 } 196 }
@@ -240,6 +248,14 @@ public: @@ -240,6 +248,14 @@ public:
240 mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); 248 mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 );
241 break; 249 break;
242 } 250 }
  251 + case KEY_A: // Animate text colour
  252 + {
  253 + Animation animation = Animation::New( 2.f );
  254 + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN );
  255 + animation.SetLooping( true );
  256 + animation.Play();
  257 + break;
  258 + }
243 case KEY_F: // Fill vertically 259 case KEY_F: // Fill vertically
244 { 260 {
245 if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) ) 261 if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) )