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>
29 #include <dali-toolkit/internal/builder/builder-get-is.inl.h>
30 #include <dali-toolkit/internal/builder/builder-filesystem.h>
31 #include <dali-toolkit/internal/builder/builder-declarations.h>
32 #include <dali-toolkit/internal/builder/replacement.h>
44 extern Animation CreateAnimation(const TreeNode& child, const Replacement& replacements, const Dali::Actor searchRoot );
45 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value );
46 extern bool SetPropertyFromNode( const TreeNode& node, Property::Value& value, const Replacement& replacements );
47 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value );
48 extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value, const Replacement& replacements );
49 extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
50 extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor);
51 extern Actor SetupActor( const TreeNode& node, Actor& actor );
52 extern Control SetupControl( const TreeNode& node, Control& actor );
54 #if defined(DEBUG_ENABLED)
55 Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_SCRIPT");
61 typedef std::vector<const TreeNode*> TreeNodeList;
64 std::string ToString(const T& value)
72 std::string ToString(const Rect<int>& value)
75 ss << value.x << "," << value.y << "," << value.width << "," << value.height;
80 std::string PropertyValueToString( const Property::Value& value )
84 switch( value.GetType() )
91 case Property::BOOLEAN:
93 ret = value.Get<bool>() ? "True" : "False";
99 ret = ToString( value.Get<float>() );
102 case Property::INTEGER:
104 ret = ToString( value.Get<int>() );
107 case Property::UNSIGNED_INTEGER:
109 ret = ToString( value.Get<unsigned int>() );
112 case Property::VECTOR2:
114 ret = ToString( value.Get<Vector2>() );
117 case Property::VECTOR3:
119 ret = ToString( value.Get<Vector3>() );
122 case Property::VECTOR4:
124 ret = ToString( value.Get<Vector4>() );
127 case Property::MATRIX3:
129 ret = ToString( value.Get<Matrix3>() );
132 case Property::MATRIX:
134 ret = ToString( value.Get<Matrix>() );
137 case Property::RECTANGLE:
139 ret = ToString( value.Get< Rect<int> >() );
142 case Property::ROTATION:
146 case Property::STRING:
148 ret = value.Get<std::string>();
151 case Property::ARRAY:
153 ret = std::string("Array Size=") + ToString( value.Get<Property::Array>().size() );
158 ret = std::string("Map Size=") + ToString( value.Get<Property::Map>().size() );
161 case Property::TYPE_COUNT:
172 * Sets the handle properties found in the tree node
174 void SetProperties( const TreeNode& node, Handle& handle, Builder& builder, const Replacement& constant )
178 for( TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter )
180 const TreeNode::KeyNodePair& keyChild = *iter;
182 std::string key( keyChild.first );
184 // ignore special fields; type,actors,signals
185 if(key == "type" || key == "actors" || key == "signals")
190 // special field 'image' usually contains an json object description
191 // although sometimes refers to a framebuffer
192 if( 0 == keyChild.second.Size() )
196 ImageActor imageActor = ImageActor::DownCast(handle);
199 if( OptionalString s = constant.IsString( keyChild.second ) )
201 FrameBufferImage fb = builder.GetFrameBufferImage(*s, constant);
204 imageActor.SetImage( fb );
211 // special field 'effect' references the shader effect instances
214 Actor actor = Actor::DownCast(handle);
215 OptionalString s = constant.IsString( keyChild.second );
218 ShaderEffect e = builder.GetShaderEffect(*s, constant);
219 actor.SetShaderEffect(e);
223 DALI_SCRIPT_WARNING("Could not find or set shader effect\n");
229 Property::Index index = handle.GetPropertyIndex(key);
231 if( Property::INVALID_INDEX != index )
233 Property::Type type = handle.GetPropertyType(index);
235 Property::Value value;
236 if( !SetPropertyFromNode( keyChild.second, type, value, constant ) )
238 // verbose as this might not be a problem
239 // eg parent-origin can be a string which is picked up later
240 DALI_SCRIPT_VERBOSE("Could not convert property:%s\n", key.c_str());
244 DALI_SCRIPT_VERBOSE("SetProperty '%s' Index=:%d Value Type=%d Value '%s'\n", key.c_str(), index, value.GetType(), PropertyValueToString(value).c_str() );
246 handle.SetProperty( index, value );
251 DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
254 } // for property nodes
258 DALI_SCRIPT_WARNING("Style applied to empty handle\n");
263 * Split a string by delimiter
265 std::vector<std::string> SplitString(const std::string &s, char delim, std::vector<std::string> &elems)
267 std::stringstream ss(s);
269 while(std::getline(ss, item, delim))
271 elems.push_back(item);
277 * Recursively collects all styles listed in a json node 'type' field. (Could be a comma separated list).
278 * It also returns the first found base typeInfo from the TypeRegistry. This is the concrete object to instance.
279 * i.e. the type field can name a json style section or a TypeRegistry base type.
281 void CollectAllStyles( const TreeNode& styles, const std::string& typeStyleString, TreeNodeList& additionalStyles, TypeInfo& typeInfo )
283 typedef std::vector<std::string> StyleNames;
284 StyleNames styleNames;
286 SplitString(typeStyleString, ',', styleNames);
288 for(StyleNames::iterator iter = styleNames.begin(); iter != styleNames.end(); ++iter)
290 const std::string typeName(*iter);
292 OptionalChild style = IsChild(styles, typeName);
295 additionalStyles.push_back(&(*style));
297 OptionalString styleType = IsString( IsChild(*style, "type") );
300 CollectAllStyles(styles, *styleType, additionalStyles, typeInfo);
306 // if its not a style then check for a type but only the first found
307 typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
313 DALI_ASSERT_DEBUG(!typeInfo);
314 typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
320 * Recursively collects all styles listed in a json node 'type' field. (Could be a comma separated list).
321 * Adds the given node to the end of the additional styles list.
322 * It also returns the first found base typeInfo from the TypeRegistry. This is the concrete object to instance.
323 * i.e. the type field can name a json style section or a TypeRegistry base type.
325 void CollectAllStyles( const OptionalChild& optionalStyles, const TreeNode& node, TreeNodeList& additionalStyles, TypeInfo& typeInfo )
327 OptionalString type = IsString( IsChild(node, "type") );
331 DALI_SCRIPT_WARNING("Cannot create style as type section is missing\n");
335 additionalStyles.push_back(&node);
339 CollectAllStyles( *optionalStyles, *type, additionalStyles, typeInfo );
343 typeInfo = TypeRegistry::Get().GetTypeInfo( *type );
352 * Create a dali type from a node.
353 * If parent given and an actor type was created then add it to the parent and
354 * recursively add nodes children.
356 BaseHandle Builder::Create( const OptionalChild& optionalStyles, const TreeNode& node, const TreeNode& root, Actor parent,
357 const Replacement& replacements )
359 BaseHandle baseHandle;
360 TreeNodeList allStyles;
363 CollectAllStyles( optionalStyles, node, allStyles, typeInfo );
367 DALI_SCRIPT_WARNING("Cannot create Dali type from node '%s'\n", node.GetName());
371 baseHandle = typeInfo.CreateInstance();
372 Handle handle = Handle::DownCast(baseHandle);
373 Actor actor = Actor::DownCast(handle);
374 Control control = Control::DownCast(handle);
379 DALI_SCRIPT_VERBOSE("Create:%s\n", typeInfo.GetName().c_str());
380 DALI_SCRIPT_VERBOSE(" %d style sections\n", allStyles.size());
382 #if defined(DEBUG_ENABLED)
385 DALI_SCRIPT_VERBOSE(" Is Handle Object=%d\n", (long*)handle.GetObjectPtr());
386 DALI_SCRIPT_VERBOSE(" Is Handle Property Count=%d\n", handle.GetPropertyCount());
391 DALI_SCRIPT_VERBOSE(" Is Actor id=%d\n", actor.GetId());
396 DALI_SCRIPT_VERBOSE(" Is Control id=%d\n", actor.GetId());
398 #endif // DEBUG_ENABLED
400 for(TreeNodeList::reverse_iterator iter = allStyles.rbegin(); iter != allStyles.rend(); ++iter)
402 if( (*iter)->GetType() == TreeNode::ARRAY )
404 // if its an array then its a list of styles to set to objects already in the hiearchy by name
407 const TreeNode& styleList = *(*iter);
408 for( TreeNode::ConstIterator iterSubStyle = styleList.CBegin(); iterSubStyle != styleList.CEnd(); ++iterSubStyle )
410 const TreeNode* nameNode = (*iterSubStyle).second.Find("name");
411 if( nameNode && nameNode->GetType() == TreeNode::STRING )
413 Dali::Actor found = actor.FindChildByName( nameNode->GetString() );
416 SetProperties( (*iterSubStyle).second, found, *this, replacements );
420 DALI_SCRIPT_VERBOSE("Cannot find object '%s' in tree to style\n", nameNode->GetString());
425 DALI_SCRIPT_VERBOSE("Style name is not a string '%s' '%d'\n",
426 nameNode->GetString(), (*iterSubStyle).second.GetType());
432 DALI_SCRIPT_VERBOSE("Cannot apply style list to non actor\n");
437 DALI_ASSERT_DEBUG( (*iter)->GetType() == TreeNode::OBJECT );
438 // else it should be a map of properties
439 SetProperties( *(*iter), handle, *this, replacements );
444 SetupActor( *(*iter), actor);
448 SetupControl( *(*iter), control);
451 // add children of all the styles
452 if( OptionalChild actors = IsChild( *(*iter), "actors" ) )
454 for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter )
456 Create( optionalStyles, (*iter).second, root, actor, replacements );
465 SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor );
467 SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor );
469 // then add to parent
479 DALI_SCRIPT_WARNING("Cannot create handle from type '%s'\n", typeInfo.GetName().c_str());
487 ActorContainer Builder::GetTopLevelActors() const
489 // deprecated function.
490 return ActorContainer();
493 Animation Builder::GetAnimation( const std::string &name ) const
499 void Builder::SetupTask( RenderTask& task, const TreeNode& node, const Replacement& constant )
501 const Stage& stage = Stage::GetCurrent();
502 Layer root = stage.GetRootLayer();
504 if( OptionalString s = constant.IsString( IsChild(node, "source-actor") ) )
506 Actor actor = root.FindChildByName(*s);
509 task.SetSourceActor( actor );
513 DALI_SCRIPT_WARNING("Cannot find source actor on stage for render task called '%s'\n", (*s).c_str() );
517 if( OptionalString s = constant.IsString( IsChild(node, "camera-actor") ) )
519 CameraActor actor = CameraActor::DownCast( root.FindChildByName(*s) );
522 task.SetCameraActor( actor );
526 DALI_SCRIPT_WARNING("Cannot find camera actor on stage for render task called '%s'\n", (*s).c_str() );
530 if( OptionalString s = constant.IsString( IsChild(node, "target-frame-buffer") ) )
532 FrameBufferImage fb = GetFrameBufferImage( *s, constant );
535 task.SetTargetFrameBuffer( fb );
539 DALI_SCRIPT_WARNING("Cannot find target frame buffer '%s'\n", (*s).c_str() );
543 if( OptionalString s = constant.IsString( IsChild(node, "screen-to-frame-buffer-function") ) )
545 if("DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION" == *s)
547 task.SetScreenToFrameBufferFunction( RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION );
549 else if("FULLSCREEN_FRAMEBUFFER_FUNCTION" == *s)
551 task.SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
555 DALI_SCRIPT_WARNING("todo");
559 // other setup is via the property system
560 SetProperties( node, task, *this, constant ); // @ todo, remove 'source-actor', 'camera-actor'?
564 void Builder::CreateRenderTask( const std::string &name )
566 Replacement constant(mReplacementMap);
568 const Stage& stage = Stage::GetCurrent();
570 OptionalChild tasks = IsChild(*mParser.GetRoot(), "render-tasks");
575 // Create the tasks from the current task as generally we want
576 // to setup task zero and onwards. Although this does overwrite
577 // the properties of the current task.
579 if( OptionalChild renderTask = IsChild(*tasks, name ) )
581 RenderTaskList list = stage.GetRenderTaskList();
582 unsigned int start = list.GetTaskCount();
587 // zero should have already been created by the stage so really
588 // this case should never happen
589 task = list.CreateTask();
593 TreeNode::ConstIterator iter = (*renderTask).CBegin();
594 task = list.GetTask( start - 1 );
596 SetupTask( task, (*iter).second, constant );
600 for(; iter != (*renderTask).CEnd(); ++iter )
602 task = list.CreateTask();
603 SetupTask( task, (*iter).second, constant );
609 ShaderEffect Builder::GetShaderEffect( const std::string &name)
611 Replacement constant;
612 return GetShaderEffect( name, constant );
615 ShaderEffect Builder::GetShaderEffect( const std::string &name, const Replacement& constant )
619 ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) );
620 if( iter != mShaderEffectLut.end() )
626 if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shader-effects") )
628 if( OptionalChild effect = IsChild( *effects, name ) )
630 Dali::Property::Value propertyMap(Property::MAP);
631 if( SetPropertyFromNode( *effect, Property::MAP, propertyMap, constant ) )
633 ret = Dali::Scripting::NewShaderEffect( propertyMap );
634 mShaderEffectLut[ name ] = ret;
643 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name )
645 Replacement constant;
646 return GetFrameBufferImage(name, constant);
649 FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Replacement& constant )
651 FrameBufferImage ret;
653 ImageLut::const_iterator iter( mFrameBufferImageLut.find( name ) );
654 if( iter != mFrameBufferImageLut.end() )
660 if( OptionalChild images = IsChild( *mParser.GetRoot(), "frame-buffer-images") )
662 if( OptionalChild image = IsChild( *images, name ) )
664 Dali::Property::Value propertyMap(Property::MAP);
665 if( SetPropertyFromNode( *image, Property::MAP, propertyMap, constant ) )
667 propertyMap.SetValue("type", Property::Value(std::string("FrameBufferImage")));
668 ret = Dali::Scripting::NewImage( propertyMap );
669 mFrameBufferImageLut[ name ] = ret;
678 Font Builder::GetFont( const std::string& name ) const
680 // deprecated function.
685 TextStyle Builder::GetTextStyle( const std::string& name ) const
691 Image Builder::GetImage( const std::string& name) const
693 // deprecated function.
697 Actor Builder::GetActor( const std::string &name ) const
699 // deprecated function.
703 void Builder::AddActors( Actor toActor )
705 // 'stage' is the default/by convention section to add from
706 AddActors( "stage", toActor );
709 void Builder::AddActors( const std::string §ionName, Actor toActor )
711 PropertyValueMap overrideMap;
712 Replacement replacements(overrideMap, mReplacementMap);
714 OptionalChild addToStage = IsChild(*mParser.GetRoot(), sectionName);
718 OptionalChild styles = IsChild(*mParser.GetRoot(), "styles");
720 for( TreeNode::ConstIterator iter = (*addToStage).CBegin(); iter != (*addToStage).CEnd(); ++iter )
722 // empty actor adds directly to the stage
723 BaseHandle baseHandle = Create( styles, (*iter).second, *mParser.GetRoot(), Actor(), replacements );
724 Actor actor = Actor::DownCast(baseHandle);
727 toActor.Add( actor );
731 // if were adding the 'stage' section then also check for a render task called stage
732 // to add automatically
733 if( "stage" == sectionName )
735 if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "render-tasks") )
737 if( OptionalChild tasks = IsChild(*renderTasks, "stage") )
739 CreateRenderTask( "stage" );
746 Animation Builder::CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor )
750 if( OptionalChild animations = IsChild(*mParser.GetRoot(), "animations") )
752 if( OptionalChild animation = IsChild(*animations, animationName) )
754 anim = Dali::Toolkit::Internal::CreateAnimation( *animation, replacement, sourceActor );
758 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed\n", animationName.c_str() );
763 DALI_SCRIPT_WARNING( "Request for Animation called '%s' failed (no animation section)\n", animationName.c_str() );
769 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor )
771 Replacement replacement(map, mReplacementMap);
772 return CreateAnimation( animationName, replacement, sourceActor);
775 Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map )
777 Replacement replacement(map, mReplacementMap);
778 return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() );
781 Animation Builder::CreateAnimation( const std::string& animationName, Dali::Actor sourceActor )
783 Replacement replacement( mReplacementMap );
785 return CreateAnimation( animationName, replacement, sourceActor );
788 Animation Builder::CreateAnimation( const std::string& animationName )
790 Replacement replacement( mReplacementMap );
792 return CreateAnimation( animationName, replacement, Dali::Stage::GetCurrent().GetRootLayer() );
795 void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format )
797 DALI_ASSERT_ALWAYS( format == Dali::Toolkit::Builder::JSON && "Currently only JSON is supported" );
799 if( !mParser.Parse(data) )
801 DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n",
802 mParser.GetErrorLineNumber(),
803 mParser.GetErrorColumn(),
804 mParser.GetErrorDescription().c_str() );
806 DALI_ASSERT_ALWAYS(!"Cannot parse JSON");
809 DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Cannot parse JSON");
811 // load constant map (allows the user to override the constants in the json after loading)
816 void Builder::AddConstants( const PropertyValueMap& map )
818 for(PropertyValueMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
820 mReplacementMap[ (*iter).first ] = (*iter).second;
824 void Builder::AddConstant( const std::string& key, const Property::Value& value )
826 mReplacementMap[key] = value;
829 const PropertyValueMap& Builder::GetConstants() const
831 return mReplacementMap;
834 const Property::Value& Builder::GetConstant( const std::string& key ) const
836 PropertyValueMap::const_iterator iter = mReplacementMap.find( key );
837 if( iter != mReplacementMap.end() )
839 return (*iter).second;
843 static Property::Value invalid;
848 void Builder::LoadConstants()
850 Replacement replacer(mReplacementMap);
852 if( OptionalChild constants = IsChild(*mParser.GetRoot(), "constants") )
854 for(TreeNode::ConstIterator iter = (*constants).CBegin();
855 iter != (*constants).CEnd(); ++iter)
857 Dali::Property::Value property;
858 if( (*iter).second.GetName() )
860 #if defined(DEBUG_ENABLED)
861 DALI_SCRIPT_VERBOSE("Constant set from json '%s'\n", (*iter).second.GetName());
863 if( SetPropertyFromNode( (*iter).second, property, replacer ) )
865 mReplacementMap[ (*iter).second.GetName() ] = property;
869 DALI_SCRIPT_WARNING("Cannot convert property for constant %s\n",
870 (*iter).second.GetName() == NULL ? "no name?" : (*iter).second.GetName());
876 #if defined(DEBUG_ENABLED)
877 PropertyValueMap::const_iterator iter = mReplacementMap.find( "CONFIG_SCRIPT_LOG_LEVEL" );
878 if( iter != mReplacementMap.end() && (*iter).second.GetType() == Property::STRING )
880 std::string logLevel( (*iter).second.Get< std::string >() );
881 if( logLevel == "NoLogging" )
883 gFilterScript->SetLogLevel( Integration::Log::NoLogging );
885 else if( logLevel == "Concise" )
887 gFilterScript->SetLogLevel( Integration::Log::Concise );
889 else if( logLevel == "General" )
891 gFilterScript->SetLogLevel( Integration::Log::General );
893 else if( logLevel == "Verbose" )
895 gFilterScript->SetLogLevel( Integration::Log::Verbose );
902 void Builder::ApplyStyle( const std::string& styleName, Handle& handle )
904 Replacement replacer;
905 ApplyStyle( styleName, handle, replacer );
908 void Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement )
910 OptionalChild styles = IsChild(*mParser.GetRoot(), "styles");
914 if( OptionalChild style = IsChild(*styles, styleName) )
916 TreeNodeList allStyles;
919 CollectAllStyles( styles, *style, allStyles, typeInfo );
921 for(TreeNodeList::reverse_iterator iter = allStyles.rbegin(); iter != allStyles.rend(); ++iter)
923 if( (*iter)->GetType() == TreeNode::ARRAY )
925 // if its an array then its a list of styles to set to objects already in the hiearchy by name
926 if( Dali::Actor actor = Dali::Actor::DownCast( handle ) )
928 const TreeNode& styleList = *(*iter);
929 for( TreeNode::ConstIterator iterSubStyle = styleList.CBegin(); iterSubStyle != styleList.CEnd(); ++iterSubStyle )
931 const TreeNode* nameNode = (*iterSubStyle).second.Find("name");
932 if( nameNode && nameNode->GetType() == TreeNode::STRING )
934 Dali::Actor found = actor.FindChildByName( nameNode->GetString() );
937 SetProperties( (*iterSubStyle).second, found, *this, replacement );
941 DALI_SCRIPT_VERBOSE("Cannot find object '%s' in tree to style\n", nameNode->GetString());
946 DALI_SCRIPT_VERBOSE("Style name is not a string '%s' '%d'\n",
947 nameNode->GetString(), (*iterSubStyle).second.GetType());
953 DALI_SCRIPT_VERBOSE("Cannot apply style list to non actor\n");
958 DALI_ASSERT_DEBUG( (*iter)->GetType() == TreeNode::OBJECT );
959 SetProperties( *style, handle, *this, replacement );
965 DALI_SCRIPT_WARNING("Could not find style:%s\n", styleName.c_str());
970 DALI_SCRIPT_WARNING("No style section available for style:%s\n", styleName.c_str());
974 BaseHandle Builder::CreateFromStyle( const std::string& styleName, const PropertyValueMap& map )
976 Replacement replacement( map, mReplacementMap );
977 return CreateFromStyle( styleName, replacement );
980 BaseHandle Builder::CreateFromStyle( const std::string& styleName, const Replacement& constant )
982 BaseHandle baseHandle;
984 OptionalChild styles = IsChild(*mParser.GetRoot(), "styles");
988 DALI_SCRIPT_WARNING("No style section found to CreateFromStyle\n");
992 OptionalChild style = IsChild(*styles, styleName);
995 DALI_SCRIPT_WARNING("Style '%s' does not exist in style section\n", styleName.c_str());
999 OptionalString type = constant.IsString( IsChild(*style, "type") );
1003 DALI_SCRIPT_WARNING("Cannot create style '%s' as style section is missing 'type'\n", styleName.c_str());
1007 baseHandle = Create( styles, *style, *mParser.GetRoot(), Actor(), constant );
1016 BaseHandle Builder::CreateFromStyle( const std::string& styleName )
1018 PropertyValueMap overrideMap;
1019 Replacement replacement( overrideMap, mReplacementMap );
1020 return CreateFromStyle( styleName, replacement );
1024 : mSlotDelegate( this )
1026 mParser = Dali::Toolkit::JsonParser::New();
1033 } // namespace Internal
1035 } // namespace Toolkit