From: Richard Huang Date: Tue, 13 Feb 2018 18:37:25 +0000 (+0000) Subject: Add support of text background style to TextLabel example X-Git-Tag: dali_1.3.13~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd5d01e85ea1d522c147ce9bd9b6dc0c4f736329;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Add support of text background style to TextLabel example Change-Id: I9f55b7b325bfe26867adcc8ccaccaa18f772c23f --- diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index 893698b..63f1c36 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -45,7 +47,8 @@ const char* BUTTON_IMAGES[] = { DEMO_IMAGE_DIR "FontStyleButton_Colour.png", DEMO_IMAGE_DIR "FontStyleButton_Outline.png", - DEMO_IMAGE_DIR "FontStyleButton_Shadow.png" + DEMO_IMAGE_DIR "FontStyleButton_Shadow.png", + DEMO_IMAGE_DIR "FontStyleButton_Background.png" }; const unsigned int KEY_ZERO = 10; @@ -84,6 +87,7 @@ enum StyleType TEXT_COLOR = 0, OUTLINE, SHADOW, + BACKGROUND, NUMBER_OF_STYLES }; @@ -166,7 +170,7 @@ public: mApplication.InitSignal().Connect( this, &TextLabelExample::Create ); // Set Style flags to inactive - for ( unsigned int i = OUTLINE; i < NUMBER_OF_STYLES; i++ ) + for ( unsigned int i = TEXT_COLOR; i < NUMBER_OF_STYLES; i++ ) { mStyleActiveState[ i ] = false; mCurrentStyleColor[i] = AVAILABLE_COLORS[ NUMBER_OF_COLORS - 1 ]; @@ -204,7 +208,7 @@ public: stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent); mStageSize = stage.GetSize(); - mButtonSize = Size( mStageSize.height * 0.12, mStageSize.height * 0.12 ); // Button size 1/12 of stage height + mButtonSize = Size( mStageSize.height * 0.1, mStageSize.height * 0.1 ); // Button size 1/10 of stage height mContainer = Control::New(); mContainer.SetName( "Container" ); @@ -297,6 +301,10 @@ public: { style = StyleType::SHADOW; } + else if( button == mStyleButtons[ StyleType::BACKGROUND ] ) + { + style = StyleType::BACKGROUND; + } return style; } @@ -370,8 +378,29 @@ public: mStyleActiveState[ SHADOW ] = ( shadowOffset == Vector2::ZERO ) ? false : true; mCurrentStyleColor[ SHADOW ] = mSelectedColor; - mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, shadowOffset ); - mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, mSelectedColor ); + Property::Map shadowMap; + shadowMap.Insert( "offset", shadowOffset ); + shadowMap.Insert( "color", mSelectedColor ); + mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap ); + + break; + } + case BACKGROUND : + { + Property::Map backgroundMap; + auto backgroundEnabled(true); + + if( mStyleActiveState[ BACKGROUND ] ) + { + backgroundEnabled = ( Color::WHITE != mSelectedColor ); // toggles background on/off + } + mStyleActiveState[ BACKGROUND ] = backgroundEnabled; + + backgroundMap["color"] = mSelectedColor; + backgroundMap["enable"] = backgroundEnabled; + mCurrentStyleColor[ BACKGROUND ] = mSelectedColor; + mLabel.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMap ); + break; } default : diff --git a/resources/images/FontStyleButton_Background.png b/resources/images/FontStyleButton_Background.png new file mode 100644 index 0000000..2bcd03e Binary files /dev/null and b/resources/images/FontStyleButton_Background.png differ