-void Builder::AddActors( Actor toActor )
-{
- // 'stage' is the default/by convention section to add from
- AddActors( "stage", toActor );
-}
-
-void Builder::AddActors( const std::string §ionName, Actor toActor )
-{
- DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
-
- Property::Map overrideMap;
- Replacement replacements(overrideMap, mReplacementMap);
-
- OptionalChild add = IsChild(*mParser.GetRoot(), sectionName);
-
- if( add )
- {
- for( TreeNode::ConstIterator iter = (*add).CBegin(); iter != (*add).CEnd(); ++iter )
- {
- // empty actor adds directly to the stage
- BaseHandle baseHandle = DoCreate( *mParser.GetRoot(), (*iter).second, Actor(), replacements );
- Actor actor = Actor::DownCast(baseHandle);
- if(actor)
- {
- toActor.Add( actor );
- }
- }
-
- // if were adding the 'stage' section then also check for a render task called stage
- // to add automatically
- if( "stage" == sectionName )
- {
- if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "renderTasks") )
- {
- if( OptionalChild tasks = IsChild(*renderTasks, "stage") )
- {
- CreateRenderTask( "stage" );
- }
- }
- }
- }
-}
-
-Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor )
-{
- DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
-
- Animation anim;
-
- if( OptionalChild animations = IsChild(*mParser.GetRoot(), "animations") )
- {
- if( OptionalChild animation = IsChild(*animations, animationName) )
- {
- anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, sourceActor, this );
- }
- else
- {
- DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed\n", animationName.c_str() );
- }
- }
- else
- {
- DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed (no animation section)\n", animationName.c_str() );
- }
-
- return anim;
-}
-
-Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor )
-{
- Replacement replacement(map, mReplacementMap);
- return CreateAnimation( animationName, replacement, sourceActor);
-}
-
-Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map )
-{
- Replacement replacement(map, mReplacementMap);
- return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() );
-}
-
-Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor )
-{
- Replacement replacement( mReplacementMap );
-
- return CreateAnimation( animationName, replacement, sourceActor );
-}
-
-Animation Builder::CreateAnimation( const std::string& animationName )
-{
- Replacement replacement( mReplacementMap );
-
- return CreateAnimation( animationName, replacement, Dali::Stage::GetCurrent().GetRootLayer() );
-}
-
-void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
-{
- // parser to get constants and includes only
- Dali::Toolkit::JsonParser parser = Dali::Toolkit::JsonParser::New();
-
- if( !parser.Parse( data ) )
- {
- DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
- parser.GetErrorLineNumber(),
- parser.GetErrorColumn(),
- parser.GetErrorDescription().c_str() );
-
- DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
- }
- else
- {
- // 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) )
- {
- Replacement replacer( mReplacementMap );
-
- for(TreeNode::ConstIterator iter = (*includes).CBegin(); iter != (*includes).CEnd(); ++iter)
- {
- OptionalString filename = replacer.IsString( (*iter).second );
-
- if( filename )
- {
-#if defined(DEBUG_ENABLED)
- DALI_SCRIPT_VERBOSE("Loading Include '%s'\n", (*filename).c_str());
-#endif
- LoadFromString( GetFileContents(*filename) );
- }
- }
- }
-
- if( !mParser.Parse( data ) )
- {
- DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
- mParser.GetErrorLineNumber(),
- mParser.GetErrorColumn(),
- mParser.GetErrorDescription().c_str() );
-
- DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
- }
- }
-
- DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON");
-}
-
-void Builder::AddConstants( const Property::Map& map )
-{
- mReplacementMap.Merge( map );
-}
-
-void Builder::AddConstant( const std::string& key, const Property::Value& value )
-{
- mReplacementMap[key] = value;
-}
-
-const Property::Map& Builder::GetConstants() const
-{
- return mReplacementMap;
-}
-
-const Property::Value& Builder::GetConstant( const std::string& key ) const