X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-effects-style.cpp;h=d8d35def9164a14076a028e285197dc6a23f30a9;hp=8b71d3009b9d43404a3fc728c04980896e22ef34;hb=cc06ca1ff697d568fde8de7a4d147fb9d9442fbc;hpb=44bb6ae11e1c189104d9a8c9881bd5e524b398c0 diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp index 8b71d30..d8d35de 100755 --- a/dali-toolkit/internal/text/text-effects-style.cpp +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -35,6 +35,7 @@ namespace { const std::string COLOR_KEY( "color" ); const std::string OFFSET_KEY( "offset" ); +const std::string BLUR_RADIUS_KEY( "blurRadius" ); const std::string WIDTH_KEY( "width" ); const std::string HEIGHT_KEY( "height" ); const std::string ENABLE_KEY( "enable" ); @@ -46,7 +47,9 @@ bool ParseShadowProperties( const Property::Map& shadowPropertiesMap, bool& colorDefined, Vector4& color, bool& offsetDefined, - Vector2& offset ) + Vector2& offset, + bool& blurRadiusDefined, + float& blurRadius ) { const unsigned int numberOfItems = shadowPropertiesMap.Count(); @@ -60,18 +63,45 @@ bool ParseShadowProperties( const Property::Map& shadowPropertiesMap, /// Color key. colorDefined = true; - const std::string colorStr = valueGet.second.Get(); - - Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string colorStr = valueGet.second.Get(); + Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + } + else + { + color = valueGet.second.Get(); + } } else if( OFFSET_KEY == valueGet.first.stringKey ) { /// Offset key. offsetDefined = true; - const std::string offsetStr = valueGet.second.Get(); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string offsetStr = valueGet.second.Get(); + StringToVector2( offsetStr.c_str(), offsetStr.size(), offset ); + } + else + { + offset = valueGet.second.Get(); + } + } + else if( BLUR_RADIUS_KEY == valueGet.first.stringKey ) + { + /// Blur radius key. + blurRadiusDefined = true; - StringToVector2( offsetStr.c_str(), offsetStr.size(), offset ); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string blurRadiusStr = valueGet.second.Get(); + blurRadius = StringToFloat( blurRadiusStr.c_str() ); + } + else + { + blurRadius = valueGet.second.Get(); + } } } @@ -95,26 +125,45 @@ bool ParseUnderlineProperties( const Property::Map& underlinePropertiesMap, if( ENABLE_KEY == valueGet.first.stringKey ) { /// Enable key. - const std::string enableStr = valueGet.second.Get(); - enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() ); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string enableStr = valueGet.second.Get(); + enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() ); + } + else + { + enabled = valueGet.second.Get(); + } } else if( COLOR_KEY == valueGet.first.stringKey ) { /// Color key. colorDefined = true; - const std::string colorStr = valueGet.second.Get(); - - Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string colorStr = valueGet.second.Get(); + Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color ); + } + else + { + color = valueGet.second.Get(); + } } else if( HEIGHT_KEY == valueGet.first.stringKey ) { /// Height key. heightDefined = true; - const std::string heightStr = valueGet.second.Get(); - - height = StringToFloat( heightStr.c_str() ); + if( valueGet.second.GetType() == Dali::Property::STRING ) + { + const std::string heightStr = valueGet.second.Get(); + height = StringToFloat( heightStr.c_str() ); + } + else + { + height = valueGet.second.Get(); + } } } @@ -125,7 +174,7 @@ bool ParseOutlineProperties( const Property::Map& underlinePropertiesMap, bool& colorDefined, Vector4& color, bool& widthDefined, - float& width ) + unsigned int& width ) { const unsigned int numberOfItems = underlinePropertiesMap.Count(); @@ -144,7 +193,7 @@ bool ParseOutlineProperties( const Property::Map& underlinePropertiesMap, { /// Width key. widthDefined = true; - width = valueGet.second.Get(); + width = static_cast( valueGet.second.Get() ); } } @@ -188,7 +237,7 @@ bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& va heightDefined, height ); - controller->UnderlineSetByString( !empty); + controller->UnderlineSetByString( !empty ); } } else @@ -321,6 +370,8 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value Vector4 color; bool offsetDefined = false; Vector2 offset; + bool blurRadiusDefined = false; + float blurRadius; bool empty = true; @@ -336,7 +387,9 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value colorDefined, color, offsetDefined, - offset ); + offset, + blurRadiusDefined, + blurRadius ); controller->ShadowSetByString( !empty ); @@ -347,7 +400,9 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value colorDefined, color, offsetDefined, - offset ); + offset, + blurRadiusDefined, + blurRadius ); controller->ShadowSetByString( false ); } @@ -366,6 +421,12 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value controller->SetShadowOffset( offset ); update = true; } + + if( blurRadiusDefined && ( controller->GetShadowBlurRadius() != blurRadius ) ) + { + controller->SetShadowBlurRadius( blurRadius ); + update = true; + } } else { @@ -400,6 +461,7 @@ void GetShadowProperties( ControllerPtr controller, Property::Value& value, Effe { const Vector4& color = controller->GetShadowColor(); const Vector2& offset = controller->GetShadowOffset(); + const float& blurRadius = controller->GetShadowBlurRadius(); if ( controller->IsShadowSetByString() ) { @@ -411,7 +473,11 @@ void GetShadowProperties( ControllerPtr controller, Property::Value& value, Effe std::string offsetStr; Vector2ToString( offset, offsetStr ); - shadowProperties += "\"offset\":\"" + offsetStr + "\"}"; + shadowProperties += "\"offset\":\"" + offsetStr + "\","; + + std::string blurRadiusStr; + FloatToString( blurRadius, blurRadiusStr ); + shadowProperties += "\"blurRadius\":\"" + blurRadiusStr + "\"}"; value = shadowProperties; } @@ -419,13 +485,9 @@ void GetShadowProperties( ControllerPtr controller, Property::Value& value, Effe { Property::Map map; - std::string colorStr; - Vector4ToColorString( color, colorStr ); - map.Insert( COLOR_KEY, colorStr ); - - std::string offsetStr; - Vector2ToString( offset, offsetStr ); - map.Insert( OFFSET_KEY, offsetStr ); + map.Insert( COLOR_KEY, color ); + map.Insert( OFFSET_KEY, offset ); + map.Insert( BLUR_RADIUS_KEY, blurRadius ); value = map; } @@ -503,17 +565,30 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu bool colorDefined = false; Vector4 color; bool widthDefined = false; - float width = 0.f; + unsigned int width = 0u; bool empty = true; - if ( !propertiesMap.Empty() ) + if ( propertiesMap.Empty() ) + { + // Map empty so check if a string provided + // This is purely to maintain backward compatibility, but we don't parse the string to be a property map. + const std::string propertyString = value.Get(); + + // Stores the default outline's properties string to be recovered by the GetOutlineProperties() function. + controller->SetDefaultOutlineProperties( propertyString ); + + controller->OutlineSetByString( true ); + } + else { empty = ParseOutlineProperties( propertiesMap, colorDefined, color, widthDefined, width ); + + controller->OutlineSetByString( false ); } if( !empty ) @@ -525,7 +600,7 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu update = true; } - if( widthDefined && ( fabsf( controller->GetOutlineWidth() - width ) > Math::MACHINE_EPSILON_1000 ) ) + if( widthDefined && ( controller->GetOutlineWidth() != width ) ) { controller->SetOutlineWidth( width ); update = true; @@ -534,9 +609,9 @@ bool SetOutlineProperties( ControllerPtr controller, const Property::Value& valu else { // Disable outline - if( fabsf( controller->GetOutlineWidth() ) > Math::MACHINE_EPSILON_1000 ) + if( 0u != controller->GetOutlineWidth() ) { - controller->SetOutlineWidth( 0.0f ); + controller->SetOutlineWidth( 0u ); update = true; } } @@ -563,22 +638,24 @@ void GetOutlineProperties( ControllerPtr controller, Property::Value& value, Eff { case EffectStyle::DEFAULT: { - const Vector4& color = controller->GetOutlineColor(); - const float width = controller->GetOutlineWidth(); - - Property::Map map; - - std::string colorStr; - Vector4ToColorString( color, colorStr ); - map.Insert( COLOR_KEY, colorStr ); + if ( controller->IsOutlineSetByString() ) + { + value = controller->GetDefaultOutlineProperties(); + break; + } + else + { + const Vector4& color = controller->GetOutlineColor(); + const unsigned int width = controller->GetOutlineWidth(); - std::string widthStr; - FloatToString( width, widthStr ); - map.Insert( WIDTH_KEY, widthStr ); + Property::Map map; + map.Insert( COLOR_KEY, color ); + map.Insert( WIDTH_KEY, static_cast( width ) ); - value = map; + value = map; - break; + break; + } } case EffectStyle::INPUT: {