+ DALI_SCRIPT_WARNING("Constrainer type not specified for constrainer '%s'\n", name.c_str() );
+ }
+ else if( *constrainerType == "LinearConstrainer")
+ {
+ //points property
+ if( OptionalChild pointsProperty = IsChild( *linearConstrainer, "value") )
+ {
+ Dali::Property::Value points(Property::ARRAY);
+ if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) )
+ {
+ ret = Dali::LinearConstrainer::New();
+ ret.SetProperty( LinearConstrainer::Property::VALUE, points);
+
+ //controlPoints property
+ if( OptionalChild pointsProperty = IsChild( *linearConstrainer, "progress") )
+ {
+ Dali::Property::Value points(Property::ARRAY);
+ if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) )
+ {
+ ret.SetProperty( LinearConstrainer::Property::PROGRESS, points);
+ }
+ }
+ //Add the new constrainer to vector of LinearConstrainer
+ LinearConstrainerEntry entry = {name,ret};
+ mLinearConstrainerLut.push_back( entry );
+ }
+ }
+ else
+ {
+ //Interpolation points not specified
+ DALI_SCRIPT_WARNING("Values not specified for LinearConstrainer '%s'\n", name.c_str() );
+ }
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Constrainer '%s' is not a LinearConstrainer\n", name.c_str() );
+ }
+ }
+ }
+
+ return ret;
+}
+
+bool Builder::IsLinearConstrainer( const std::string& name )
+{
+ // Search the LinearConstrainer in the LUT
+ size_t count( mLinearConstrainerLut.size() );
+ for( size_t i(0); i!=count; ++i )
+ {
+ if( mLinearConstrainerLut[i].name == name )
+ {
+ return true;
+ }
+ }
+
+ if( OptionalChild constrainers = IsChild( *mParser.GetRoot(), "constrainers") )
+ {
+ if( OptionalChild constrainer = IsChild( *constrainers, name ) )
+ {
+ OptionalString constrainerType(IsString(IsChild(*constrainer, "type")));
+ if(!constrainerType)
+ {
+ return false;
+ }
+ else
+ {
+ return *constrainerType == "LinearConstrainer";
+ }
+ }
+ }
+ return false;
+}
+
+Toolkit::Builder::BuilderSignalType& Builder::QuitSignal()
+{
+ return mQuitSignal;
+}
+
+void Builder::EmitQuitSignal()
+{
+ mQuitSignal.Emit();
+}
+
+Builder::~Builder()
+{
+}
+
+void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap )
+{
+ Replacement replacer(intoMap);
+
+ if( OptionalChild constants = IsChild(root, "constants") )
+ {
+ for(TreeNode::ConstIterator iter = (*constants).CBegin();
+ iter != (*constants).CEnd(); ++iter)
+ {
+ Dali::Property::Value property;
+ if( (*iter).second.GetName() )
+ {
+#if defined(DEBUG_ENABLED)
+ DALI_SCRIPT_VERBOSE("Constant set from json '%s'\n", (*iter).second.GetName());
+#endif
+ DeterminePropertyFromNode( (*iter).second, property, replacer );
+ intoMap[ (*iter).second.GetName() ] = property;
+ }
+ }
+ }
+
+#if defined(DEBUG_ENABLED)
+ Property::Value* iter = intoMap.Find( "CONFIG_SCRIPT_LOG_LEVEL" );
+ if( iter && iter->GetType() == Property::STRING )
+ {
+ std::string logLevel( iter->Get< std::string >() );
+ if( logLevel == "NoLogging" )
+ {
+ gFilterScript->SetLogLevel( Integration::Log::NoLogging );
+ }
+ else if( logLevel == "Concise" )
+ {
+ gFilterScript->SetLogLevel( Integration::Log::Concise );
+ }
+ else if( logLevel == "General" )
+ {
+ gFilterScript->SetLogLevel( Integration::Log::General );
+ }
+ else if( logLevel == "Verbose" )
+ {
+ gFilterScript->SetLogLevel( Integration::Log::Verbose );
+ }
+ }
+#endif
+}
+
+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;
+}
+
+BaseHandle Builder::Create( const std::string& templateName, const Replacement& constant )
+{
+ DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
+
+ BaseHandle baseHandle;
+
+ OptionalChild templates = IsChild(*mParser.GetRoot(), KEYNAME_TEMPLATES);
+
+ if( !templates )
+ {
+ DALI_SCRIPT_WARNING("No template section found to CreateFromTemplate\n");
+ }
+ else
+ {
+ OptionalChild childTemplate = IsChild(*templates, templateName);
+ if(!childTemplate)
+ {
+ DALI_SCRIPT_WARNING("Template '%s' does not exist in template section\n", templateName.c_str());
+ }
+ else
+ {
+ OptionalString type = constant.IsString( IsChild(*childTemplate, KEYNAME_TYPE) );
+
+ if(!type)
+ {
+ DALI_SCRIPT_WARNING("Cannot create template '%s' as template section is missing 'type'\n", templateName.c_str());
+ }
+ else
+ {
+ baseHandle = DoCreate( *mParser.GetRoot(), *childTemplate, Actor(), constant );
+ }
+ }
+ }
+
+ return baseHandle;
+}
+
+/*
+ * Create a dali type from a node.
+ * If parent given and an actor type was created then add it to the parent and
+ * recursively add nodes children.
+ */
+BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node,
+ Actor parent, const Replacement& replacements )
+{
+ BaseHandle baseHandle;
+ TypeInfo typeInfo;
+ const TreeNode* templateNode = NULL;
+
+ if( OptionalString typeName = IsString(node, KEYNAME_TYPE) )
+ {
+ typeInfo = TypeRegistry::Get().GetTypeInfo( *typeName );
+
+ if( !typeInfo )
+ {
+ // a template name is also allowed inplace of the type name
+ OptionalChild templates = IsChild( root, KEYNAME_TEMPLATES);
+
+ if( templates )
+ {
+ if( OptionalChild isTemplate = IsChild( *templates, *typeName ) )
+ {
+ templateNode = &(*isTemplate);
+
+ if( OptionalString templateTypeName = IsString(*templateNode, KEYNAME_TYPE) )
+ {
+ typeInfo = TypeRegistry::Get().GetTypeInfo( *templateTypeName );
+ }
+ }
+ }
+ }
+ }
+
+ if(!typeInfo)
+ {
+ DALI_SCRIPT_WARNING("Cannot create Dali type from node '%s'\n", node.GetName());
+ }
+ else
+ {
+ baseHandle = typeInfo.CreateInstance();
+ Handle handle = Handle::DownCast(baseHandle);
+ Actor actor = Actor::DownCast(handle);
+
+ if(handle)
+ {
+
+ DALI_SCRIPT_VERBOSE("Create:%s\n", typeInfo.GetName().c_str());
+
+#if defined(DEBUG_ENABLED)
+ if(handle)
+ {
+ DALI_SCRIPT_VERBOSE(" Is Handle Object=%d\n", (long*)handle.GetObjectPtr());
+ DALI_SCRIPT_VERBOSE(" Is Handle Property Count=%d\n", handle.GetPropertyCount());
+ }
+
+ if(actor)
+ {
+ DALI_SCRIPT_VERBOSE(" Is Actor id=%d\n", actor.GetId());
+ }
+
+ Toolkit::Control control = Toolkit::Control::DownCast(handle);
+ if(control)
+ {
+ DALI_SCRIPT_VERBOSE(" Is Control id=%d\n", actor.GetId());