Merge "Added actor creation from json snippet" into tizen
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 3 Sep 2014 12:05:54 +0000 (05:05 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 3 Sep 2014 12:05:54 +0000 (05:05 -0700)
1  2 
base/dali-toolkit/internal/builder/builder-impl.cpp

@@@ -507,7 -507,9 +507,7 @@@ BaseHandle Builder::DoCreate( const Tre
          }
        }
  
 -      ApplyProperties( root, node, handle, replacements );
 -
 -      if( actor)
 +      if( actor )
        {
          // add children of all the styles
          if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
            parent.Add( actor );
          }
        }
 -
 +      else
 +      {
 +        ApplyProperties( root, node, handle, replacements );
 +      }
      }
      else
      {
@@@ -1030,6 -1029,44 +1030,44 @@@ BaseHandle Builder::Create( const std::
    return baseHandle;
  }
  
+ BaseHandle Builder::CreateFromJson( const std::string& json )
+ {
+   BaseHandle ret;
+   // merge in new template, hoping no one else has one named '@temp@'
+   std::string newTemplate =
+     std::string("{\"templates\":{\"@temp@\":") +                      \
+     json +                                                            \
+     std::string("}}");
+   if( mParser.Parse(newTemplate) )
+   {
+     Replacement replacement( mReplacementMap );
+     ret = Create( "@temp@", replacement );
+   }
+   return ret;
+ }
+ bool Builder::ApplyFromJson(  Handle& handle, const std::string& json )
+ {
+   bool ret = false;
+   // merge new style, hoping no one else has one named '@temp@'
+   std::string newStyle =
+     std::string("{\"styles\":{\"@temp@\":") +                           \
+     json +                                                              \
+     std::string("}}");
+   if( mParser.Parse(newStyle) )
+   {
+     Replacement replacement( mReplacementMap );
+     ret = ApplyStyle( "@temp@", handle, replacement );
+   }
+   return ret;
+ }
  
  BaseHandle Builder::Create( const std::string& templateName )
  {