2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali-toolkit/internal/builder/builder-impl.h>
25 #include <dali/dali.h>
26 #include <dali/integration-api/debug.h>
28 #include <dali-toolkit/public-api/controls/control.h>
29 #include <dali-toolkit/public-api/builder/json-parser.h>
31 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
32 #include <dali-toolkit/internal/builder/builder-filesystem.h>
33 #include <dali-toolkit/internal/builder/builder-declarations.h>
34 #include <dali-toolkit/internal/builder/replacement.h>
46 extern Animation CreateAnimation(const TreeNode& child, const Replacement& replacements, const Dali::Actor searchRoot );
47 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value );
48 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value, const Replacement& replacements );
49 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value );
50 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, const Replacement& replacements );
51 extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
52 extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
53 extern Actor SetupActor( const TreeNode& node, Actor& actor );
55 #if defined(DEBUG_ENABLED)
56 Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_SCRIPT");
62 const std::string KEYNAME_STYLES = "styles";
63 const std::string KEYNAME_TYPE = "type";
64 const std::string KEYNAME_ACTORS = "actors";
65 const std::string KEYNAME_SIGNALS = "signals";
66 const std::string KEYNAME_NAME = "name";
67 const std::string KEYNAME_TEMPLATES = "templates";
68 const std::string KEYNAME_INCLUDES = "includes";
70 typedef std::vector<const TreeNode*> TreeNodeList;
73 std::string ToString(const T& value)
81 std::string ToString(const Rect<int>& value)
84 ss << value.x << "," << value.y << "," << value.width << "," << value.height;
89 std::string PropertyValueToString( const Property::Value& value )
93 switch( value.GetType() )
100 case Property::BOOLEAN:
102 ret = value.Get<bool>() ? "True" : "False";
105 case Property::FLOAT:
108 ret = ToString( value.Get<float>() );
111 case Property::INTEGER:
113 ret = ToString( value.Get<int>() );
116 case Property::UNSIGNED_INTEGER:
118 ret = ToString( value.Get<unsigned int>() );
121 case Property::VECTOR2:
123 ret = ToString( value.Get<Vector2>() );
126 case Property::VECTOR3:
128 ret = ToString( value.Get<Vector3>() );
131 case Property::VECTOR4:
133 ret = ToString( value.Get<Vector4>() );
136 case Property::MATRIX3:
138 ret = ToString( value.Get<Matrix3>() );
141 case Property::MATRIX:
143 ret = ToString( value.Get<Matrix>() );
146 case Property::RECTANGLE:
148 ret = ToString( value.Get< Rect<int> >() );
151 case Property::ROTATION:
155 case Property::STRING:
157 ret = value.Get<std::string>();
160 case Property::ARRAY:
162 ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().size() );
167 ret = std::string("Map Size=") + ToString( value.Get<Property::Map>().size() );
170 case Property::TYPE_COUNT:
181 * Recursively collects all stylesin a node (An array of style names).
183 * stylesCollection The set of styles from the json file (a json object of named styles)
184 * style The style array to begin the collection from
185 * styleList The style list to add nodes to apply
187 void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, TreeNodeList& styleList )
189 // style is an array of style names
190 if( TreeNode::ARRAY == style.GetType() )
192 for(TreeNode::ConstIterator iter = style.CBegin(); iter != style.CEnd(); ++iter)
194 if( OptionalString styleName = IsString( (*iter).second ) )
196 if( OptionalChild node = IsChild( stylesCollection, *styleName) )
198 styleList.push_back( &(*node) );
200 if( OptionalChild subStyle = IsChild( *node, KEYNAME_STYLES ) )
202 CollectAllStyles( stylesCollection, *subStyle, styleList );
213 * Sets the handle properties found in the tree node
215 void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant )
219 for( TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter )
221 const TreeNode::KeyNodePair& keyChild = *iter;
223 std::string key( keyChild.first );
225 // ignore special fields; type,actors,signals
226 if(key == KEYNAME_TYPE || key == KEYNAME_ACTORS || key == KEYNAME_SIGNALS || key == KEYNAME_STYLES)
231 // special field 'image' usually contains an json object description
232 // although sometimes refers to a framebuffer
233 if( 0 == keyChild.second.Size() )
237 ImageActor imageActor = ImageActor::DownCast(handle);
240 if( OptionalString s = constant.IsString( keyChild.second ) )
242 FrameBufferImage fb = GetFrameBufferImage(*s, constant);
245 imageActor.SetImage( fb );
252 // special field 'effect' references the shader effect instances
255 Actor actor = Actor::DownCast(handle);
256 OptionalString s = constant.IsString( keyChild.second );
259 ShaderEffect e = GetShaderEffect(*s, constant);
260 actor.SetShaderEffect(e);
264 DALI_SCRIPT_WARNING("Could not find or set shader effect\n");
270 Handle propertyObject( handle );
272 Property::Index index = propertyObject.GetPropertyIndex( key );
274 if( Property::INVALID_INDEX == index )
276 Actor actor = Actor::DownCast(propertyObject);
279 if( ShaderEffect effect = actor.GetShaderEffect() )
281 index = effect.GetPropertyIndex( key );
282 if(index != Property::INVALID_INDEX)
284 propertyObject = effect;
290 if( Property::INVALID_INDEX != index )
292 Property::Type type = propertyObject.GetPropertyType(index);
294 Property::Value value;
295 if( !SetPropertyFromNode( keyChild.second, type, value, constant ) )
297 // verbose as this might not be a problem
298 // eg parent-origin can be a string which is picked up later
299 DALI_SCRIPT_VERBOSE("Could not convert property:%s\n", key.c_str());
303 DALI_SCRIPT_VERBOSE("SetProperty '%s' Index=:%d Value Type=%d Value '%s'\n", key.c_str(), index, value.GetType(), PropertyValueToString(value).c_str() );
305 propertyObject.SetProperty( index, value );
310 DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
313 } // for property nodes
317 DALI_SCRIPT_WARNING("Style applied to empty handle\n");
321 // Set properties from node on handle.
322 void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node,
323 Dali::Handle& handle, const Replacement& constant )
325 if( Actor actor = Actor::DownCast(handle) )
327 SetProperties( node, actor, constant );
331 SetupActor( node, actor );
334 SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor );
336 SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor );
341 SetProperties( node, handle, constant );
345 // Appling by style helper
346 // use FindChildByName() to apply properties referenced in KEYNAME_ACTORS in the node
347 void Builder::ApplyStylesByActor( const TreeNode& root, const TreeNode& node,
348 Dali::Handle& handle, const Replacement& constant )
350 if( Dali::Actor actor = Dali::Actor::DownCast( handle ) )
352 if( const TreeNode* actors = node.GetChild( KEYNAME_ACTORS ) )
354 // in a style the actor subtree properties referenced by actor name
355 for( TreeConstIter iter = actors->CBegin(); iter != actors->CEnd(); ++iter )
357 Dali::Actor foundActor;
361 foundActor = actor.FindChildByName( (*iter).first );
366 // debug log cannot find searched for actor
367 #if defined(DEBUG_ENABLED)
368 DALI_SCRIPT_VERBOSE("Cannot find actor in style application '%s'\n", (*iter).first);
373 #if defined(DEBUG_ENABLED)
374 DALI_SCRIPT_VERBOSE("Styles applied to actor '%s'\n", (*iter).first);
376 ApplyProperties( root, (*iter).second, foundActor, constant );
384 void Builder::ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node,
385 Dali::Handle& handle, const Replacement& constant )
387 OptionalChild styles = IsChild(root, KEYNAME_STYLES);
388 OptionalChild style = IsChild(node, KEYNAME_STYLES);
390 if( styles && style )
392 TreeNodeList additionalStyles;
394 CollectAllStyles( *styles, *style, additionalStyles );
396 #if defined(DEBUG_ENABLED)
397 for(TreeNode::ConstIterator iter = (*style).CBegin(); iter != (*style).CEnd(); ++iter)
399 if( OptionalString styleName = IsString( (*iter).second ) )
401 DALI_SCRIPT_VERBOSE("Style Applied '%s'\n", (*styleName).c_str());
406 // a style may have other styles, which has other styles etc so we apply in reverse by convention.
407 for(TreeNodeList::reverse_iterator iter = additionalStyles.rbegin(); iter != additionalStyles.rend(); ++iter)
409 ApplyProperties( root, *(*iter), handle, constant );
411 ApplyStylesByActor( root, *(*iter), handle, constant );
415 // applying given node last
416 ApplyProperties( root, node, handle, constant );
418 ApplyStylesByActor( root, node, handle, constant );
424 * Create a dali type from a node.
425 * If parent given and an actor type was created then add it to the parent and
426 * recursively add nodes children.
428 BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node,
429 Actor parent, const Replacement& replacements )
431 BaseHandle baseHandle;
433 const TreeNode* templateNode = NULL;
435 if( OptionalString typeName = IsString(node, KEYNAME_TYPE) )
437 typeInfo = TypeRegistry::Get().GetTypeInfo( *typeName );
441 // a template name is also allowed inplace of the type name
442 OptionalChild templates = IsChild( root, KEYNAME_TEMPLATES);
446 if( OptionalChild isTemplate = IsChild( *templates, *typeName ) )
448 templateNode = &(*isTemplate);
450 if( OptionalString templateTypeName = IsString(*templateNode, KEYNAME_TYPE) )
452 typeInfo = TypeRegistry::Get().GetTypeInfo( *templateTypeName );
461 DALI_SCRIPT_WARNING("Cannot create Dali type from node '%s'\n", node.GetName());
465 baseHandle = typeInfo.CreateInstance();
466 Handle handle = Handle::DownCast(baseHandle);
467 Actor actor = Actor::DownCast(handle);
472 DALI_SCRIPT_VERBOSE("Create:%s\n", typeInfo.GetName().c_str());
474 #if defined(DEBUG_ENABLED)
477 DALI_SCRIPT_VERBOSE(" Is Handle Object=%d\n", (long*)handle.GetObjectPtr());
478 DALI_SCRIPT_VERBOSE(" Is Handle Property Count=%d\n", handle.GetPropertyCount());
483 DALI_SCRIPT_VERBOSE(" Is Actor id=%d\n", actor.GetId());
486 Toolkit::Control control = Toolkit::Control::DownCast(handle);
489 DALI_SCRIPT_VERBOSE(" Is Control id=%d\n", actor.GetId());
491 #endif // DEBUG_ENABLED
495 ApplyProperties( root, *templateNode, handle, replacements );
497 if( OptionalChild actors = IsChild( *templateNode, KEYNAME_ACTORS ) )
499 for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter )
501 DoCreate( root, (*iter).second, actor, replacements );
506 ApplyProperties( root, node, handle, replacements );
510 // add children of all the styles
511 if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
513 for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter )
515 DoCreate( root, (*iter).second, actor, replacements );
519 // apply style on top as they need the children to exist
520 ApplyAllStyleProperties( root, node, actor, replacements );
522 // then add to parent
532 DALI_SCRIPT_WARNING("Cannot create handle from type '%s'\n", typeInfo.GetName().c_str());
540 ActorContainer Builder::GetTopLevelActors() const
542 // deprecated function.
543 return ActorContainer();
546 Animation Builder::GetAnimation( const std::string &name ) const
552 void Builder::SetupTask( RenderTask& task, const TreeNode& node, const Replacement& constant )
554 const Stage& stage = Stage::GetCurrent();
555 Layer root = stage.GetRootLayer();
557 if( OptionalString s = constant.IsString( IsChild(node, "source-actor") ) )
559 Actor actor = root.FindChildByName(*s);
562 task.SetSourceActor( actor );
566 DALI_SCRIPT_WARNING("Cannot find source actor on stage for render task called '%s'\n", (*s).c_str() );
570 if( OptionalString s = constant.IsString( IsChild(node, "camera-actor") ) )
572 CameraActor actor = CameraActor::DownCast( root.FindChildByName(*s) );
575 task.SetCameraActor( actor );
579 DALI_SCRIPT_WARNING("Cannot find camera actor on stage for render task called '%s'\n", (*s).c_str() );
583 if( OptionalString s = constant.IsString( IsChild(node, "target-frame-buffer") ) )
585 FrameBufferImage fb = GetFrameBufferImage( *s, constant );
588 task.SetTargetFrameBuffer( fb );
592 DALI_SCRIPT_WARNING("Cannot find target frame buffer '%s'\n", (*s).c_str() );
596 if( OptionalString s = constant.IsString( IsChild(node, "screen-to-frame-buffer-function") ) )
598 if("DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION" == *s)
600 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
602 else if("FULLSCREEN_FRAMEBUFFER_FUNCTION" == *s)
604 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
608 DALI_SCRIPT_WARNING("todo");
612 // other setup is via the property system
613 SetProperties( node, task, constant ); // @ todo, remove 'source-actor', 'camera-actor'?
617 void Builder::CreateRenderTask( const std::string &name )
619 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
621 Replacement constant(mReplacementMap);
623 const Stage& stage = Stage::GetCurrent();
625 OptionalChild tasks = IsChild(*mParser.GetRoot(), "render-tasks");
630 // Create the tasks from the current task as generally we want
631 // to setup task zero and onwards. Although this does overwrite
632 // the properties of the current task.
634 if( OptionalChild renderTask = IsChild(*tasks, name ) )
636 RenderTaskList list = stage.GetRenderTaskList();
637 unsigned int start = list.GetTaskCount();
642 // zero should have already been created by the stage so really
643 // this case should never happen
644 task = list.CreateTask();
648 TreeNode::ConstIterator iter = (*renderTask).CBegin();
649 task = list.GetTask( start - 1 );
651 SetupTask( task, (*iter).second, constant );
655 for(; iter != (*renderTask).CEnd(); ++iter )
657 task = list.CreateTask();
658 SetupTask( task, (*iter).second, constant );
664 ShaderEffect Builder::GetShaderEffect( const std::string &name)
666 Replacement constant( mReplacementMap );
667 return GetShaderEffect( name, constant );
670 ShaderEffect Builder::GetShaderEffect( const std::string &name, const Replacement& constant )
672 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
676 ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) );
677 if( iter != mShaderEffectLut.end() )
683 if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shader-effects") )
685 if( OptionalChild effect = IsChild( *effects, name ) )
687 Dali::Property::Value propertyMap(Property::MAP);
688 if( SetPropertyFromNode( *effect, Property::MAP, propertyMap, constant ) )
690 ret = Dali::Scripting::NewShaderEffect( propertyMap );
691 mShaderEffectLut[ name ] = ret;
700 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name )
702 Replacement constant( mReplacementMap );
703 return GetFrameBufferImage(name, constant);
706 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Replacement& constant )
708 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
710 FrameBufferImage ret;
712 ImageLut::const_iterator iter( mFrameBufferImageLut.find( name ) );
713 if( iter != mFrameBufferImageLut.end() )
719 if( OptionalChild images = IsChild( *mParser.GetRoot(), "frame-buffer-images") )
721 if( OptionalChild image = IsChild( *images, name ) )
723 Dali::Property::Value propertyMap(Property::MAP);
724 if( SetPropertyFromNode( *image, Property::MAP, propertyMap, constant ) )
726 propertyMap.SetValue(KEYNAME_TYPE, Property::Value(std::string("FrameBufferImage")));
727 ret = Dali::Scripting::NewImage( propertyMap );
728 mFrameBufferImageLut[ name ] = ret;
737 Font Builder::GetFont( const std::string& name ) const
739 // deprecated function.
744 TextStyle Builder::GetTextStyle( const std::string& name ) const
750 Image Builder::GetImage( const std::string& name) const
752 // deprecated function.
756 Actor Builder::GetActor( const std::string &name ) const
758 // deprecated function.
762 void Builder::AddActors( Actor toActor )
764 // 'stage' is the default/by convention section to add from
765 AddActors( "stage", toActor );
768 void Builder::AddActors( const std::string §ionName, Actor toActor )
770 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
772 PropertyValueMap overrideMap;
773 Replacement replacements(overrideMap, mReplacementMap);
775 OptionalChild add = IsChild(*mParser.GetRoot(), sectionName);
779 for( TreeNode::ConstIterator iter = (*add).CBegin(); iter != (*add).CEnd(); ++iter )
781 // empty actor adds directly to the stage
782 BaseHandle baseHandle = DoCreate( *mParser.GetRoot(), (*iter).second, Actor(), replacements );
783 Actor actor = Actor::DownCast(baseHandle);
786 toActor.Add( actor );
790 // if were adding the 'stage' section then also check for a render task called stage
791 // to add automatically
792 if( "stage" == sectionName )
794 if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "render-tasks") )
796 if( OptionalChild tasks = IsChild(*renderTasks, "stage") )
798 CreateRenderTask( "stage" );
805 Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor )
807 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
811 if( OptionalChild animations = IsChild(*mParser.GetRoot(), "animations") )
813 if( OptionalChild animation = IsChild(*animations, animationName) )
815 anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, sourceActor );
819 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed\n", animationName.c_str() );
824 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed (no animation section)\n", animationName.c_str() );
830 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor )
832 Replacement replacement(map, mReplacementMap);
833 return CreateAnimation( animationName, replacement, sourceActor);
836 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map )
838 Replacement replacement(map, mReplacementMap);
839 return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() );
842 Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor )
844 Replacement replacement( mReplacementMap );
846 return CreateAnimation( animationName, replacement, sourceActor );
849 Animation Builder::CreateAnimation( const std::string& animationName )
851 Replacement replacement( mReplacementMap );
853 return CreateAnimation( animationName, replacement, Dali::Stage::GetCurrent().GetRootLayer() );
856 void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
858 DALI_ASSERT_ALWAYS( format == Dali::Toolkit::Builder::JSON && "Currently only JSON is supported" );
860 // parser to get constants and includes only
861 Dali::Toolkit::JsonParser parser = Dali::Toolkit::JsonParser::New();
863 if( !parser.Parse( data ) )
865 DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
866 parser.GetErrorLineNumber(),
867 parser.GetErrorColumn(),
868 parser.GetErrorDescription().c_str() );
870 DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
875 // load constant map (allows the user to override the constants in the json after loading)
876 LoadConstants( *parser.GetRoot(), mReplacementMap );
879 if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) )
881 Replacement replacer( mReplacementMap );
883 for(TreeNode::ConstIterator iter = (*includes).CBegin(); iter != (*includes).CEnd(); ++iter)
885 OptionalString filename = replacer.IsString( (*iter).second );
889 #if defined(DEBUG_ENABLED)
890 DALI_SCRIPT_VERBOSE("Loading Include '%s'\n", (*filename).c_str());
892 LoadFromString( GetFileContents(*filename) );
897 if( !mParser.Parse( data ) )
899 DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
900 mParser.GetErrorLineNumber(),
901 mParser.GetErrorColumn(),
902 mParser.GetErrorDescription().c_str() );
904 DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
908 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON");
912 void Builder::AddConstants( const PropertyValueMap& map )
914 for(PropertyValueMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
916 mReplacementMap[ (*iter).first ] = (*iter).second;
920 void Builder::AddConstant( const std::string& key, const Property::Value& value )
922 mReplacementMap[key] = value;
925 const PropertyValueMap& Builder::GetConstants() const
927 return mReplacementMap;
930 const Property::Value& Builder::GetConstant( const std::string& key ) const
932 PropertyValueMap::const_iterator iter = mReplacementMap.find( key );
933 if( iter != mReplacementMap.end() )
935 return (*iter).second;
939 static Property::Value invalid;
944 void Builder::LoadConstants( const TreeNode& root, PropertyValueMap& intoMap )
946 Replacement replacer(intoMap);
948 if( OptionalChild constants = IsChild(root, "constants") )
950 for(TreeNode::ConstIterator iter = (*constants).CBegin();
951 iter != (*constants).CEnd(); ++iter)
953 Dali::Property::Value property;
954 if( (*iter).second.GetName() )
956 #if defined(DEBUG_ENABLED)
957 DALI_SCRIPT_VERBOSE("Constant set from json '%s'\n", (*iter).second.GetName());
959 if( SetPropertyFromNode( (*iter).second, property, replacer ) )
961 intoMap[ (*iter).second.GetName() ] = property;
965 DALI_SCRIPT_WARNING("Cannot convert property for constant %s\n",
966 (*iter).second.GetName() == NULL ? "no name?" : (*iter).second.GetName());
972 #if defined(DEBUG_ENABLED)
973 PropertyValueMap::const_iterator iter = intoMap.find( "CONFIG_SCRIPT_LOG_LEVEL" );
974 if( iter != intoMap.end() && (*iter).second.GetType() == Property::STRING )
976 std::string logLevel( (*iter).second.Get< std::string >() );
977 if( logLevel == "NoLogging" )
979 gFilterScript->SetLogLevel( Integration::Log::NoLogging );
981 else if( logLevel == "Concise" )
983 gFilterScript->SetLogLevel( Integration::Log::Concise );
985 else if( logLevel == "General" )
987 gFilterScript->SetLogLevel( Integration::Log::General );
989 else if( logLevel == "Verbose" )
991 gFilterScript->SetLogLevel( Integration::Log::Verbose );
998 bool Builder::ApplyStyle( const std::string& styleName, Handle& handle )
1000 Replacement replacer( mReplacementMap );
1001 return ApplyStyle( styleName, handle, replacer );
1004 bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement )
1006 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
1008 OptionalChild styles = IsChild( *mParser.GetRoot(), KEYNAME_STYLES );
1009 OptionalChild style = IsChild( *styles, styleName );
1011 if( styles && style )
1013 ApplyAllStyleProperties( *mParser.GetRoot(), *style, handle, replacement );
1018 DALI_SCRIPT_WARNING("No styles section to create style '%s'\n", styleName.c_str());
1023 BaseHandle Builder::Create( const std::string& templateName, const PropertyValueMap& map )
1025 Replacement replacement( map, mReplacementMap );
1026 return Create( templateName, replacement );
1029 BaseHandle Builder::Create( const std::string& templateName, const Replacement& constant )
1031 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
1033 BaseHandle baseHandle;
1035 OptionalChild templates = IsChild(*mParser.GetRoot(), KEYNAME_TEMPLATES);
1039 DALI_SCRIPT_WARNING("No template section found to CreateFromTemplate\n");
1043 OptionalChild childTemplate = IsChild(*templates, templateName);
1046 DALI_SCRIPT_WARNING("Template '%s' does not exist in template section\n", templateName.c_str());
1050 OptionalString type = constant.IsString( IsChild(*childTemplate, KEYNAME_TYPE) );
1054 DALI_SCRIPT_WARNING("Cannot create template '%s' as template section is missing 'type'\n", templateName.c_str());
1058 baseHandle = DoCreate( *mParser.GetRoot(), *childTemplate, Actor(), constant );
1067 BaseHandle Builder::Create( const std::string& templateName )
1069 Replacement replacement( mReplacementMap );
1070 return Create( templateName, replacement );
1074 : mSlotDelegate( this )
1076 mParser = Dali::Toolkit::JsonParser::New();
1083 } // namespace Internal
1085 } // namespace Toolkit