Commit 0732ea82cec951e4aa3adf34f0e577e684caade3
1 parent
4650fc43
Animate Text Color of TextLabel
Change-Id: If1cf3c6bd484f9b2ce64b0fba79dbef0c23cb9fb
Showing
1 changed file
with
17 additions
and
1 deletions
examples/text-label/text-label-example.cpp
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | // EXTERNAL INCLUDES |
| 24 | 24 | #include <dali/devel-api/object/handle-devel.h> |
| 25 | +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h> | |
| 25 | 26 | #include <dali-toolkit/dali-toolkit.h> |
| 26 | 27 | #include <iostream> |
| 27 | 28 | |
| ... | ... | @@ -39,6 +40,7 @@ const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "grab-handle.png"; |
| 39 | 40 | |
| 40 | 41 | const unsigned int KEY_ZERO = 10; |
| 41 | 42 | const unsigned int KEY_ONE = 11; |
| 43 | +const unsigned int KEY_A = 38; | |
| 42 | 44 | const unsigned int KEY_F = 41; |
| 43 | 45 | const unsigned int KEY_H = 43; |
| 44 | 46 | const unsigned int KEY_V = 55; |
| ... | ... | @@ -163,7 +165,7 @@ public: |
| 163 | 165 | mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 164 | 166 | mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); |
| 165 | 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 | 169 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); |
| 168 | 170 | mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); |
| 169 | 171 | mLabel.SetBackgroundColor( Color::WHITE ); |
| ... | ... | @@ -183,6 +185,12 @@ public: |
| 183 | 185 | anim.SetLooping(true); |
| 184 | 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 | 194 | Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); |
| 187 | 195 | std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl; |
| 188 | 196 | } |
| ... | ... | @@ -240,6 +248,14 @@ public: |
| 240 | 248 | mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); |
| 241 | 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 | 259 | case KEY_F: // Fill vertically |
| 244 | 260 | { |
| 245 | 261 | if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) ) | ... | ... |