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=8d552d4b798644b99f844d6c8ac45124497e16ae;hp=38145dc5ed4a4b6c2fb57a0100a5c9db588e6167;hb=29a52105283ce8ced672ed92545daeacf882316a;hpb=70fdb1a1e8e2660c383079ae49bc94fbe14943d1 diff --git a/dali-toolkit/internal/text/text-effects-style.cpp b/dali-toolkit/internal/text/text-effects-style.cpp index 38145dc..8d552d4 100644 --- a/dali-toolkit/internal/text/text-effects-style.cpp +++ b/dali-toolkit/internal/text/text-effects-style.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include namespace Dali { @@ -37,6 +39,9 @@ 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"); +const std::string TYPE_KEY("type"); +const std::string DASH_WIDTH_KEY("dashWidth"); +const std::string DASH_GAP_KEY("dashGap"); const std::string TRUE_TOKEN("true"); const std::string FALSE_TOKEN("false"); } // namespace @@ -106,12 +111,18 @@ bool ParseShadowProperties(const Property::Map& shadowPropertiesMap, return 0u == numberOfItems; } -bool ParseUnderlineProperties(const Property::Map& underlinePropertiesMap, - bool& enabled, - bool& colorDefined, - Vector4& color, - bool& heightDefined, - float& height) +bool ParseUnderlineProperties(const Property::Map& underlinePropertiesMap, + bool& enabled, + bool& colorDefined, + Vector4& color, + bool& heightDefined, + float& height, + bool& typeDefined, + Text::Underline::Type& type, + bool& dashWidthDefined, + float& dashWidth, + bool& dashGapDefined, + float& dashGap) { const unsigned int numberOfItems = underlinePropertiesMap.Count(); @@ -163,6 +174,51 @@ bool ParseUnderlineProperties(const Property::Map& underlinePropertiesMap, height = valueGet.second.Get(); } } + else if((DevelText::Underline::Property::TYPE == valueGet.first.indexKey) || (TYPE_KEY == valueGet.first.stringKey)) + { + /// Underline Type key. + typeDefined = true; + + if(valueGet.second.GetType() == Dali::Property::STRING) + { + const std::string typeStr = valueGet.second.Get(); + Text::UnderlineTypeStringToTypeValue(typeStr.c_str(), typeStr.size(), type); + } + else + { + type = valueGet.second.Get(); + } + } + else if((DevelText::Underline::Property::DASH_WIDTH == valueGet.first.indexKey) || (DASH_WIDTH_KEY == valueGet.first.stringKey)) + { + /// Dashed Underline Width key. + dashWidthDefined = true; + + if(valueGet.second.GetType() == Dali::Property::STRING) + { + const std::string dashWidthStr = valueGet.second.Get(); + dashWidth = StringToFloat(dashWidthStr.c_str()); + } + else + { + dashWidth = valueGet.second.Get(); + } + } + else if((DevelText::Underline::Property::DASH_GAP == valueGet.first.indexKey) || (DASH_GAP_KEY == valueGet.first.stringKey)) + { + /// Dashed Underline Gap key. + dashGapDefined = true; + + if(valueGet.second.GetType() == Dali::Property::STRING) + { + const std::string dashGapStr = valueGet.second.Get(); + dashGap = StringToFloat(dashGapStr.c_str()); + } + else + { + dashGap = valueGet.second.Get(); + } + } } return 0u == numberOfItems; @@ -299,11 +355,17 @@ bool SetUnderlineProperties(ControllerPtr controller, const Property::Value& val { const Property::Map& propertiesMap = value.Get(); - bool enabled = false; - bool colorDefined = false; - Vector4 color; - bool heightDefined = false; - float height = 0.f; + bool enabled = false; + bool colorDefined = false; + Vector4 color; + bool heightDefined = false; + float height = 0.f; + bool typeDefined = false; + Text::Underline::Type type; + bool dashWidthDefined = false; + float dashWidth = 2.0f; + bool dashGapDefined = false; + float dashGap = 1.0f; bool empty = true; @@ -322,7 +384,13 @@ bool SetUnderlineProperties(ControllerPtr controller, const Property::Value& val colorDefined, color, heightDefined, - height); + height, + typeDefined, + type, + dashWidthDefined, + dashWidth, + dashGapDefined, + dashGap); controller->UnderlineSetByString(!empty); } @@ -334,7 +402,13 @@ bool SetUnderlineProperties(ControllerPtr controller, const Property::Value& val colorDefined, color, heightDefined, - height); + height, + typeDefined, + type, + dashWidthDefined, + dashWidth, + dashGapDefined, + dashGap); controller->UnderlineSetByString(false); } @@ -359,6 +433,24 @@ bool SetUnderlineProperties(ControllerPtr controller, const Property::Value& val controller->SetUnderlineHeight(height); update = true; } + + if(typeDefined && (controller->GetUnderlineType() != type)) + { + controller->SetUnderlineType(type); + update = true; + } + + if(dashWidthDefined && (fabsf(controller->GetDashedUnderlineWidth() - dashWidth) > Math::MACHINE_EPSILON_1000)) + { + controller->SetDashedUnderlineWidth(dashWidth); + update = true; + } + + if(dashGapDefined && (fabsf(controller->GetDashedUnderlineGap() - dashGap) > Math::MACHINE_EPSILON_1000)) + { + controller->SetDashedUnderlineGap(dashGap); + update = true; + } } else { @@ -392,9 +484,12 @@ void GetUnderlineProperties(ControllerPtr controller, Property::Value& value, Ef { case EffectStyle::DEFAULT: { - const bool enabled = controller->IsUnderlineEnabled(); - const Vector4& color = controller->GetUnderlineColor(); - const float height = controller->GetUnderlineHeight(); + const bool enabled = controller->IsUnderlineEnabled(); + const Vector4& color = controller->GetUnderlineColor(); + const float height = controller->GetUnderlineHeight(); + const Text::Underline::Type type = controller->GetUnderlineType(); + const float dashWidth = controller->GetDashedUnderlineWidth(); + const float dashGap = controller->GetDashedUnderlineGap(); if(controller->IsUnderlineSetByString()) { @@ -408,7 +503,19 @@ void GetUnderlineProperties(ControllerPtr controller, Property::Value& value, Ef std::string heightStr; FloatToString(height, heightStr); - underlineProperties += "\"height\":\"" + heightStr + "\"}"; + underlineProperties += "\"height\":\"" + heightStr + "\","; + + std::string typeStr; + typeStr = GetUnderlineTypeToString(type); + underlineProperties += "\"type\":\"" + typeStr + "\","; + + std::string dashWidthStr; + FloatToString(dashWidth, dashWidthStr); + underlineProperties += "\"dashWidth\":\"" + dashWidthStr + "\","; + + std::string dashGapStr; + FloatToString(dashGap, dashGapStr); + underlineProperties += "\"dashGap\":\"" + dashGapStr + "\"}"; value = underlineProperties; } @@ -419,6 +526,9 @@ void GetUnderlineProperties(ControllerPtr controller, Property::Value& value, Ef map.Insert(ENABLE_KEY, enabled); map.Insert(COLOR_KEY, color); map.Insert(HEIGHT_KEY, height); + map.Insert(TYPE_KEY, type); + map.Insert(DASH_WIDTH_KEY, dashWidth); + map.Insert(DASH_GAP_KEY, dashGap); value = map; }