Text - UNDERLINE, SHADOW, INPUT_UNDERLINE and INPUT_SHADOW properties refactor. 17/94217/10
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 27 Oct 2016 08:04:45 +0000 (09:04 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Tue, 1 Nov 2016 11:50:00 +0000 (04:50 -0700)
* These two properties are currently implemented with a json map encoded inside a string.
  This patch replaces this string by a property map.

Change-Id: I96c3c873bb2df69069d94d87fa29ef9de0d7db5b
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/text/text-effects-style.cpp
dali-toolkit/internal/text/text-effects-style.h
dali-toolkit/internal/visuals/text/text-visual.cpp

index 1532883913d8217b9e83382f728ff74ce9d89e39..022695daa11283e3c5d7c8de3c2655f22bf43bf6 100644 (file)
@@ -542,16 +542,36 @@ int UtcDaliTextEditorSetPropertyP(void)
   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   // Check the underline property
-  editor.SetProperty( TextEditor::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
-  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
+
+  Property::Map underlineMapSet;
+  Property::Map underlineMapGet;
+
+  underlineMapSet.Insert( "enable", "true" );
+  underlineMapSet.Insert( "color", "red" );
+  underlineMapSet.Insert( "height", "1" );
+
+  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( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
 
   // Check the input underline property
   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
 
   // Check the shadow property
-  editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
-  DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION );
+  Property::Map shadowMapSet;
+  Property::Map shadowMapGet;
+
+  shadowMapSet.Insert( "color", "green" );
+  shadowMapSet.Insert( "offset", "2 2" );
+
+  editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
+
+  shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
+  DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
 
   // Check the input shadow property
   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
index d72f2321335ed61138c35cd6a451b98275defd67..7dffc693e35b54cca448e276e4d0d25d051f13ba 100644 (file)
@@ -712,17 +712,36 @@ int UtcDaliTextFieldSetPropertyP(void)
   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
 
+  Property::Map underlineMapSet;
+  Property::Map underlineMapGet;
+
+  underlineMapSet.Insert( "enable", "true" );
+  underlineMapSet.Insert( "color", "red" );
+  underlineMapSet.Insert( "height", "1" );
+
   // Check the underline property
-  field.SetProperty( TextField::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
+  field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
+
+  underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
+  DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
 
   // Check the input underline property
   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
 
   // Check the shadow property
-  field.SetProperty( TextField::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION );
+  Property::Map shadowMapSet;
+  Property::Map shadowMapGet;
+
+  shadowMapSet.Insert( "color", "green" );
+  shadowMapSet.Insert( "offset", "2 2" );
+
+  field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
+
+  shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
+  DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
 
   // Check the input shadow property
   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
index 82615306429df1684ea99d3bae37b741838fe09f..1045ad425d85f96107e78d73630612f0d121aad1 100644 (file)
@@ -299,7 +299,16 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   // The underline color is changed as well.
   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
 
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"false\",\"color\":\"blue\",\"height\":\"0\"}"), TEST_LOCATION );
+  Property::Map underlineMapSet;
+  Property::Map underlineMapGet;
+
+  underlineMapSet.Insert( "enable", "false" );
+  underlineMapSet.Insert( "color", "blue" );
+  underlineMapSet.Insert( "height", "0" );
+
+  underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
+  DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
 
   // Check that shadow parameters can be correctly set
   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
@@ -345,18 +354,54 @@ int UtcDaliToolkitTextLabelSetPropertyP(void)
   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   // Check the underline property
-  label.SetProperty( TextLabel::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
 
-  label.SetProperty( TextLabel::Property::UNDERLINE, "" );
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"false\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
+  underlineMapSet.Clear();
+  underlineMapSet.Insert( "enable", "true" );
+  underlineMapSet.Insert( "color", "red" );
+  underlineMapSet.Insert( "height", "1" );
+
+  label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
+
+  underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
+  DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
+
+  underlineMapSet.Clear();
+
+  Property::Map underlineDisabledMapGet;
+  underlineDisabledMapGet.Insert( "enable", "false" );
+  underlineDisabledMapGet.Insert( "color", "red" );
+  underlineDisabledMapGet.Insert( "height", "1" );
+
+  label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
+  underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
+  DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
 
   // Check the shadow property
-  label.SetProperty( TextLabel::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION );
 
-  label.SetProperty( TextLabel::Property::SHADOW, "" );
-  DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"0 0\"}"), TEST_LOCATION );
+  Property::Map shadowMapSet;
+  Property::Map shadowMapGet;
+
+  shadowMapSet.Insert( "color", "green" );
+  shadowMapSet.Insert( "offset", "2 2" );
+
+  label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
+
+  shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
+  DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
+
+  shadowMapSet.Clear();
+  Property::Map shadowDisabledMapGet;
+  shadowDisabledMapGet.Insert( "color", "green" );
+  shadowDisabledMapGet.Insert( "offset", "0 0" );
+
+  label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
+
+  shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
+  DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
 
   // Check the emboss property
   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
