X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.cpp;h=5a18bef4a46705dfdcc1c3b38f29f720488efd95;hp=e4ef639d9c40602bcb9f303066eb5814ee0e4d8e;hb=ced87ad561e5fd73b23c8abaa397b206448a2b4b;hpb=e2fbffea1d7c5d3df04b025247c1a77377a3f0c3 diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index e4ef639..5a18bef 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -179,9 +179,10 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U } else { + // load configuration map + LoadConfiguration( *parser.GetRoot(), mConfigurationMap ); // load constant map (allows the user to override the constants in the json after loading) LoadConstants( *parser.GetRoot(), mReplacementMap ); - // merge includes if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) ) { @@ -201,7 +202,12 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U } } - if( !mParser.Parse( data ) ) + if( mParser.Parse( data ) ) + { + // Drop the styles and get them to be rebuilt against the new parse tree as required. + mStyles.Clear(); + } + else { DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n", mParser.GetErrorLineNumber(), @@ -212,8 +218,8 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U } } - DUMP_PARSE_TREE(parser); // This macro only writes out if DEBUG is enabled and the "DUMP_TREE" constant is defined in the stylesheet. - DUMP_TEST_MAPPINGS(parser); + DUMP_PARSE_TREE(mParser); // This macro only writes out if DEBUG is enabled and the "DUMP_TREE" constant is defined in the stylesheet. + DUMP_TEST_MAPPINGS(mParser); DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON"); } @@ -228,6 +234,11 @@ void Builder::AddConstant( const std::string& key, const Property::Value& value mReplacementMap[key] = value; } +const Property::Map& Builder::GetConfigurations() const +{ + return mConfigurationMap; +} + const Property::Map& Builder::GetConstants() const { return mReplacementMap; @@ -773,6 +784,25 @@ Builder::~Builder() { } +void Builder::LoadConfiguration( const TreeNode& root, Property::Map& intoMap ) +{ + Replacement replacer(intoMap); + + if( OptionalChild constants = IsChild(root, "config") ) + { + for(TreeNode::ConstIterator iter = (*constants).CBegin(); + iter != (*constants).CEnd(); ++iter) + { + Dali::Property::Value property; + if( (*iter).second.GetName() ) + { + DeterminePropertyFromNode( (*iter).second, property, replacer ); + intoMap[ (*iter).second.GetName() ] = property; + } + } + } +} + void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap ) { Replacement replacer(intoMap);