Commit f78b247ae99f685bcada123573d236201df58767
Committed by
Gerrit Code Review
Merge "Add support of text background style to TextLabel example" into devel/master
Showing
2 changed files
with
34 additions
and
5 deletions
examples/text-label/text-label-example.cpp
| @@ -24,6 +24,8 @@ | @@ -24,6 +24,8 @@ | ||
| 24 | #include <dali/devel-api/object/handle-devel.h> | 24 | #include <dali/devel-api/object/handle-devel.h> |
| 25 | #include <dali/devel-api/actors/actor-devel.h> | 25 | #include <dali/devel-api/actors/actor-devel.h> |
| 26 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> | 26 | #include <dali-toolkit/devel-api/controls/buttons/button-devel.h> |
| 27 | +#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h> | ||
| 28 | +#include <dali-toolkit/devel-api/text/text-enumerations-devel.h> | ||
| 27 | #include <dali-toolkit/dali-toolkit.h> | 29 | #include <dali-toolkit/dali-toolkit.h> |
| 28 | #include <iostream> | 30 | #include <iostream> |
| 29 | 31 | ||
| @@ -45,7 +47,8 @@ const char* BUTTON_IMAGES[] = | @@ -45,7 +47,8 @@ const char* BUTTON_IMAGES[] = | ||
| 45 | { | 47 | { |
| 46 | DEMO_IMAGE_DIR "FontStyleButton_Colour.png", | 48 | DEMO_IMAGE_DIR "FontStyleButton_Colour.png", |
| 47 | DEMO_IMAGE_DIR "FontStyleButton_Outline.png", | 49 | DEMO_IMAGE_DIR "FontStyleButton_Outline.png", |
| 48 | - DEMO_IMAGE_DIR "FontStyleButton_Shadow.png" | 50 | + DEMO_IMAGE_DIR "FontStyleButton_Shadow.png", |
| 51 | + DEMO_IMAGE_DIR "FontStyleButton_Background.png" | ||
| 49 | }; | 52 | }; |
| 50 | 53 | ||
| 51 | const unsigned int KEY_ZERO = 10; | 54 | const unsigned int KEY_ZERO = 10; |
| @@ -84,6 +87,7 @@ enum StyleType | @@ -84,6 +87,7 @@ enum StyleType | ||
| 84 | TEXT_COLOR = 0, | 87 | TEXT_COLOR = 0, |
| 85 | OUTLINE, | 88 | OUTLINE, |
| 86 | SHADOW, | 89 | SHADOW, |
| 90 | + BACKGROUND, | ||
| 87 | NUMBER_OF_STYLES | 91 | NUMBER_OF_STYLES |
| 88 | }; | 92 | }; |
| 89 | 93 | ||
| @@ -166,7 +170,7 @@ public: | @@ -166,7 +170,7 @@ public: | ||
| 166 | mApplication.InitSignal().Connect( this, &TextLabelExample::Create ); | 170 | mApplication.InitSignal().Connect( this, &TextLabelExample::Create ); |
| 167 | 171 | ||
| 168 | // Set Style flags to inactive | 172 | // Set Style flags to inactive |
| 169 | - for ( unsigned int i = OUTLINE; i < NUMBER_OF_STYLES; i++ ) | 173 | + for ( unsigned int i = TEXT_COLOR; i < NUMBER_OF_STYLES; i++ ) |
| 170 | { | 174 | { |
| 171 | mStyleActiveState[ i ] = false; | 175 | mStyleActiveState[ i ] = false; |
| 172 | mCurrentStyleColor[i] = AVAILABLE_COLORS[ NUMBER_OF_COLORS - 1 ]; | 176 | mCurrentStyleColor[i] = AVAILABLE_COLORS[ NUMBER_OF_COLORS - 1 ]; |
| @@ -204,7 +208,7 @@ public: | @@ -204,7 +208,7 @@ public: | ||
| 204 | 208 | ||
| 205 | stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent); | 209 | stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent); |
| 206 | mStageSize = stage.GetSize(); | 210 | mStageSize = stage.GetSize(); |
| 207 | - mButtonSize = Size( mStageSize.height * 0.12, mStageSize.height * 0.12 ); // Button size 1/12 of stage height | 211 | + mButtonSize = Size( mStageSize.height * 0.1, mStageSize.height * 0.1 ); // Button size 1/10 of stage height |
| 208 | 212 | ||
| 209 | mContainer = Control::New(); | 213 | mContainer = Control::New(); |
| 210 | mContainer.SetName( "Container" ); | 214 | mContainer.SetName( "Container" ); |
| @@ -297,6 +301,10 @@ public: | @@ -297,6 +301,10 @@ public: | ||
| 297 | { | 301 | { |
| 298 | style = StyleType::SHADOW; | 302 | style = StyleType::SHADOW; |
| 299 | } | 303 | } |
| 304 | + else if( button == mStyleButtons[ StyleType::BACKGROUND ] ) | ||
| 305 | + { | ||
| 306 | + style = StyleType::BACKGROUND; | ||
| 307 | + } | ||
| 300 | return style; | 308 | return style; |
| 301 | } | 309 | } |
| 302 | 310 | ||
| @@ -370,8 +378,29 @@ public: | @@ -370,8 +378,29 @@ public: | ||
| 370 | mStyleActiveState[ SHADOW ] = ( shadowOffset == Vector2::ZERO ) ? false : true; | 378 | mStyleActiveState[ SHADOW ] = ( shadowOffset == Vector2::ZERO ) ? false : true; |
| 371 | mCurrentStyleColor[ SHADOW ] = mSelectedColor; | 379 | mCurrentStyleColor[ SHADOW ] = mSelectedColor; |
| 372 | 380 | ||
| 373 | - mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, shadowOffset ); | ||
| 374 | - mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, mSelectedColor ); | 381 | + Property::Map shadowMap; |
| 382 | + shadowMap.Insert( "offset", shadowOffset ); | ||
| 383 | + shadowMap.Insert( "color", mSelectedColor ); | ||
| 384 | + mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap ); | ||
| 385 | + | ||
| 386 | + break; | ||
| 387 | + } | ||
| 388 | + case BACKGROUND : | ||
| 389 | + { | ||
| 390 | + Property::Map backgroundMap; | ||
| 391 | + auto backgroundEnabled(true); | ||
| 392 | + | ||
| 393 | + if( mStyleActiveState[ BACKGROUND ] ) | ||
| 394 | + { | ||
| 395 | + backgroundEnabled = ( Color::WHITE != mSelectedColor ); // toggles background on/off | ||
| 396 | + } | ||
| 397 | + mStyleActiveState[ BACKGROUND ] = backgroundEnabled; | ||
| 398 | + | ||
| 399 | + backgroundMap["color"] = mSelectedColor; | ||
| 400 | + backgroundMap["enable"] = backgroundEnabled; | ||
| 401 | + mCurrentStyleColor[ BACKGROUND ] = mSelectedColor; | ||
| 402 | + mLabel.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMap ); | ||
| 403 | + | ||
| 375 | break; | 404 | break; |
| 376 | } | 405 | } |
| 377 | default : | 406 | default : |
resources/images/FontStyleButton_Background.png
0 → 100644
7.26 KB