index 274f40edbec32e88803c0cbd38ef705e53143e62..273ffee8966001a82c29bf86d1459149c2d9f2cd 100644 (file)
@@ -173,11 +173,11 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           Vector4 color;
           bool offsetDefined = false;
           Vector2 offset;
-          const bool empty = Text::ParseProperties( value.Get<std::string>(),
-                                                    colorDefined,
-                                                    color,
-                                                    offsetDefined,
-                                                    offset );
+          const bool empty = Text::ParseShadowProperties( value.Get<Property::Map>(),
+                                                          colorDefined,
+                                                          color,
+                                                          offsetDefined,
+                                                          offset );
 
           if( !empty )
           {
@@ -191,11 +191,11 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           Vector4 color;
           bool offsetDefined = false;
           Vector2 offset;
-          const bool empty = Text::ParseProperties( value.Get<std::string>(),
-                                                    colorDefined,
-                                                    color,
-                                                    offsetDefined,
-                                                    offset );
+          const bool empty = Text::ParseShadowProperties( value.Get<Property::Map>(),
+                                                          colorDefined,
+                                                          color,
+                                                          offsetDefined,
+                                                          offset );
 
           if( !empty )
           {
@@ -210,12 +210,12 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           Vector4 color;
           bool heightDefined = false;
           float height = 0.f;
-          const bool empty = Text::ParseProperties( value.Get<std::string>(),
-                                                    enabled,
-                                                    colorDefined,
-                                                    color,
-                                                    heightDefined,
-                                                    height );
+          const bool empty = Text::ParseUnderlineProperties( value.Get<Property::Map>(),
+                                                             enabled,
+                                                             colorDefined,
+                                                             color,
+                                                             heightDefined,
+                                                             height );
 
           if( !empty )
           {
@@ -230,12 +230,12 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           Vector4 color;
           bool heightDefined = false;
           float height = 0.f;
-          const bool empty = Text::ParseProperties( value.Get<std::string>(),
-                                                    enabled,
-                                                    colorDefined,
-                                                    color,
-                                                    heightDefined,
-                                                    height );
+          const bool empty = Text::ParseUnderlineProperties( value.Get<Property::Map>(),
+                                                             enabled,
+                                                             colorDefined,
+                                                             color,
+                                                             heightDefined,
+                                                             height );
 
           if( !empty && colorDefined )
           {
@@ -250,12 +250,12 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
           Vector4 color;
           bool heightDefined = false;
           float height = 0.f;
-          const bool empty = Text::ParseProperties( value.Get<std::string>(),
-                                                    enabled,
-                                                    colorDefined,
-                                                    color,
-                                                    heightDefined,
-                                                    height );
+          const bool empty = Text::ParseUnderlineProperties( value.Get<Property::Map>(),
+                                                             enabled,
+                                                             colorDefined,
+                                                             color,
+                                                             heightDefined,
+                                                             height );
 
           if( !empty && heightDefined )
           {
index 083cf47e5b25ba301ea5030bb8052ed0233c1449..44302d77ffcc21f62803af3b40671e88cf3ba8bf 100644 (file)
@@ -38,99 +38,86 @@ const std::string OFFSET_KEY( "offset" );
 const std::string HEIGHT_KEY( "height" );
 const std::string ENABLE_KEY( "enable" );
 const std::string TRUE_TOKEN( "true" );
+const std::string FALSE_TOKEN( "false" );
 }
 
-bool ParseProperties( const std::string& shadowProperties,
-                      bool& colorDefined,
-                      Vector4& color,
-                      bool& offsetDefined,
-                      Vector2& offset )
+bool ParseShadowProperties( const Property::Map& shadowPropertiesMap,
+                            bool& colorDefined,
+                            Vector4& color,
+                            bool& offsetDefined,
+                            Vector2& offset )
 {
-  // Parses and applies the style.
-  Property::Map map;
-  Text::ParsePropertyString( shadowProperties, map );
-
-  const bool empty = map.Empty();
+  const unsigned int numberOfItems = shadowPropertiesMap.Count();
 
-  if( !empty )
+  // Parses and applies the style.
+  for( unsigned int index = 0u; index < numberOfItems; ++index )
   {
-    /// Color key.
-    Property::Value* colorValue = map.Find( COLOR_KEY );
+    const KeyValuePair& valueGet = shadowPropertiesMap.GetKeyValue( index );
 
-    colorDefined = colorValue != NULL;
-    if( colorDefined )
+    if( COLOR_KEY == valueGet.first.stringKey )
     {
-      const std::string colorStr = colorValue->Get<std::string>();
+      /// Color key.
+      colorDefined = true;
+
+      const std::string colorStr = valueGet.second.Get<std::string>();
 
       Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
     }
-
-    /// Offset key.
-    Property::Value* offsetValue = map.Find( OFFSET_KEY );
-
-    offsetDefined = offsetValue != NULL;
-    if( offsetDefined )
+    else if( OFFSET_KEY == valueGet.first.stringKey )
     {
-      const std::string offsetStr = offsetValue->Get<std::string>();
+      /// Offset key.
+      offsetDefined = true;
+
+      const std::string offsetStr = valueGet.second.Get<std::string>();
 
       StringToVector2( offsetStr.c_str(), offsetStr.size(), offset );
     }
   }
 
-  return empty;
+  return 0u == numberOfItems;
 }
 
-bool ParseProperties( const std::string& underlineProperties,
-                      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 )
 {
-  // Parses and applies the style.
-  Property::Map map;
-  Text::ParsePropertyString( underlineProperties, map );
+  const unsigned int numberOfItems = underlinePropertiesMap.Count();
 
-  const bool empty = map.Empty();
-
-  if( !empty )
+  // Parses and applies the style.
+  for( unsigned int index = 0u; index < numberOfItems; ++index )
   {
-    /// Enable key.
-    Property::Value* enableValue = map.Find( ENABLE_KEY );
+    const KeyValuePair& valueGet = underlinePropertiesMap.GetKeyValue( index );
 
-    enabled = false;
-    const bool enabledDefined = enableValue != NULL;
-    if( enabledDefined )
+    if( ENABLE_KEY == valueGet.first.stringKey )
     {
-      const std::string enableStr = enableValue->Get<std::string>();
+      /// Enable key.
+      const std::string enableStr = valueGet.second.Get<std::string>();
       enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
     }
-
-    /// Color key.
-    Property::Value* colorValue = map.Find( COLOR_KEY );
-
-    colorDefined = colorValue != NULL;
-    if( colorDefined )
+    else if( COLOR_KEY == valueGet.first.stringKey )
     {
-      const std::string colorStr = colorValue->Get<std::string>();
+      /// Color key.
+      colorDefined = true;
+
+      const std::string colorStr = valueGet.second.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 )
+    else if( HEIGHT_KEY == valueGet.first.stringKey )
     {
-      const std::string heightStr = heightValue->Get<std::string>();
+      /// Height key.
+      heightDefined = true;
+
+      const std::string heightStr = valueGet.second.Get<std::string>();
 
       height = StringToFloat( heightStr.c_str() );
     }
   }
 
-  return empty;
+  return 0u == numberOfItems;
 }
 
 bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type )
@@ -139,26 +126,26 @@ bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& va
 
   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 )
     {
-      switch( type )
+      case EffectStyle::DEFAULT:
       {
-        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;
+
+        const bool empty = ParseUnderlineProperties( propertiesMap,
+                                                     enabled,
+                                                     colorDefined,
+                                                     color,
+                                                     heightDefined,
+                                                     height );
+
+        if( !empty )
         {
           if( enabled != controller->IsUnderlineEnabled() )
           {
@@ -178,21 +165,8 @@ bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& va
             controller->SetUnderlineHeight( height );
             update = true;
           }
-          break;
         }
-        case EffectStyle::INPUT:
-        {
-          // Sets the input underline values.
-          // TODO: to be implemented.
-          break;
-        }
-      }
-    }
-    else
-    {
-      switch( type )
-      {
-        case EffectStyle::DEFAULT:
+        else
         {
           // Disable underline.
           if( controller->IsUnderlineEnabled() )
@@ -200,18 +174,18 @@ bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& va
             controller->SetUnderlineEnabled( false );
             update = true;
           }
-          break;
-        }
-        case EffectStyle::INPUT:
-        {
-          // Sets the input underline values.
-          // TODO: to be implemented.
-          controller->SetInputUnderlineProperties( properties );
-          break;
         }
+        break;
       }
-    }
-  }
+      case EffectStyle::INPUT:
+      {
+        const std::string& underlineProperties = value.Get<std::string>();
+
+        controller->SetInputUnderlineProperties( underlineProperties );
+        break;
+      }
+    } // switch
+  } // if( controller )
 
   return update;
 }
