#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
#include <dali-toolkit/dali-toolkit.h>
#include <iostream>
{
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;
TEXT_COLOR = 0,
OUTLINE,
SHADOW,
+ BACKGROUND,
NUMBER_OF_STYLES
};
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 ];
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" );
{
style = StyleType::SHADOW;
}
+ else if( button == mStyleButtons[ StyleType::BACKGROUND ] )
+ {
+ style = StyleType::BACKGROUND;
+ }
return style;
}
case SHADOW :
{
Vector2 shadowOffset( SHADOW_OFFSET ); // Will be set to zeros if color already set
- Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW_COLOR );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
Vector4 currentShadowColor;
value.Get( currentShadowColor );
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 :
}
case KEY_S: // Shadow color
{
- if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) )
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector4 shadowColor;
+ value.Get( shadowColor );
+ Property::Map shadowMap;
+ if( Color::BLACK == shadowColor )
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED );
+ shadowMap.Insert( "color", Color::RED );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
}
else
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+ shadowMap.Insert( "color", Color::BLACK );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
}
break;
}
}
case KEY_PLUS: // Increase shadow offset
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector2 shadowOffset;
+ value.Get( shadowOffset );
+ shadowOffset += Vector2( 1.0f, 1.0f );
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "offset", shadowOffset );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
break;
}
case KEY_MINUS: // Decrease shadow offset
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector2 shadowOffset;
+ value.Get( shadowOffset );
+ shadowOffset -= Vector2( 1.0f, 1.0f );
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "offset", shadowOffset );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
break;
}