Commit f78b247ae99f685bcada123573d236201df58767

Authored by Adeel Kazmi
Committed by Gerrit Code Review
2 parents b7a0babe fd5d01e8

Merge "Add support of text background style to TextLabel example" into devel/master

examples/text-label/text-label-example.cpp
... ... @@ -24,6 +24,8 @@
24 24 #include <dali/devel-api/object/handle-devel.h>
25 25 #include <dali/devel-api/actors/actor-devel.h>
26 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 29 #include <dali-toolkit/dali-toolkit.h>
28 30 #include <iostream>
29 31  
... ... @@ -45,7 +47,8 @@ const char* BUTTON_IMAGES[] =
45 47 {
46 48 DEMO_IMAGE_DIR "FontStyleButton_Colour.png",
47 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 54 const unsigned int KEY_ZERO = 10;
... ... @@ -84,6 +87,7 @@ enum StyleType
84 87 TEXT_COLOR = 0,
85 88 OUTLINE,
86 89 SHADOW,
  90 + BACKGROUND,
87 91 NUMBER_OF_STYLES
88 92 };
89 93  
... ... @@ -166,7 +170,7 @@ public:
166 170 mApplication.InitSignal().Connect( this, &TextLabelExample::Create );
167 171  
168 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 175 mStyleActiveState[ i ] = false;
172 176 mCurrentStyleColor[i] = AVAILABLE_COLORS[ NUMBER_OF_COLORS - 1 ];
... ... @@ -204,7 +208,7 @@ public:
204 208  
205 209 stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent);
206 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 213 mContainer = Control::New();
210 214 mContainer.SetName( "Container" );
... ... @@ -297,6 +301,10 @@ public:
297 301 {
298 302 style = StyleType::SHADOW;
299 303 }
  304 + else if( button == mStyleButtons[ StyleType::BACKGROUND ] )
  305 + {
  306 + style = StyleType::BACKGROUND;
  307 + }
300 308 return style;
301 309 }
302 310  
... ... @@ -370,8 +378,29 @@ public:
370 378 mStyleActiveState[ SHADOW ] = ( shadowOffset == Vector2::ZERO ) ? false : true;
371 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 404 break;
376 405 }
377 406 default :
... ...
resources/images/FontStyleButton_Background.png 0 → 100644

7.26 KB