@@ -228,19 +202,20 @@ void GetUnderlineProperties( ControllerPtr controller, Property::Value& value, E
         const Vector4& color = controller->GetUnderlineColor();
         const float height = controller->GetUnderlineHeight();
 
-        std::string underlineProperties = "{\"enable\":";
-        const std::string enabledStr = enabled ? "true" : "false";
-        underlineProperties += "\"" + enabledStr + "\",";
+        Property::Map map;
+
+        const std::string enabledStr = enabled ? TRUE_TOKEN : FALSE_TOKEN;
+        map.Insert( ENABLE_KEY, enabledStr );
 
         std::string colorStr;
         Vector4ToColorString( color, colorStr );
-        underlineProperties += "\"color\":\"" + colorStr + "\",";
+        map.Insert( COLOR_KEY, colorStr );
 
         std::string heightStr;
         FloatToString( height, heightStr );
-        underlineProperties += "\"height\":\"" + heightStr + "\"}";
+        map.Insert( HEIGHT_KEY, heightStr );
 
-        value = underlineProperties;
+        value = map;
         break;
       }
       case EffectStyle::INPUT:
@@ -258,24 +233,24 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value
 
   if( controller )
   {
-    const std::string properties = value.Get< std::string >();
+    switch( type )
+    {
+      case EffectStyle::DEFAULT:
+      {
+        const Property::Map& propertiesMap = value.Get<Property::Map>();
 
-    bool colorDefined = false;
-    Vector4 color;
-    bool offsetDefined = false;
-    Vector2 offset;
+        bool colorDefined = false;
+        Vector4 color;
+        bool offsetDefined = false;
+        Vector2 offset;
 
-    const bool empty = ParseProperties( properties,
-                                        colorDefined,
-                                        color,
-                                        offsetDefined,
-                                        offset );
+        const bool empty = ParseShadowProperties( propertiesMap,
+                                                  colorDefined,
+                                                  color,
+                                                  offsetDefined,
+                                                  offset );
 
-    if( !empty )
-    {
-      switch( type )
-      {
-        case EffectStyle::DEFAULT:
+        if( !empty )
         {
           // Sets the default shadow values.
           if( colorDefined && ( controller->GetShadowColor() != color ) )
@@ -289,39 +264,26 @@ bool SetShadowProperties( ControllerPtr controller, const Property::Value& value
             controller->SetShadowOffset( offset );
             update = true;
           }
-          break;
         }
-        case EffectStyle::INPUT:
-        {
-          // Sets the input shadow values.
-          // TODO: to be implemented.
-          break;
-        }
-      }
-    }
-    else
-    {
-      switch( type )
-      {
-        case EffectStyle::DEFAULT:
+        else
         {
           // Disable shadow.
           if( Vector2::ZERO != controller->GetShadowOffset() )
           {
             controller->SetShadowOffset( Vector2::ZERO );
           }
-          break;
-        }
-        case EffectStyle::INPUT:
-        {
-          // Sets the input shadow values.
-          // TODO: to be implemented.
-          controller->SetInputShadowProperties( properties );
-          break;
         }
+        break;
       }
-    }
-  }
+      case EffectStyle::INPUT:
+      {
+        const std::string& shadowString = value.Get<std::string>();
+
+        controller->SetInputShadowProperties( shadowString );
+        break;
+      }
+    } // switch
+  } // if( controller )
 
   return update;
 }
@@ -337,17 +299,17 @@ void GetShadowProperties( ControllerPtr controller, Property::Value& value, Effe
         const Vector4& color = controller->GetShadowColor();
         const Vector2& offset = controller->GetShadowOffset();
 
-        std::string shadowProperties = "{";
+        Property::Map map;
 
         std::string colorStr;
         Vector4ToColorString( color, colorStr );
-        shadowProperties += "\"color\":\"" + colorStr + "\",";
+        map.Insert( COLOR_KEY, colorStr );
 
         std::string offsetStr;
         Vector2ToString( offset, offsetStr );
-        shadowProperties += "\"offset\":\"" + offsetStr + "\"}";
+        map.Insert( OFFSET_KEY, offsetStr );
 
-        value = shadowProperties;
+        value = map;
         break;
       }
       case EffectStyle::INPUT:
index fb21fe9b95473380d67d135a71dcbb6b3f4697f5..4ab61a3ef3a9ee0531e2ad68422f0009f3e0f0de 100644 (file)
@@ -42,32 +42,34 @@ namespace EffectStyle
 /**
  * @brief Parses the shadow properties.
  *
+ * @param[in] shadowProperties The map with the shadow properties.
  * @param[out] colorDefined Whether the shadow's color is defined.
  * @param[out] color The shadow's color.
  * @param[out] offsetDefined Whether the shadow's offset is defined.
  * @param[out] offset The shadow's offset.
  */
