+bool SetBackgroundProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type)
+{
+ bool update = false;
+
+ if(controller)
+ {
+ switch(type)
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const Property::Map& propertiesMap = value.Get<Property::Map>();
+
+ bool enabled = false;
+ bool colorDefined = false;
+ Vector4 color;
+
+ bool empty = true;
+
+ if(!propertiesMap.Empty())
+ {
+ empty = ParseBackgroundProperties(propertiesMap,
+ enabled,
+ colorDefined,
+ color);
+ }
+
+ if(!empty)
+ {
+ if(enabled != controller->IsBackgroundEnabled())
+ {
+ controller->SetBackgroundEnabled(enabled);
+ update = true;
+ }
+
+ if(colorDefined && (controller->GetBackgroundColor() != color))
+ {
+ controller->SetBackgroundColor(color);
+ update = true;
+ }
+ }
+ else
+ {
+ // Disable background.
+ if(controller->IsBackgroundEnabled())
+ {
+ controller->SetBackgroundEnabled(false);
+ update = true;
+ }
+ }
+ break;
+ }
+ case EffectStyle::INPUT:
+ {
+ // Text background is not supported while inputting yet
+ break;
+ }
+ } // switch
+ } // if( controller )
+
+ return update;
+}
+
+void GetBackgroundProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type)
+{
+ if(controller)
+ {
+ switch(type)
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const bool enabled = controller->IsBackgroundEnabled();
+ const Vector4& color = controller->GetBackgroundColor();
+
+ Property::Map map;
+ map.Insert(ENABLE_KEY, enabled);
+ map.Insert(COLOR_KEY, color);
+
+ value = map;
+
+ break;
+ }
+ case EffectStyle::INPUT:
+ {
+ // Text background is not supported while inputting yet
+ break;
+ }
+ }
+ }
+}
+
+bool SetStrikethroughProperties(ControllerPtr controller, const Property::Value& value, EffectStyle::Type type)
+{
+ bool update = false;
+
+ if(controller)
+ {
+ switch(type)
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const Property::Map& propertiesMap = value.Get<Property::Map>();
+
+ bool enabled = false;
+ bool colorDefined = false;
+ Vector4 color;
+ bool heightDefined = false;
+ float height = 0.f;
+
+ bool empty = true;
+
+ if(propertiesMap.Empty())
+ {
+ // Map empty so check if a string provided
+ const std::string propertyString = value.Get<std::string>();
+
+ if(!propertyString.empty())
+ {
+ Property::Map parsedStringMap;
+ Text::ParsePropertyString(propertyString, parsedStringMap);
+
+ empty = ParseStrikethroughProperties(parsedStringMap,
+ enabled,
+ colorDefined,
+ color,
+ heightDefined,
+ height);
+
+ controller->StrikethroughSetByString(!empty);
+ }
+ }
+ else
+ {
+ empty = ParseStrikethroughProperties(propertiesMap,
+ enabled,
+ colorDefined,
+ color,
+ heightDefined,
+ height);
+
+ controller->StrikethroughSetByString(false);
+ }
+
+ if(!empty)
+ {
+ if(enabled != controller->IsStrikethroughEnabled())
+ {
+ controller->SetStrikethroughEnabled(enabled);
+ update = true;
+ }
+
+ // Sets the default strikethrough values.
+ if(colorDefined && (controller->GetStrikethroughColor() != color))
+ {
+ controller->SetStrikethroughColor(color);
+ update = true;
+ }
+ if(heightDefined && (fabsf(controller->GetStrikethroughHeight() - height) > Math::MACHINE_EPSILON_1000))
+ {
+ controller->SetStrikethroughHeight(height);
+ update = true;
+ }
+ }
+ else
+ {
+ // Disable strikethrough.
+ if(controller->IsStrikethroughEnabled())
+ {
+ controller->SetStrikethroughEnabled(false);
+ update = true;
+ }
+ }
+ break;
+ }
+ case EffectStyle::INPUT:
+ {
+ const std::string& strikethroughProperties = value.Get<std::string>();
+
+ controller->SetInputStrikethroughProperties(strikethroughProperties);
+ update = true;
+ break;
+ }
+ } // switch
+ } // if( controller )
+
+ return update;
+}
+
+void GetStrikethroughProperties(ControllerPtr controller, Property::Value& value, EffectStyle::Type type)
+{
+ if(controller)
+ {
+ switch(type)
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const bool enabled = controller->IsStrikethroughEnabled();
+ const Vector4& color = controller->GetStrikethroughColor();
+ const float height = controller->GetStrikethroughHeight();
+
+ if(controller->IsStrikethroughSetByString())
+ {
+ std::string strikethroughProperties = "{\"enable\":";
+ const std::string enabledStr = enabled ? "true" : "false";
+ strikethroughProperties += "\"" + enabledStr + "\",";
+
+ std::string colorStr;
+ Vector4ToColorString(color, colorStr);
+ strikethroughProperties += "\"color\":\"" + colorStr + "\",";
+
+ std::string heightStr;
+ FloatToString(height, heightStr);
+ strikethroughProperties += "\"height\":\"" + heightStr + "\"}";
+
+ value = strikethroughProperties;
+ }
+ else
+ {
+ Property::Map map;
+
+ map.Insert(ENABLE_KEY, enabled);
+ map.Insert(COLOR_KEY, color);
+ map.Insert(HEIGHT_KEY, height);
+
+ value = map;
+ }
+
+ break;
+ }
+ case EffectStyle::INPUT:
+ {
+ value = controller->GetInputStrikethroughProperties();
+ break;
+ }
+ }
+ }
+}
+
+Underline::Type StringToUnderlineType(const char* const underlineTypeStr)
+{
+ Underline::Type underlineType = Text::Underline::SOLID;
+ Scripting::GetEnumeration<Underline::Type>(underlineTypeStr,
+ UNDERLINE_TYPE_STRING_TABLE,
+ UNDERLINE_TYPE_STRING_TABLE_COUNT,
+ underlineType);
+
+ return underlineType;
+}
+