END_TEST;
}
+
+int utcDaliTextEditorUnderPropertyStringP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+
+ std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
+ DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
+
+ tet_infoline("Set underline settings with a map");
+ // Check the input underline property
+ Property::Map underlineMapSet;
+ Property::Map underlineMapGet;
+ underlineMapSet.Insert( "enable", "true" );
+ underlineMapSet.Insert( "color", "blue" );
+ underlineMapSet.Insert( "height", "2" );
+
+ editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
+ underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
+ DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
+
+ tet_infoline("Set underline settings with a string");
+ editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
+ Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
+ std::string result;
+ value.Get(result);
+ DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
+
+ tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
+ std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
+ editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
+ value = editor.GetProperty( TextEditor::Property::UNDERLINE );
+ value.Get(result);
+ DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextEditorShadowPropertyStringP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
+
+ TextEditor editor = TextEditor::New();
+
+ std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
+
+ Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
+ std::string result;
+ value.Get(result);
+
+ DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
+
+ END_TEST;
+}
mMarkupProcessorEnabled( false ),
mClipboardHideEnabled( true ),
mIsAutoScrollEnabled( false ),
- mAutoScrollDirectionRTL( false )
+ mAutoScrollDirectionRTL( false ),
+ mUnderlineSetByString( false ),
+ mShadowSetByString( false )
{
mModel = Model::New();
bool mIsAutoScrollEnabled:1; ///< Whether auto text scrolling is enabled.
CharacterDirection mAutoScrollDirectionRTL:1; ///< Direction of auto scrolling, true if rtl
+ bool mUnderlineSetByString:1; ///< Set when underline is set by string (legacy) instead of map
+ bool mShadowSetByString:1; ///< Set when shadow is set by string (legacy) instead of map
};
} // namespace Text
return action;
}
+bool Controller::IsUnderlineSetByString()
+{
+ return mImpl->mUnderlineSetByString;
+}
+
+void Controller::UnderlineSetByString( bool setByString )
+{
+ mImpl->mUnderlineSetByString = setByString;
+}
+
+bool Controller::IsShadowSetByString()
+{
+ return mImpl->mShadowSetByString;
+}
+
+void Controller::ShadowSetByString( bool setByString )
+{
+ mImpl->mShadowSetByString = setByString;
+}
+
// public : Queries & retrieves.
Layout::Engine& Controller::GetLayoutEngine()
*/
NoTextTap::Action GetNoTextLongPressAction() const;
+ /**
+ * @brief Query if Underline settings were provided by string or map
+ * @return bool true if set by string
+ */
+ bool IsUnderlineSetByString();
+
+ /**
+ * Set method underline setting were set by
+ * @param[in] bool, true if set by string
+ */
+ void UnderlineSetByString( bool setByString );
+
+ /**
+ * @brief Query if shadow settings were provided by string or map
+ * @return bool true if set by string
+ */
+ bool IsShadowSetByString();
+
+ /**
+ * Set method shadow setting were set by
+ * @param[in] bool, true if set by string
+ */
+ void ShadowSetByString( bool setByString );
+
public: // Update.
/**
bool heightDefined = false;
float height = 0.f;
- const bool empty = ParseUnderlineProperties( propertiesMap,
- enabled,
- colorDefined,
- color,
- heightDefined,
- height );
+ 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 = ParseUnderlineProperties( parsedStringMap,
+ enabled,
+ colorDefined,
+ color,
+ heightDefined,
+ height );
+
+ controller->UnderlineSetByString( !empty);
+ }
+ }
+ else
+ {
+ empty = ParseUnderlineProperties( propertiesMap,
+ enabled,
+ colorDefined,
+ color,
+ heightDefined,
+ height );
+
+ controller->UnderlineSetByString( false );
+ }
if( !empty )
{
const Vector4& color = controller->GetUnderlineColor();
const float height = controller->GetUnderlineHeight();
- Property::Map map;
+ if ( controller->IsUnderlineSetByString() )
+ {
+ std::string underlineProperties = "{\"enable\":";
+ const std::string enabledStr = enabled ? "true" : "false";
+ underlineProperties += "\"" + enabledStr + "\",";
+
+ std::string colorStr;
+ Vector4ToColorString( color, colorStr );
+ underlineProperties += "\"color\":\"" + colorStr + "\",";
+
+ std::string heightStr;
+ FloatToString( height, heightStr );
+ underlineProperties += "\"height\":\"" + heightStr + "\"}";
+
+ value = underlineProperties;
+ }
+ else
+ {
+ Property::Map map;
- const std::string enabledStr = enabled ? TRUE_TOKEN : FALSE_TOKEN;
- map.Insert( ENABLE_KEY, enabledStr );
+ const std::string enabledStr = enabled ? TRUE_TOKEN : FALSE_TOKEN;
+ map.Insert( ENABLE_KEY, enabledStr );
- std::string colorStr;
- Vector4ToColorString( color, colorStr );
- map.Insert( COLOR_KEY, colorStr );
+ std::string colorStr;
+ Vector4ToColorString( color, colorStr );
+ map.Insert( COLOR_KEY, colorStr );
- std::string heightStr;
- FloatToString( height, heightStr );
- map.Insert( HEIGHT_KEY, heightStr );
+ std::string heightStr;
+ FloatToString( height, heightStr );
+ map.Insert( HEIGHT_KEY, heightStr );
+
+ value = map;
+ }
- value = map;
break;
}
case EffectStyle::INPUT:
bool offsetDefined = false;
Vector2 offset;
- const bool empty = ParseShadowProperties( propertiesMap,
- colorDefined,
- color,
- offsetDefined,
- offset );
+ bool empty = true;
+
+ if ( propertiesMap.Empty() )
+ {
+ // Map empty so check if a string provided
+ const std::string propertyString = value.Get<std::string>();
+
+ Property::Map parsedStringMap;
+ Text::ParsePropertyString( propertyString, parsedStringMap );
+
+ empty = ParseShadowProperties( parsedStringMap,
+ colorDefined,
+ color,
+ offsetDefined,
+ offset );
+
+ controller->ShadowSetByString( !empty );
+
+ }
+ else
+ {
+ empty = ParseShadowProperties( propertiesMap,
+ colorDefined,
+ color,
+ offsetDefined,
+ offset );
+
+ controller->ShadowSetByString( false );
+ }
if( !empty )
{
const Vector4& color = controller->GetShadowColor();
const Vector2& offset = controller->GetShadowOffset();
- Property::Map map;
+ if ( controller->IsShadowSetByString() )
+ {
+ std::string shadowProperties = "{";
- std::string colorStr;
- Vector4ToColorString( color, colorStr );
- map.Insert( COLOR_KEY, colorStr );
+ std::string colorStr;
+ Vector4ToColorString( color, colorStr );
+ shadowProperties += "\"color\":\"" + colorStr + "\",";
- std::string offsetStr;
- Vector2ToString( offset, offsetStr );
- map.Insert( OFFSET_KEY, offsetStr );
+ std::string offsetStr;
+ Vector2ToString( offset, offsetStr );
+ shadowProperties += "\"offset\":\"" + offsetStr + "\"}";
- value = map;
+ value = shadowProperties;
+ }
+ else
+ {
+ 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 );
+
+ value = map;
+ }
break;
}
case EffectStyle::INPUT: