const std::string TRUE_TOKEN( "true" );
}
-bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type )
+bool ParseProperties( const std::string& shadowProperties,
+ bool& colorDefined,
+ Vector4& color,
+ bool& offsetDefined,
+ Vector2& offset )
{
- bool update = false;
+ // Parses and applies the style.
+ Property::Map map;
+ Text::ParsePropertyString( shadowProperties, map );
- if( controller )
+ const bool empty = map.Empty();
+
+ if( !empty )
{
- const std::string properties = value.Get<std::string>();
+ /// Color key.
+ Property::Value* colorValue = map.Find( COLOR_KEY );
+
+ colorDefined = colorValue != NULL;
+ if( colorDefined )
+ {
+ const std::string colorStr = colorValue->Get<std::string>();
- // Parses and applies the style.
- Property::Map map;
- ParsePropertyString( properties, map );
+ Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+ }
- if( !map.Empty() )
+ /// Offset key.
+ Property::Value* offsetValue = map.Find( OFFSET_KEY );
+
+ offsetDefined = offsetValue != NULL;
+ if( offsetDefined )
{
- /// Enable key.
- Property::Value* enableValue = map.Find( ENABLE_KEY );
+ const std::string offsetStr = offsetValue->Get<std::string>();
- bool enabled = false;
- const bool enabledDefined = enableValue != NULL;
- if( enabledDefined )
- {
- const std::string enableStr = enableValue->Get<std::string>();
- enabled = TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
- }
+ StringToVector2( offsetStr.c_str(), offsetStr.size(), offset );
+ }
+ }
- /// Color key.
- Property::Value* colorValue = map.Find( COLOR_KEY );
+ return empty;
+}
- Vector4 color;
- const bool colorDefined = colorValue != NULL;
- if( colorDefined )
- {
- const std::string colorStr = colorValue->Get<std::string>();
+bool ParseProperties( const std::string& underlineProperties,
+ bool& enabled,
+ bool& colorDefined,
+ Vector4& color,
+ bool& heightDefined,
+ float& height )
+{
+ // Parses and applies the style.
+ Property::Map map;
+ Text::ParsePropertyString( underlineProperties, map );
- ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
- }
+ const bool empty = map.Empty();
- /// Height key.
- Property::Value* heightValue = map.Find( HEIGHT_KEY );
+ if( !empty )
+ {
+ /// Enable key.
+ Property::Value* enableValue = map.Find( ENABLE_KEY );
- float height = 0.f;
- const bool heightDefined = heightValue != NULL;
- if( heightDefined )
- {
- const std::string heightStr = heightValue->Get<std::string>();
+ enabled = false;
+ const bool enabledDefined = enableValue != NULL;
+ if( enabledDefined )
+ {
+ const std::string enableStr = enableValue->Get<std::string>();
+ enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
+ }
- height = StringToFloat( heightStr.c_str() );
- }
+ /// Color key.
+ Property::Value* colorValue = map.Find( COLOR_KEY );
+
+ colorDefined = colorValue != NULL;
+ if( colorDefined )
+ {
+ const std::string colorStr = colorValue->Get<std::string>();
+
+ Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+ }
+
+ /// Height key.
+ Property::Value* heightValue = map.Find( HEIGHT_KEY );
+
+ height = 0.f;
+ heightDefined = heightValue != NULL;
+ if( heightDefined )
+ {
+ const std::string heightStr = heightValue->Get<std::string>();
+ height = StringToFloat( heightStr.c_str() );
+ }
+ }
+
+ return empty;
+}
+
+bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type )
+{
+ bool update = false;
+
+ if( controller )
+ {
+ const std::string properties = value.Get<std::string>();
+
+ bool enabled = false;
+ bool colorDefined = false;
+ Vector4 color;
+ bool heightDefined = false;
+ float height = 0.f;
+
+ const bool empty = ParseProperties( properties,
+ enabled,
+ colorDefined,
+ color,
+ heightDefined,
+ height );
+
+ if( !empty )
+ {
switch( type )
{
case EffectStyle::DEFAULT:
controller->SetUnderlineEnabled( enabled );
update = true;
}
+
// Sets the default underline values.
if( colorDefined && ( controller->GetUnderlineColor() != color ) )
{
update = true;
}
- if( heightDefined && fabsf( controller->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
+ if( heightDefined && ( fabsf( controller->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 ) )
{
controller->SetUnderlineHeight( height );
update = true;
{
const std::string properties = value.Get< std::string >();
- // Parses and applies the style.
- Property::Map map;
- ParsePropertyString( properties, map );
-
- if( !map.Empty() )
- {
- /// Color key
- Property::Value* colorValue = map.Find( COLOR_KEY );
-
- Vector4 color;
- const bool colorDefined = colorValue != NULL;
- if( colorDefined )
- {
- const std::string colorStr = colorValue->Get<std::string>();
-
- ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
- }
-
- /// Offset key
- Property::Value* offsetValue = map.Find( OFFSET_KEY );
+ bool colorDefined = false;
+ Vector4 color;
+ bool offsetDefined = false;
+ Vector2 offset;
- Vector2 offset;
- const bool offsetDefined = offsetValue != NULL;
- if( offsetDefined )
- {
- const std::string offsetStr = offsetValue->Get<std::string>();
-
- StringToVector2( offsetStr.c_str(), offsetStr.size(), offset );
- }
+ const bool empty = ParseProperties( properties,
+ colorDefined,
+ color,
+ offsetDefined,
+ offset );
+ if( !empty )
+ {
switch( type )
{
case EffectStyle::DEFAULT: