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>
24 #include <dali/dali.h>
25 #include <dali/integration-api/debug.h>
27 #include <dali-toolkit/public-api/controls/control.h>
28 #include <dali-toolkit/public-api/builder/json-parser.h>
30 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
31 #include <dali-toolkit/internal/builder/builder-filesystem.h>
32 #include <dali-toolkit/internal/builder/builder-declarations.h>
33 #include <dali-toolkit/internal/builder/replacement.h>
45 extern Animation CreateAnimation(const TreeNode& child, const Replacement& replacements, const Dali::Actor searchRoot );
46 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value );
47 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value, const Replacement& replacements );
48 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value );
49 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, const Replacement& replacements );
50 extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
51 extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
52 extern Actor SetupActor( const TreeNode& node, Actor& actor );
54 #if defined(DEBUG_ENABLED)
55 Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_SCRIPT");
61 const std::string KEYNAME_STYLES = "styles";
62 const std::string KEYNAME_TYPE = "type";
63 const std::string KEYNAME_ACTORS = "actors";
64 const std::string KEYNAME_SIGNALS = "signals";
65 const std::string KEYNAME_NAME = "name";
66 const std::string KEYNAME_TEMPLATES = "templates";
67 const std::string KEYNAME_INCLUDES = "includes";
69 typedef std::vector<const TreeNode*> TreeNodeList;
72 std::string ToString(const T& value)
80 std::string ToString(const Rect<int>& value)
83 ss << value.x << "," << value.y << "," << value.width << "," << value.height;
88 std::string PropertyValueToString( const Property::Value& value )
92 switch( value.GetType() )
99 case Property::BOOLEAN:
101 ret = value.Get<bool>() ? "True" : "False";
104 case Property::FLOAT:
107 ret = ToString( value.Get<float>() );
110 case Property::INTEGER:
112 ret = ToString( value.Get<int>() );
115 case Property::UNSIGNED_INTEGER:
117 ret = ToString( value.Get<unsigned int>() );
120 case Property::VECTOR2:
122 ret = ToString( value.Get<Vector2>() );
125 case Property::VECTOR3:
127 ret = ToString( value.Get<Vector3>() );
130 case Property::VECTOR4:
132 ret = ToString( value.Get<Vector4>() );
135 case Property::MATRIX3:
137 ret = ToString( value.Get<Matrix3>() );
140 case Property::MATRIX:
142 ret = ToString( value.Get<Matrix>() );
145 case Property::RECTANGLE:
147 ret = ToString( value.Get< Rect<int> >() );
150 case Property::ROTATION:
154 case Property::STRING:
156 ret = value.Get<std::string>();
159 case Property::ARRAY:
161 ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().size() );
166 ret = std::string("Map Size=") + ToString( value.Get<Property::Map>().size() );
169 case Property::TYPE_COUNT:
180 * Recursively collects all stylesin a node (An array of style names).
182 * stylesCollection The set of styles from the json file (a json object of named styles)
183 * style The style array to begin the collection from
184 * styleList The style list to add nodes to apply
186 void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, TreeNodeList& styleList )
188 // style is an array of style names
189 if( TreeNode::ARRAY == style.GetType() )
191 for(TreeNode::ConstIterator iter = style.CBegin(); iter != style.CEnd(); ++iter)
193 if( OptionalString styleName = IsString( (*iter).second ) )
195 if( OptionalChild node = IsChild( stylesCollection, *styleName) )
197 styleList.push_back( &(*node) );
199 if( OptionalChild subStyle = IsChild( *node, KEYNAME_STYLES ) )
201 CollectAllStyles( stylesCollection, *subStyle, styleList );
212 * Sets the handle properties found in the tree node
214 void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant )
218 for( TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter )
220 const TreeNode::KeyNodePair& keyChild = *iter;
222 std::string key( keyChild.first );
224 // ignore special fields; type,actors,signals
225 if(key == KEYNAME_TYPE || key == KEYNAME_ACTORS || key == KEYNAME_SIGNALS || key == KEYNAME_STYLES)
230 // special field 'image' usually contains an json object description
231 // although sometimes refers to a framebuffer
232 if( 0 == keyChild.second.Size() )
236 ImageActor imageActor = ImageActor::DownCast(handle);
239 if( OptionalString s = constant.IsString( keyChild.second ) )
241 FrameBufferImage fb = GetFrameBufferImage(*s, constant);
244 imageActor.SetImage( fb );
251 // special field 'effect' references the shader effect instances
254 Actor actor = Actor::DownCast(handle);
255 OptionalString s = constant.IsString( keyChild.second );
258 ShaderEffect e = GetShaderEffect(*s, constant);
259 actor.SetShaderEffect(e);
263 DALI_SCRIPT_WARNING("Could not find or set shader effect\n");
269 Handle propertyObject( handle );
271 Property::Index index = propertyObject.GetPropertyIndex( key );
273 if( Property::INVALID_INDEX == index )
275 Actor actor = Actor::DownCast(propertyObject);
278 if( ShaderEffect effect = actor.GetShaderEffect() )
280 index = effect.GetPropertyIndex( key );
281 if(index != Property::INVALID_INDEX)
283 propertyObject = effect;
289 if( Property::INVALID_INDEX != index )
291 Property::Type type = propertyObject.GetPropertyType(index);
293 Property::Value value;
294 if( !SetPropertyFromNode( keyChild.second, type, value, constant ) )
296 // verbose as this might not be a problem
297 // eg parent-origin can be a string which is picked up later
298 DALI_SCRIPT_VERBOSE("Could not convert property:%s\n", key.c_str());
302 DALI_SCRIPT_VERBOSE("SetProperty '%s' Index=:%d Value Type=%d Value '%s'\n", key.c_str(), index, value.GetType(), PropertyValueToString(value).c_str() );
304 propertyObject.SetProperty( index, value );
309 DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
312 } // for property nodes
316 DALI_SCRIPT_WARNING("Style applied to empty handle\n");
320 // Set properties from node on handle.
321 void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node,
322 Dali::Handle& handle, const Replacement& constant )
324 if( Actor actor = Actor::DownCast(handle) )
326 SetProperties( node, actor, constant );
330 SetupActor( node, actor );
333 SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor );
335 SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor );
340 SetProperties( node, handle, constant );
344 // Appling by style helper
345 // use FindChildByName() to apply properties referenced in KEYNAME_ACTORS in the node
346 void Builder::ApplyStylesByActor( const TreeNode& root, const TreeNode& node,
347 Dali::Handle& handle, const Replacement& constant )
349 if( Dali::Actor actor = Dali::Actor::DownCast( handle ) )
351 if( const TreeNode* actors = node.GetChild( KEYNAME_ACTORS ) )
353 // in a style the actor subtree properties referenced by actor name
354 for( TreeConstIter iter = actors->CBegin(); iter != actors->CEnd(); ++iter )
356 Dali::Actor foundActor;
360 foundActor = actor.FindChildByName( (*iter).first );
365 // debug log cannot find searched for actor
366 #if defined(DEBUG_ENABLED)
367 DALI_SCRIPT_VERBOSE("Cannot find actor in style application '%s'\n", (*iter).first);
372 #if defined(DEBUG_ENABLED)
373 DALI_SCRIPT_VERBOSE("Styles applied to actor '%s'\n", (*iter).first);
375 ApplyProperties( root, (*iter).second, foundActor, constant );
383 void Builder::ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node,
384 Dali::Handle& handle, const Replacement& constant )
386 OptionalChild styles = IsChild(root, KEYNAME_STYLES);
387 OptionalChild style = IsChild(node, KEYNAME_STYLES);
389 if( styles && style )
391 TreeNodeList additionalStyles;
393 CollectAllStyles( *styles, *style, additionalStyles );
395 #if defined(DEBUG_ENABLED)
396 for(TreeNode::ConstIterator iter = (*style).CBegin(); iter != (*style).CEnd(); ++iter)
398 if( OptionalString styleName = IsString( (*iter).second ) )
400 DALI_SCRIPT_VERBOSE("Style Applied '%s'\n", (*styleName).c_str());
405 // a style may have other styles, which has other styles etc so we apply in reverse by convention.
406 for(TreeNodeList::reverse_iterator iter = additionalStyles.rbegin(); iter != additionalStyles.rend(); ++iter)
408 ApplyProperties( root, *(*iter), handle, constant );
410 ApplyStylesByActor( root, *(*iter), handle, constant );
414 // applying given node last
415 ApplyProperties( root, node, handle, constant );
417 ApplyStylesByActor( root, node, handle, constant );
423 * Create a dali type from a node.
424 * If parent given and an actor type was created then add it to the parent and
425 * recursively add nodes children.
427 BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node,
428 Actor parent, const Replacement& replacements )
430 BaseHandle baseHandle;
432 const TreeNode* templateNode = NULL;
434 if( OptionalString typeName = IsString(node, KEYNAME_TYPE) )
436 typeInfo = TypeRegistry::Get().GetTypeInfo( *typeName );
440 // a template name is also allowed inplace of the type name
441 OptionalChild templates = IsChild( root, KEYNAME_TEMPLATES);
445 if( OptionalChild isTemplate = IsChild( *templates, *typeName ) )
447 templateNode = &(*isTemplate);
449 if( OptionalString templateTypeName = IsString(*templateNode, KEYNAME_TYPE) )
451 typeInfo = TypeRegistry::Get().GetTypeInfo( *templateTypeName );
460 DALI_SCRIPT_WARNING("Cannot create Dali type from node '%s'\n", node.GetName());
464 baseHandle = typeInfo.CreateInstance();
465 Handle handle = Handle::DownCast(baseHandle);
466 Actor actor = Actor::DownCast(handle);
471 DALI_SCRIPT_VERBOSE("Create:%s\n", typeInfo.GetName().c_str());
473 #if defined(DEBUG_ENABLED)
476 DALI_SCRIPT_VERBOSE(" Is Handle Object=%d\n", (long*)handle.GetObjectPtr());
477 DALI_SCRIPT_VERBOSE(" Is Handle Property Count=%d\n", handle.GetPropertyCount());
482 DALI_SCRIPT_VERBOSE(" Is Actor id=%d\n", actor.GetId());
485 Toolkit::Control control = Toolkit::Control::DownCast(handle);
488 DALI_SCRIPT_VERBOSE(" Is Control id=%d\n", actor.GetId());
490 #endif // DEBUG_ENABLED
494 ApplyProperties( root, *templateNode, handle, replacements );
496 if( OptionalChild actors = IsChild( *templateNode, KEYNAME_ACTORS ) )
498 for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter )
500 DoCreate( root, (*iter).second, actor, replacements );
505 ApplyProperties( root, node, handle, replacements );
509 // add children of all the styles
510 if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
512 for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter )
514 DoCreate( root, (*iter).second, actor, replacements );
518 // apply style on top as they need the children to exist
519 ApplyAllStyleProperties( root, node, actor, replacements );
521 // then add to parent
531 DALI_SCRIPT_WARNING("Cannot create handle from type '%s'\n", typeInfo.GetName().c_str());
539 ActorContainer Builder::GetTopLevelActors() const
541 // deprecated function.
542 return ActorContainer();
545 Animation Builder::GetAnimation( const std::string &name ) const
551 void Builder::SetupTask( RenderTask& task, const TreeNode& node, const Replacement& constant )
553 const Stage& stage = Stage::GetCurrent();
554 Layer root = stage.GetRootLayer();
556 if( OptionalString s = constant.IsString( IsChild(node, "source-actor") ) )
558 Actor actor = root.FindChildByName(*s);
561 task.SetSourceActor( actor );
565 DALI_SCRIPT_WARNING("Cannot find source actor on stage for render task called '%s'\n", (*s).c_str() );
569 if( OptionalString s = constant.IsString( IsChild(node, "camera-actor") ) )
571 CameraActor actor = CameraActor::DownCast( root.FindChildByName(*s) );
574 task.SetCameraActor( actor );
578 DALI_SCRIPT_WARNING("Cannot find camera actor on stage for render task called '%s'\n", (*s).c_str() );
582 if( OptionalString s = constant.IsString( IsChild(node, "target-frame-buffer") ) )
584 FrameBufferImage fb = GetFrameBufferImage( *s, constant );
587 task.SetTargetFrameBuffer( fb );
591 DALI_SCRIPT_WARNING("Cannot find target frame buffer '%s'\n", (*s).c_str() );
595 if( OptionalString s = constant.IsString( IsChild(node, "screen-to-frame-buffer-function") ) )
597 if("DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION" == *s)
599 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
601 else if("FULLSCREEN_FRAMEBUFFER_FUNCTION" == *s)
603 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
607 DALI_SCRIPT_WARNING("todo");
611 // other setup is via the property system
612 SetProperties( node, task, constant ); // @ todo, remove 'source-actor', 'camera-actor'?
616 void Builder::CreateRenderTask( const std::string &name )
618 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
620 Replacement constant(mReplacementMap);
622 const Stage& stage = Stage::GetCurrent();
624 OptionalChild tasks = IsChild(*mParser.GetRoot(), "render-tasks");
629 // Create the tasks from the current task as generally we want
630 // to setup task zero and onwards. Although this does overwrite
631 // the properties of the current task.
633 if( OptionalChild renderTask = IsChild(*tasks, name ) )
635 RenderTaskList list = stage.GetRenderTaskList();
636 unsigned int start = list.GetTaskCount();
641 // zero should have already been created by the stage so really
642 // this case should never happen
643 task = list.CreateTask();
647 TreeNode::ConstIterator iter = (*renderTask).CBegin();
648 task = list.GetTask( start - 1 );
650 SetupTask( task, (*iter).second, constant );
654 for(; iter != (*renderTask).CEnd(); ++iter )
656 task = list.CreateTask();
657 SetupTask( task, (*iter).second, constant );
663 ShaderEffect Builder::GetShaderEffect( const std::string &name)
665 Replacement constant( mReplacementMap );
666 return GetShaderEffect( name, constant );
669 ShaderEffect Builder::GetShaderEffect( const std::string &name, const Replacement& constant )
671 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
675 ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) );
676 if( iter != mShaderEffectLut.end() )
682 if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shader-effects") )
684 if( OptionalChild effect = IsChild( *effects, name ) )
686 Dali::Property::Value propertyMap(Property::MAP);
687 if( SetPropertyFromNode( *effect, Property::MAP, propertyMap, constant ) )
689 ret = Dali::Scripting::NewShaderEffect( propertyMap );
690 mShaderEffectLut[ name ] = ret;
699 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name )
701 Replacement constant( mReplacementMap );
702 return GetFrameBufferImage(name, constant);
705 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Replacement& constant )
707 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
709 FrameBufferImage ret;
711 ImageLut::const_iterator iter( mFrameBufferImageLut.find( name ) );
712 if( iter != mFrameBufferImageLut.end() )
718 if( OptionalChild images = IsChild( *mParser.GetRoot(), "frame-buffer-images") )
720 if( OptionalChild image = IsChild( *images, name ) )
722 Dali::Property::Value propertyMap(Property::MAP);
723 if( SetPropertyFromNode( *image, Property::MAP, propertyMap, constant ) )
725 propertyMap.SetValue(KEYNAME_TYPE, Property::Value(std::string("FrameBufferImage")));
726 ret = Dali::Scripting::NewImage( propertyMap );
727 mFrameBufferImageLut[ name ] = ret;
736 Font Builder::GetFont( const std::string& name ) const
738 // deprecated function.
743 TextStyle Builder::GetTextStyle( const std::string& name ) const
749 Image Builder::GetImage( const std::string& name) const
751 // deprecated function.
755 Actor Builder::GetActor( const std::string &name ) const
757 // deprecated function.
761 void Builder::AddActors( Actor toActor )
763 // 'stage' is the default/by convention section to add from
764 AddActors( "stage", toActor );
767 void Builder::AddActors( const std::string §ionName, Actor toActor )
769 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
771 PropertyValueMap overrideMap;
772 Replacement replacements(overrideMap, mReplacementMap);
774 OptionalChild add = IsChild(*mParser.GetRoot(), sectionName);
778 for( TreeNode::ConstIterator iter = (*add).CBegin(); iter != (*add).CEnd(); ++iter )
780 // empty actor adds directly to the stage
781 BaseHandle baseHandle = DoCreate( *mParser.GetRoot(), (*iter).second, Actor(), replacements );
782 Actor actor = Actor::DownCast(baseHandle);
785 toActor.Add( actor );
789 // if were adding the 'stage' section then also check for a render task called stage
790 // to add automatically
791 if( "stage" == sectionName )
793 if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "render-tasks") )
795 if( OptionalChild tasks = IsChild(*renderTasks, "stage") )
797 CreateRenderTask( "stage" );
804 Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor )
806 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
810 if( OptionalChild animations = IsChild(*mParser.GetRoot(), "animations") )
812 if( OptionalChild animation = IsChild(*animations, animationName) )
814 anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, sourceActor );
818 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed\n", animationName.c_str() );
823 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed (no animation section)\n", animationName.c_str() );
829 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor )
831 Replacement replacement(map, mReplacementMap);
832 return CreateAnimation( animationName, replacement, sourceActor);
835 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map )
837 Replacement replacement(map, mReplacementMap);
838 return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() );
841 Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor )
843 Replacement replacement( mReplacementMap );
845 return CreateAnimation( animationName, replacement, sourceActor );
848 Animation Builder::CreateAnimation( const std::string& animationName )
850 Replacement replacement( mReplacementMap );
852 return CreateAnimation( animationName, replacement, Dali::Stage::GetCurrent().GetRootLayer() );
855 void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
857 DALI_ASSERT_ALWAYS( format == Dali::Toolkit::Builder::JSON && "Currently only JSON is supported" );
859 // parser to get constants and includes only
860 Dali::Toolkit::JsonParser parser = Dali::Toolkit::JsonParser::New();
862 if( !parser.Parse( data ) )
864 DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
865 parser.GetErrorLineNumber(),
866 parser.GetErrorColumn(),
867 parser.GetErrorDescription().c_str() );
869 DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
874 // load constant map (allows the user to override the constants in the json after loading)
875 LoadConstants( *parser.GetRoot(), mReplacementMap );
878 if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) )
880 Replacement replacer( mReplacementMap );
882 for(TreeNode::ConstIterator iter = (*includes).CBegin(); iter != (*includes).CEnd(); ++iter)
884 OptionalString filename = replacer.IsString( (*iter).second );
888 #if defined(DEBUG_ENABLED)
889 DALI_SCRIPT_VERBOSE("Loading Include '%s'\n", (*filename).c_str());
891 LoadFromString( GetFileContents(*filename) );
896 if( !mParser.Parse( data ) )
898 DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
899 mParser.GetErrorLineNumber(),
900 mParser.GetErrorColumn(),
901 mParser.GetErrorDescription().c_str() );
903 DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
907 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON");
911 void Builder::AddConstants( const PropertyValueMap& map )
913 for(PropertyValueMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
915 mReplacementMap[ (*iter).first ] = (*iter).second;
919 void Builder::AddConstant( const std::string& key, const Property::Value& value )
921 mReplacementMap[key] = value;
924 const PropertyValueMap& Builder::GetConstants() const
926 return mReplacementMap;
929 const Property::Value& Builder::GetConstant( const std::string& key ) const
931 PropertyValueMap::const_iterator iter = mReplacementMap.find( key );
932 if( iter != mReplacementMap.end() )
934 return (*iter).second;
938 static Property::Value invalid;
943 void Builder::LoadConstants( const TreeNode& root, PropertyValueMap& intoMap )
945 Replacement replacer(intoMap);
947 if( OptionalChild constants = IsChild(root, "constants") )
949 for(TreeNode::ConstIterator iter = (*constants).CBegin();
950 iter != (*constants).CEnd(); ++iter)
952 Dali::Property::Value property;
953 if( (*iter).second.GetName() )
955 #if defined(DEBUG_ENABLED)
956 DALI_SCRIPT_VERBOSE("Constant set from json '%s'\n", (*iter).second.GetName());
958 if( SetPropertyFromNode( (*iter).second, property, replacer ) )
960 intoMap[ (*iter).second.GetName() ] = property;
964 DALI_SCRIPT_WARNING("Cannot convert property for constant %s\n",
965 (*iter).second.GetName() == NULL ? "no name?" : (*iter).second.GetName());
971 #if defined(DEBUG_ENABLED)
972 PropertyValueMap::const_iterator iter = intoMap.find( "CONFIG_SCRIPT_LOG_LEVEL" );
973 if( iter != intoMap.end() && (*iter).second.GetType() == Property::STRING )
975 std::string logLevel( (*iter).second.Get< std::string >() );
976 if( logLevel == "NoLogging" )
978 gFilterScript->SetLogLevel( Integration::Log::NoLogging );
980 else if( logLevel == "Concise" )
982 gFilterScript->SetLogLevel( Integration::Log::Concise );
984 else if( logLevel == "General" )
986 gFilterScript->SetLogLevel( Integration::Log::General );
988 else if( logLevel == "Verbose" )
990 gFilterScript->SetLogLevel( Integration::Log::Verbose );
997 bool Builder::ApplyStyle( const std::string& styleName, Handle& handle )
999 Replacement replacer( mReplacementMap );
1000 return ApplyStyle( styleName, handle, replacer );
1003 bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement )
1005 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
1007 OptionalChild styles = IsChild( *mParser.GetRoot(), KEYNAME_STYLES );
1008 OptionalChild style = IsChild( *styles, styleName );
1010 if( styles && style )
1012 ApplyAllStyleProperties( *mParser.GetRoot(), *style, handle, replacement );
1017 DALI_SCRIPT_WARNING("No styles section to create style '%s'\n", styleName.c_str());
1022 BaseHandle Builder::Create( const std::string& templateName, const PropertyValueMap& map )
1024 Replacement replacement( map, mReplacementMap );
1025 return Create( templateName, replacement );
1028 BaseHandle Builder::Create( const std::string& templateName, const Replacement& constant )
1030 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
1032 BaseHandle baseHandle;
1034 OptionalChild templates = IsChild(*mParser.GetRoot(), KEYNAME_TEMPLATES);
1038 DALI_SCRIPT_WARNING("No template section found to CreateFromTemplate\n");
1042 OptionalChild childTemplate = IsChild(*templates, templateName);
1045 DALI_SCRIPT_WARNING("Template '%s' does not exist in template section\n", templateName.c_str());
1049 OptionalString type = constant.IsString( IsChild(*childTemplate, KEYNAME_TYPE) );
1053 DALI_SCRIPT_WARNING("Cannot create template '%s' as template section is missing 'type'\n", templateName.c_str());
1057 baseHandle = DoCreate( *mParser.GetRoot(), *childTemplate, Actor(), constant );
1066 BaseHandle Builder::Create( const std::string& templateName )
1068 Replacement replacement( mReplacementMap );
1069 return Create( templateName, replacement );
1073 : mSlotDelegate( this )
1075 mParser = Dali::Toolkit::JsonParser::New();
1082 } // namespace Internal
1084 } // namespace Toolkit