-bool ParseProperties( const std::string& shadowProperties,
-                      bool& colorDefined,
-                      Vector4& color,
-                      bool& offsetDefined,
-                      Vector2& offset );
+bool ParseShadowProperties( const Property::Map& shadowProperties,
+                            bool& colorDefined,
+                            Vector4& color,
+                            bool& offsetDefined,
+                            Vector2& offset );
 
 /**
  * @brief Parses the underline properties.
  *
+ * @param[in] underlineProperties The map with the underline properties.
  * @param[out] enabled Whether the underline is enabled.
  * @param[out] colorDefined Whether the underline's color is defined.
  * @param[out] color The underline's color.
  * @param[out] heightDefined Whether the underline's height is defined.
  * @param[out] height The underline's height.
  */
-bool ParseProperties( const std::string& underlineProperties,
-                      bool& enabled,
-                      bool& colorDefined,
-                      Vector4& color,
-                      bool& heightDefined,
-                      float& height );
+bool ParseUnderlineProperties( const Property::Map& underlineProperties,
+                               bool& enabled,
+                               bool& colorDefined,
+                               Vector4& color,
+                               bool& heightDefined,
+                               float& height );
 
 /**
  * @brief Sets the underline properties.
index abaa703c15ef044d68a512f8ea77b72d071b9fd3..c597e27aa647ec529aaf0d25061dce3893804da7 100644 (file)
@@ -554,7 +554,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
     case Toolkit::TextVisual::Property::UNDERLINE:
     {
       // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
-      //        Only the code for the STRING case should be kept.
+      //        Only the code for the MAP case should be kept.
       switch( propertyValue.GetType() )
       {
         case Property::VECTOR4:
@@ -587,7 +587,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
           }
           break;
         }
-        case Property::STRING:
+        case Property::MAP:
         {
           const bool update = SetUnderlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
           if( update )
@@ -608,7 +608,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
     case Toolkit::TextVisual::Property::SHADOW:
     {
       // TODO : This switch can be removed when the deprecated SHADOW_OFFSET and SHADOW_COLOR properties are finally removed.
-      //        Only the code for the STRING case should be kept.
+      //        Only the code for the MAP case should be kept.
       switch( propertyValue.GetType() )
       {
         case Property::VECTOR2:
@@ -631,7 +631,7 @@ void TextVisual::DoSetProperty( Dali::Property::Index index, const Dali::Propert
           }
           break;
         }
-        case Property::STRING:
+        case Property::MAP:
         {
           const bool update = SetShadowProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
           if( update )