X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.cpp;h=de3fbe14e119bea994dbe15c677d935bc5d8dcde;hb=refs%2Fchanges%2F71%2F84271%2F13;hp=83572ec83254fff7bf488624bcb6edb5d6fab45f;hpb=e2eda444afbe82e9591fe198eef339227f90a616;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp old mode 100755 new mode 100644 index 83572ec..de3fbe1 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -1,34 +1,49 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include // EXTERNAL INCLUDES #include - -// INTERNAL INCLUDES -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include +// INTERNAL INCLUDES #include +#include #include #include #include +#include +#include +#include + +#include namespace Dali { @@ -38,13 +53,11 @@ namespace Toolkit namespace Internal { +class Replacement; -extern Animation CreateAnimation(const TreeNode& child); -extern bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::Value& value ); -extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor); -extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor); -extern Actor SetupActor( const TreeNode& node, Actor& actor ); -extern Control SetupControl( const TreeNode& node, Control& actor ); +extern Animation CreateAnimation(const TreeNode& child, const Replacement& replacements, const Dali::Actor searchRoot, Builder* const builder ); +extern Actor SetupSignalAction(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder); +extern Actor SetupPropertyNotification(ConnectionTracker* tracker, const TreeNode &root, const TreeNode &child, Actor actor, Dali::Toolkit::Internal::Builder* const builder); #if defined(DEBUG_ENABLED) Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_SCRIPT"); @@ -53,84 +66,129 @@ Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug:: namespace { +#define TOKEN_STRING(x) #x + +const std::string KEYNAME_STYLES = "styles"; +const std::string KEYNAME_TYPE = "type"; +const std::string KEYNAME_ACTORS = "actors"; +const std::string KEYNAME_SIGNALS = "signals"; +const std::string KEYNAME_NAME = "name"; +const std::string KEYNAME_TEMPLATES = "templates"; +const std::string KEYNAME_INCLUDES = "includes"; +const std::string KEYNAME_MAPPINGS = "mappings"; + +const std::string PROPERTIES = "properties"; +const std::string ANIMATABLE_PROPERTIES = "animatableProperties"; + typedef std::vector TreeNodeList; -/* - * Sets the handle properties found in the tree node - */ -void SetProperties( const TreeNode& node, Handle& handle, Builder& builder ) + +bool GetMappingKey( const std::string& str, std::string& key ) { - if( handle ) + bool result = false; + std::string test( str ); + if( ! test.empty() ) { - for( TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter ) + if( test.at(0) == '<' ) { - const TreeNode::KeyNodePair& keyChild = *iter; - - std::string key( keyChild.first ); - - // ignore special fields; type,actors,signals - if(key == "type" || key == "actors" || key == "signals") + if( test.at(test.length()-1) == '>' ) { - continue; + key = test.substr( 1, test.length()-2 ); + result = true; } + } + } + return result; +} - // special field 'image' usually contains an json object description - // although sometimes refers to a framebuffer - if( 0 == keyChild.second.Size() ) +/* + * Recursively collects all styles in a node (An array of style names). + * + * stylesCollection The set of styles from the json file (a json object of named styles) + * style The style array to begin the collection from + * styleList The style list to add nodes to apply + */ +void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, TreeNodeList& styleList ) +{ + // style is an array of style names + if( TreeNode::ARRAY == style.GetType() ) + { + for(TreeNode::ConstIterator iter = style.CBegin(); iter != style.CEnd(); ++iter) + { + if( OptionalString styleName = IsString( (*iter).second ) ) { - if(key == "image") + if( OptionalChild node = IsChildIgnoreCase( stylesCollection, *styleName) ) { - ImageActor imageActor = ImageActor::DownCast(handle); - if(imageActor) + styleList.push_back( &(*node) ); + + if( OptionalChild subStyle = IsChild( *node, KEYNAME_STYLES ) ) { - if( OptionalString s = IsString( keyChild.second ) ) - { - FrameBufferImage fb = builder.GetFrameBufferImage(*s); - if(fb) - { - imageActor.SetImage( fb ); - } - } + CollectAllStyles( stylesCollection, *subStyle, styleList ); } } } + } + } +} - // special field 'effect' references the shader effect instances - if(key == "effect") - { - Actor actor = Actor::DownCast(handle); - OptionalString s = IsString( keyChild.second ); - if(actor && s) - { - ShaderEffect e = builder.GetShaderEffect(*s); - actor.SetShaderEffect(e); - } - else - { - DALI_SCRIPT_WARNING("Could not find or set shader effect\n"); - } +} // namespace anon + +/* + * Sets the handle properties found in the tree node + */ +void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replacement& constant ) +{ + if( handle ) + { + + for( TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter ) + { + const TreeNode::KeyNodePair& keyChild = *iter; + + std::string key( keyChild.first ); + + // ignore special fields; type,actors,signals,styles + if(key == KEYNAME_TYPE || key == KEYNAME_ACTORS || key == KEYNAME_SIGNALS || key == KEYNAME_STYLES || key == KEYNAME_MAPPINGS ) + { continue; } - Property::Index index = handle.GetPropertyIndex(key); + Handle propertyObject( handle ); + + Dali::Property::Index index = propertyObject.GetPropertyIndex( key ); if( Property::INVALID_INDEX != index ) { - Property::Type type = handle.GetPropertyType(index); - + Property::Type type = propertyObject.GetPropertyType(index); Property::Value value; - if( !SetPropertyFromNode( keyChild.second, type, value ) ) + bool mapped = false; + + // if node.value is a mapping, get the property value from the "mappings" table + if( keyChild.second.GetType() == TreeNode::STRING ) { - // verbose as this might not be a problem - // eg parent-origin can be a string which is picked up later - DALI_SCRIPT_VERBOSE("Could not convert property:%s\n", key.c_str()); + std::string mappingKey; + if( GetMappingKey(keyChild.second.GetString(), mappingKey) ) + { + OptionalChild mappingRoot = IsChild( mParser.GetRoot(), KEYNAME_MAPPINGS ); + mapped = GetPropertyMap( *mappingRoot, mappingKey.c_str(), type, value ); + } } - else + if( ! mapped ) { - DALI_SCRIPT_VERBOSE("SetProperty '%s' Index=:%d Value Type=%d\n", key.c_str(), index, value.GetType()); + mapped = DeterminePropertyFromNode( keyChild.second, type, value, constant ); + if( ! mapped ) + { + // Just determine the property from the node and if it's valid, let the property object handle it + DeterminePropertyFromNode( keyChild.second, value, constant ); + mapped = ( value.GetType() != Property::NONE ); + } + } + if( mapped ) + { + DALI_SCRIPT_VERBOSE("SetProperty '%s' Index=:%d Value Type=%d Value '%s'\n", key.c_str(), index, value.GetType(), PropertyValueToString(value).c_str() ); - handle.SetProperty( index, value ); + propertyObject.SetProperty( index, value ); } } else @@ -138,6 +196,10 @@ void SetProperties( const TreeNode& node, Handle& handle, Builder& builder ) DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index); } + // Add custom properties + SetCustomProperties(node, handle, constant, PROPERTIES, Property::READ_WRITE); + SetCustomProperties(node, handle, constant, ANIMATABLE_PROPERTIES, Property::ANIMATABLE); + } // for property nodes } else @@ -146,122 +208,176 @@ void SetProperties( const TreeNode& node, Handle& handle, Builder& builder ) } } -/* - * Split a string by delimiter - */ -std::vector SplitString(const std::string &s, char delim, std::vector &elems) +void Builder::SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant, + const std::string& childName, Property::AccessMode accessMode ) { - std::stringstream ss(s); - std::string item; - while(std::getline(ss, item, delim)) + // Add custom properties + if( OptionalChild customPropertiesChild = IsChild(node, childName) ) { - elems.push_back(item); + const TreeNode& customPropertiesNode = *customPropertiesChild; + const TreeConstIter endIter = customPropertiesNode.CEnd(); + for( TreeConstIter iter = customPropertiesNode.CBegin(); endIter != iter; ++iter ) + { + const TreeNode::KeyNodePair& keyChild = *iter; + std::string key( keyChild.first ); + + Property::Value value; + DeterminePropertyFromNode( keyChild.second, value, constant ); + // Register/Set property. + handle.RegisterProperty( key, value, accessMode ); + } } - return elems; } -/* - * Recursively collects all styles listed in a json node 'type' field. (Could be a comma separated list). - * It also returns the first found base typeInfo from the TypeRegistry. This is the concrete object to instance. - * i.e. the type field can name a json style section or a TypeRegistry base type. - */ -void CollectAllStyles( const TreeNode& styles, const std::string& typeStyleString, TreeNodeList& additionalStyles, TypeInfo& typeInfo ) +// Set properties from node on handle. +void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ) { - typedef std::vector StyleNames; - StyleNames styleNames; - - SplitString(typeStyleString, ',', styleNames); - - for(StyleNames::iterator iter = styleNames.begin(); iter != styleNames.end(); ++iter) + if( Actor actor = Actor::DownCast(handle) ) { - const std::string typeName(*iter); + SetProperties( node, actor, constant ); - OptionalChild style = IsChild(styles, typeName); - if(style) + if( actor ) { - additionalStyles.push_back(&(*style)); + // add signals + SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, this ); + SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, this ); + } + } + else + { + SetProperties( node, handle, constant ); + } +} - OptionalString styleType = IsString( IsChild(*style, "type") ); - if( styleType ) - { - CollectAllStyles(styles, *styleType, additionalStyles, typeInfo); - } - else +// Appling by style helper +// use FindChildByName() to apply properties referenced in KEYNAME_ACTORS in the node +void Builder::ApplyStylesByActor( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ) +{ + if( Dali::Actor actor = Dali::Actor::DownCast( handle ) ) + { + if( const TreeNode* actors = node.GetChild( KEYNAME_ACTORS ) ) + { + // in a style the actor subtree properties referenced by actor name + for( TreeConstIter iter = actors->CBegin(); iter != actors->CEnd(); ++iter ) { - if(!typeInfo) + Dali::Actor foundActor; + + if( (*iter).first ) + { + foundActor = actor.FindChildByName( (*iter).first ); + } + + if( !foundActor ) { - // if its not a style then check for a type but only the first found - typeInfo = TypeRegistry::Get().GetTypeInfo( typeName ); + // debug log cannot find searched for actor +#if defined(DEBUG_ENABLED) + DALI_SCRIPT_VERBOSE("Cannot find actor in style application '%s'\n", (*iter).first); +#endif + } + else + { +#if defined(DEBUG_ENABLED) + DALI_SCRIPT_VERBOSE("Styles applied to actor '%s'\n", (*iter).first); +#endif + ApplyProperties( root, (*iter).second, foundActor, constant ); } } } - else - { - DALI_ASSERT_DEBUG(!typeInfo); - typeInfo = TypeRegistry::Get().GetTypeInfo( typeName ); - } } } -/* - * Recursively collects all styles listed in a json node 'type' field. (Could be a comma separated list). - * Adds the given node to the end of the additional styles list. - * It also returns the first found base typeInfo from the TypeRegistry. This is the concrete object to instance. - * i.e. the type field can name a json style section or a TypeRegistry base type. - */ -void CollectAllStyles( const OptionalChild& optionalStyles, const TreeNode& node, TreeNodeList& additionalStyles, TypeInfo& typeInfo ) + +void Builder::ApplyAllStyleProperties( const TreeNode& root, const TreeNode& node, + Dali::Handle& handle, const Replacement& constant ) { - OptionalString type = IsString( IsChild(node, "type") ); + OptionalChild styles = IsChild(root, KEYNAME_STYLES); + OptionalChild style = IsChild(node, KEYNAME_STYLES); - if(!type) - { - DALI_SCRIPT_WARNING("Cannot create style as type section is missing\n"); - } - else + if( styles && style ) { - additionalStyles.push_back(&node); + TreeNodeList additionalStyles; - if( optionalStyles ) + CollectAllStyles( *styles, *style, additionalStyles ); + +#if defined(DEBUG_ENABLED) + for(TreeNode::ConstIterator iter = (*style).CBegin(); iter != (*style).CEnd(); ++iter) { - CollectAllStyles( *optionalStyles, *type, additionalStyles, typeInfo ); + if( OptionalString styleName = IsString( (*iter).second ) ) + { + DALI_SCRIPT_VERBOSE("Style Applied '%s'\n", (*styleName).c_str()); + } } - else +#endif + + // a style may have other styles, which has other styles etc so we apply in reverse by convention. + for(TreeNodeList::reverse_iterator iter = additionalStyles.rbegin(); iter != additionalStyles.rend(); ++iter) { - typeInfo = TypeRegistry::Get().GetTypeInfo( *type ); - } + ApplyProperties( root, *(*iter), handle, constant ); + ApplyStylesByActor( root, *(*iter), handle, constant ); + } } + + // applying given node last + ApplyProperties( root, node, handle, constant ); + + ApplyStylesByActor( root, node, handle, constant ); + } + /* * 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 Create( ConnectionTracker* tracker, const OptionalChild& optionalStyles, const TreeNode& node, const TreeNode& root, Actor parent, Builder& builder ) +BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node, + Actor parent, const Replacement& replacements ) { BaseHandle baseHandle; - TreeNodeList allStyles; TypeInfo typeInfo; + const TreeNode* templateNode = NULL; + + if( OptionalString typeName = IsString(node, KEYNAME_TYPE) ) + { + typeInfo = TypeRegistry::Get().GetTypeInfo( *typeName ); - CollectAllStyles( optionalStyles, node, allStyles, typeInfo ); + 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("Unable to create Dali type from node\n"); + 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); - Control control = Control::DownCast(handle); if(handle) { DALI_SCRIPT_VERBOSE("Create:%s\n", typeInfo.GetName().c_str()); - DALI_SCRIPT_VERBOSE(" %d style sections\n", allStyles.size()); #if defined(DEBUG_ENABLED) if(handle) @@ -275,48 +391,49 @@ BaseHandle Create( ConnectionTracker* tracker, const OptionalChild& optionalStyl 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()); } #endif // DEBUG_ENABLED - for(TreeNodeList::reverse_iterator iter = allStyles.rbegin(); iter != allStyles.rend(); ++iter) + if( templateNode ) { - SetProperties( *(*iter), handle, builder ); + ApplyProperties( root, *templateNode, handle, replacements ); - if( actor ) // if we created an actor + if( OptionalChild actors = IsChild( *templateNode, KEYNAME_ACTORS ) ) { - SetupActor( *(*iter), actor); - - if( control ) + for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter ) { - SetupControl( *(*iter), control); - } - - // add children of all the styles - if( OptionalChild actors = IsChild( *(*iter), "actors" ) ) - { - for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter ) - { - Create( tracker, optionalStyles, (*iter).second, root, actor, builder ); - } + DoCreate( root, (*iter).second, actor, replacements ); } } } if( actor ) { - // add signals first - SetupSignalAction( tracker, root, node, actor ); - SetupPropertyNotification( tracker, root, node, actor ); + // add children of all the styles + if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) ) + { + for( TreeConstIter iter = (*actors).CBegin(); iter != (*actors).CEnd(); ++iter ) + { + DoCreate( root, (*iter).second, actor, replacements ); + } + } + + // apply style on top as they need the children to exist + ApplyAllStyleProperties( root, node, actor, replacements ); // then add to parent if( parent ) { parent.Add( actor ); } - + } + else + { + ApplyProperties( root, node, handle, replacements ); } } else @@ -328,28 +445,12 @@ BaseHandle Create( ConnectionTracker* tracker, const OptionalChild& optionalStyl return baseHandle; } - -} // namespace anon - - -ActorContainer Builder::GetTopLevelActors() const -{ - // deprecated function. - return ActorContainer(); -} - -Animation Builder::GetAnimation( const std::string &name ) const -{ - // deprecated - return Animation(); -} - -void Builder::SetupTask( RenderTask& task, const TreeNode& node ) +void Builder::SetupTask( RenderTask& task, const TreeNode& node, const Replacement& constant ) { const Stage& stage = Stage::GetCurrent(); Layer root = stage.GetRootLayer(); - if( OptionalString s = IsString( IsChild(node, "source-actor") ) ) + if( OptionalString s = constant.IsString( IsChild(node, "sourceActor") ) ) { Actor actor = root.FindChildByName(*s); if(actor) @@ -362,7 +463,7 @@ void Builder::SetupTask( RenderTask& task, const TreeNode& node ) } } - if( OptionalString s = IsString( IsChild(node, "camera-actor") ) ) + if( OptionalString s = constant.IsString( IsChild(node, "cameraActor") ) ) { CameraActor actor = CameraActor::DownCast( root.FindChildByName(*s) ); if(actor) @@ -375,9 +476,9 @@ void Builder::SetupTask( RenderTask& task, const TreeNode& node ) } } - if( OptionalString s = IsString( IsChild(node, "target-frame-buffer") ) ) + if( OptionalString s = constant.IsString( IsChild(node, "targetFrameBuffer") ) ) { - FrameBufferImage fb = GetFrameBufferImage( *s ); + FrameBufferImage fb = GetFrameBufferImage( *s, constant ); if(fb) { task.SetTargetFrameBuffer( fb ); @@ -388,7 +489,7 @@ void Builder::SetupTask( RenderTask& task, const TreeNode& node ) } } - if( OptionalString s = IsString( IsChild(node, "screen-to-frame-buffer-function") ) ) + if( OptionalString s = constant.IsString( IsChild(node, "screenToFrameBufferFunction") ) ) { if("DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION" == *s) { @@ -405,15 +506,18 @@ void Builder::SetupTask( RenderTask& task, const TreeNode& node ) } // other setup is via the property system - SetProperties( node, task, *this ); // @ todo, remove 'source-actor', 'camera-actor'? - + SetProperties( node, task, constant ); } void Builder::CreateRenderTask( const std::string &name ) { + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + + Replacement constant(mReplacementMap); + const Stage& stage = Stage::GetCurrent(); - OptionalChild tasks = IsChild(*mParser.GetRoot(), "render-tasks"); + OptionalChild tasks = IsChild(*mParser.GetRoot(), "renderTasks"); if(tasks) { @@ -439,39 +543,53 @@ void Builder::CreateRenderTask( const std::string &name ) TreeNode::ConstIterator iter = (*renderTask).CBegin(); task = list.GetTask( start - 1 ); - SetupTask( task, (*iter).second ); + SetupTask( task, (*iter).second, constant ); ++iter; for(; iter != (*renderTask).CEnd(); ++iter ) { task = list.CreateTask(); - SetupTask( task, (*iter).second ); + SetupTask( task, (*iter).second, constant ); } } } } -ShaderEffect Builder::GetShaderEffect( const std::string &name ) +FrameBufferImage Builder::GetFrameBufferImage( const std::string &name ) { - ShaderEffect ret; + Replacement constant( mReplacementMap ); + return GetFrameBufferImage(name, constant); +} + +FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Replacement& constant ) +{ + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + + FrameBufferImage ret; - ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) ); - if( iter != mShaderEffectLut.end() ) + ImageLut::const_iterator iter( mFrameBufferImageLut.find( name ) ); + if( iter != mFrameBufferImageLut.end() ) { ret = iter->second; } else { - if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shader-effects") ) + if( OptionalChild images = IsChild( *mParser.GetRoot(), "frameBufferImages") ) { - if( OptionalChild effect = IsChild( *effects, name ) ) + if( OptionalChild image = IsChild( *images, name ) ) { - Dali::Property::Value propertyMap(Property::MAP); - if( SetPropertyFromNode( *effect, Property::MAP, propertyMap ) ) + Dali::Property::Value property(Property::MAP); + if( DeterminePropertyFromNode( *image, Property::MAP, property, constant ) ) { - ret = Dali::Scripting::NewShaderEffect( propertyMap ); - mShaderEffectLut[ name ] = ret; + Property::Map* map = property.GetMap(); + + if( map ) + { + (*map)[ KEYNAME_TYPE ] = Property::Value(std::string("FrameBufferImage") ); + ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( property ) ); + mFrameBufferImageLut[ name ] = ret; + } } } } @@ -480,58 +598,283 @@ ShaderEffect Builder::GetShaderEffect( const std::string &name ) return ret; } -FrameBufferImage Builder::GetFrameBufferImage( const std::string &name ) +Path Builder::GetPath( const std::string& name ) { - FrameBufferImage ret; + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); - ImageLut::const_iterator iter( mFrameBufferImageLut.find( name ) ); - if( iter != mFrameBufferImageLut.end() ) + Path ret; + + PathLut::const_iterator iter( mPathLut.find( name ) ); + if( iter != mPathLut.end() ) { ret = iter->second; } else { - if( OptionalChild images = IsChild( *mParser.GetRoot(), "frame-buffer-images") ) + if( OptionalChild paths = IsChild( *mParser.GetRoot(), "paths") ) { - if( OptionalChild image = IsChild( *images, name ) ) + if( OptionalChild path = IsChild( *paths, name ) ) { - Dali::Property::Value propertyMap(Property::MAP); - if( SetPropertyFromNode( *image, Property::MAP, propertyMap ) ) + //points property + if( OptionalChild pointsProperty = IsChild( *path, "points") ) + { + Dali::Property::Value points(Property::ARRAY); + if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) ) + { + ret = Path::New(); + ret.SetProperty( Path::Property::POINTS, points); + + //controlPoints property + if( OptionalChild pointsProperty = IsChild( *path, "controlPoints") ) + { + Dali::Property::Value points(Property::ARRAY); + if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) ) + { + ret.SetProperty( Path::Property::CONTROL_POINTS, points); + } + } + else + { + //Curvature + float curvature(0.25f); + if( OptionalFloat pointsProperty = IsFloat( *path, "curvature") ) + { + curvature = *pointsProperty; + } + ret.GenerateControlPoints(curvature); + } + + //Add the new path to the hash table for paths + mPathLut[ name ] = ret; + } + } + else + { + //Interpolation points not specified + DALI_SCRIPT_WARNING("Interpolation points not specified for path '%s'\n", name.c_str() ); + } + } + + } + } + + return ret; +} + +PathConstrainer Builder::GetPathConstrainer( const std::string& name ) +{ + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + + //Search the pathConstrainer in the LUT + size_t count( mPathConstrainerLut.size() ); + for( size_t i(0); i!=count; ++i ) + { + if( mPathConstrainerLut[i].name == name ) + { + //PathConstrainer has already been created + return mPathConstrainerLut[i].pathConstrainer; + } + } + + //Create a new PathConstrainer + PathConstrainer ret; + if( OptionalChild constrainers = IsChild( *mParser.GetRoot(), "constrainers") ) + { + if( OptionalChild pathConstrainer = IsChild( *constrainers, name ) ) + { + OptionalString constrainerType(IsString(IsChild(*pathConstrainer, "type"))); + if(!constrainerType) + { + DALI_SCRIPT_WARNING("Constrainer type not specified for constrainer '%s'\n", name.c_str() ); + } + else if( *constrainerType == "PathConstrainer") + { + //points property + if( OptionalChild pointsProperty = IsChild( *pathConstrainer, "points") ) + { + Dali::Property::Value points(Property::ARRAY); + if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) ) + { + ret = PathConstrainer::New(); + ret.SetProperty( PathConstrainer::Property::POINTS, points); + + //controlPoints property + if( OptionalChild pointsProperty = IsChild( *pathConstrainer, "controlPoints") ) + { + Dali::Property::Value points(Property::ARRAY); + if( DeterminePropertyFromNode( *pointsProperty, Property::ARRAY, points ) ) + { + ret.SetProperty( PathConstrainer::Property::CONTROL_POINTS, points); + } + + //Forward vector + OptionalVector3 forward( IsVector3( IsChild(*pathConstrainer, "forward" ) ) ); + if( forward ) + { + ret.SetProperty( PathConstrainer::Property::FORWARD, *forward); + } + + //Add the new constrainer to the vector of PathConstrainer + PathConstrainerEntry entry = {name,ret}; + mPathConstrainerLut.push_back( entry ); + } + else + { + //Control points not specified + DALI_SCRIPT_WARNING("Control points not specified for pathConstrainer '%s'\n", name.c_str() ); + } + } + } + else { - propertyMap.SetValue("type", Property::Value(std::string("FrameBufferImage"))); - ret = Dali::Scripting::NewImage( propertyMap ); - mFrameBufferImageLut[ name ] = ret; + //Interpolation points not specified + DALI_SCRIPT_WARNING("Interpolation points not specified for pathConstrainer '%s'\n", name.c_str() ); } } + else + { + DALI_SCRIPT_WARNING("Constrainer '%s' is not a PathConstrainer\n", name.c_str() ); + } } } return ret; } -Font Builder::GetFont( const std::string& name ) const +bool Builder::IsPathConstrainer( const std::string& name ) { - // deprecated function. - Font font; - return font; + size_t count( mPathConstrainerLut.size() ); + for( size_t i(0); i!=count; ++i ) + { + if( mPathConstrainerLut[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 == "PathConstrainer"; + } + } + } + return false; } -TextStyle Builder::GetTextStyle( const std::string& name ) const +Dali::LinearConstrainer Builder::GetLinearConstrainer( const std::string& name ) { - // deprecated - return TextStyle(); + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + + //Search the LinearConstrainer in the LUT + size_t count( mLinearConstrainerLut.size() ); + for( size_t i(0); i!=count; ++i ) + { + if( mLinearConstrainerLut[i].name == name ) + { + //LinearConstrainer has already been created + return mLinearConstrainerLut[i].linearConstrainer; + } + } + + //Create a new LinearConstrainer + LinearConstrainer ret; + if( OptionalChild constrainers = IsChild( *mParser.GetRoot(), "constrainers") ) + { + if( OptionalChild linearConstrainer = IsChild( *constrainers, name ) ) + { + OptionalString constrainerType(IsString(IsChild(*linearConstrainer, "type"))); + if(!constrainerType) + { + 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; } -Image Builder::GetImage( const std::string& name) const +Toolkit::Builder::BuilderSignalType& Builder::QuitSignal() { - // deprecated function. - return Image(); + return mQuitSignal; } -Actor Builder::GetActor( const std::string &name ) const +void Builder::EmitQuitSignal() { - // deprecated function. - return Actor(); + mQuitSignal.Emit(); } void Builder::AddActors( Actor toActor ) @@ -542,16 +885,19 @@ void Builder::AddActors( Actor toActor ) void Builder::AddActors( const std::string §ionName, Actor toActor ) { - OptionalChild addToStage = IsChild(*mParser.GetRoot(), sectionName); + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); - if( addToStage ) - { - OptionalChild styles = IsChild(*mParser.GetRoot(), "styles"); + Property::Map overrideMap; + Replacement replacements(overrideMap, mReplacementMap); + + OptionalChild add = IsChild(*mParser.GetRoot(), sectionName); - for( TreeNode::ConstIterator iter = (*addToStage).CBegin(); iter != (*addToStage).CEnd(); ++iter ) + if( add ) + { + for( TreeNode::ConstIterator iter = (*add).CBegin(); iter != (*add).CEnd(); ++iter ) { // empty actor adds directly to the stage - BaseHandle baseHandle = Create( mSlotDelegate.GetConnectionTracker(), styles, (*iter).second, *mParser.GetRoot(), Actor(), *this); + BaseHandle baseHandle = DoCreate( *mParser.GetRoot(), (*iter).second, Actor(), replacements ); Actor actor = Actor::DownCast(baseHandle); if(actor) { @@ -563,7 +909,7 @@ void Builder::AddActors( const std::string §ionName, Actor toActor ) // to add automatically if( "stage" == sectionName ) { - if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "render-tasks") ) + if( OptionalChild renderTasks = IsChild(*mParser.GetRoot(), "renderTasks") ) { if( OptionalChild tasks = IsChild(*renderTasks, "stage") ) { @@ -571,104 +917,371 @@ void Builder::AddActors( const std::string §ionName, Actor toActor ) } } } - } } -Animation Builder::CreateAnimation( const std::string& animationName ) +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 ); + 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\n", animationName.c_str() ); + 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() ); +} + +bool Builder::ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack, Property::Value& child ) +{ + bool result = false; + + switch( child.GetType() ) + { + case Property::STRING: + { + std::string value; + if( child.Get( value ) ) + { + std::string key; + if( GetMappingKey( value, key ) ) + { + // Check key for cycles: + result=true; + for( KeyStack::iterator iter = keyStack.begin() ; iter != keyStack.end(); ++iter ) + { + if( key.compare(*iter) == 0 ) + { + // key is already in stack; stop. + DALI_LOG_WARNING("Detected cycle in stylesheet mapping table:%s\n", key.c_str()); + child = Property::Value(""); + result=false; + break; + } + } + + if( result ) + { + // The following call will overwrite the child with the value + // from the mapping. + RecursePropertyMap( mappingRoot, keyStack, key.c_str(), Property::NONE, child ); + result = true; + } + } + } + break; + } + + case Property::MAP: + { + Property::Map* map = child.GetMap(); + if( map ) + { + for( Property::Map::SizeType i=0; i < map->Count(); ++i ) + { + Property::Value& child = map->GetValue(i); + ConvertChildValue(mappingRoot, keyStack, child); + } + } + break; + } + + case Property::ARRAY: + { + Property::Array* array = child.GetArray(); + if( array ) + { + for( Property::Array::SizeType i=0; i < array->Count(); ++i ) + { + Property::Value& child = array->GetElementAt(i); + ConvertChildValue(mappingRoot, keyStack, child); + } + } + break; + } + + default: + // Ignore other types. + break; + } + + return result; +} + +bool Builder::RecursePropertyMap( const TreeNode& mappingRoot, KeyStack& keyStack, const char* theKey, Property::Type propertyType, Property::Value& value ) +{ + Replacement replacer( mReplacementMap ); + bool result = false; + + keyStack.push_back( theKey ); + + for( TreeNode::ConstIterator iter = mappingRoot.CBegin(); iter != mappingRoot.CEnd(); ++iter ) + { + std::string aKey( (*iter).first ); + if( aKey.compare( theKey ) == 0 ) + { + if( propertyType == Property::NONE ) + { + DeterminePropertyFromNode( (*iter).second, value, replacer ); + result = true; + } + else + { + result = DeterminePropertyFromNode( (*iter).second, propertyType, value, replacer ); + } + + if( result ) + { + ConvertChildValue(mappingRoot, keyStack, value); + } + break; + } + } + keyStack.pop_back(); + + return result; +} + + +bool Builder::GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value ) +{ + KeyStack keyStack; + return RecursePropertyMap( mappingRoot, keyStack, theKey, propertyType, value ); +} + + void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::UIFormat format ) { - DALI_ASSERT_ALWAYS( format == Dali::Toolkit::Builder::JSON && "Currently only JSON is supported" ); + // parser to get constants and includes only + Dali::Toolkit::JsonParser parser = Dali::Toolkit::JsonParser::New(); - if( !mParser.Parse(data) ) + if( !parser.Parse( data ) ) { DALI_LOG_WARNING( "JSON Parse Error:%d:%d:'%s'\n", - mParser.GetErrorLineNumber(), - mParser.GetErrorColumn(), - mParser.GetErrorDescription().c_str() ); + 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"); + } + } + + DUMP_PARSE_TREE(parser); // This macro only writes out if DEBUG is enabled and the "DUMP_TREE" constant is defined in the stylesheet. + DUMP_TEST_MAPPINGS(parser); 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; } -void Builder::ApplyStyle( const std::string& styleName, Handle& handle ) +const Property::Map& Builder::GetConstants() const { - OptionalChild styles = IsChild(*mParser.GetRoot(), "styles"); + return mReplacementMap; +} - if( styles ) +const Property::Value& Builder::GetConstant( const std::string& key ) const +{ + Property::Value* match = mReplacementMap.Find( key ); + if( match ) { - if( OptionalChild style = IsChild(*styles, styleName) ) - { - TreeNodeList allStyles; - TypeInfo typeInfo; + return (*match); + } + else + { + static Property::Value invalid; + return invalid; + } +} - CollectAllStyles( styles, *style, allStyles, typeInfo ); +void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap ) +{ + Replacement replacer(intoMap); - for(TreeNodeList::reverse_iterator iter = allStyles.rbegin(); iter != allStyles.rend(); ++iter) + if( OptionalChild constants = IsChild(root, "constants") ) + { + for(TreeNode::ConstIterator iter = (*constants).CBegin(); + iter != (*constants).CEnd(); ++iter) + { + Dali::Property::Value property; + if( (*iter).second.GetName() ) { - SetProperties( *style, handle, *this ); +#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; } } - else + } + +#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" ) { - DALI_SCRIPT_WARNING("Could not find style:%s\n", styleName.c_str()); + gFilterScript->SetLogLevel( Integration::Log::Verbose ); } } +#endif + +} + +bool Builder::ApplyStyle( const std::string& styleName, Handle& handle ) +{ + Replacement replacer( mReplacementMap ); + return ApplyStyle( styleName, handle, replacer ); +} + +bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement ) +{ + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + + OptionalChild styles = IsChild( *mParser.GetRoot(), KEYNAME_STYLES ); + + std::string styleNameLower(styleName); + OptionalChild style = IsChildIgnoreCase( *styles, styleNameLower ); + + if( styles && style ) + { + ApplyAllStyleProperties( *mParser.GetRoot(), *style, handle, replacement ); + return true; + } else { - DALI_SCRIPT_WARNING("No style section available for style:%s\n", styleName.c_str()); + return false; } } -BaseHandle Builder::CreateFromStyle( const std::string& styleName ) +BaseHandle Builder::Create( const std::string& templateName, const Property::Map& map ) +{ + Replacement replacement( map, mReplacementMap ); + return Create( templateName, replacement ); +} + +BaseHandle Builder::Create( const std::string& templateName, const Replacement& constant ) { + DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); + BaseHandle baseHandle; - OptionalChild styles = IsChild(*mParser.GetRoot(), "styles"); + OptionalChild templates = IsChild(*mParser.GetRoot(), KEYNAME_TEMPLATES); - if( !styles ) + if( !templates ) { - DALI_SCRIPT_WARNING("No style section found to CreateFromStyle\n"); + DALI_SCRIPT_WARNING("No template section found to CreateFromTemplate\n"); } else { - OptionalChild style = IsChild(*styles, styleName); - if(!style) + OptionalChild childTemplate = IsChild(*templates, templateName); + if(!childTemplate) { - DALI_SCRIPT_WARNING("Style '%s' does not exist in style section\n", styleName.c_str()); + DALI_SCRIPT_WARNING("Template '%s' does not exist in template section\n", templateName.c_str()); } else { - OptionalString type = IsString( IsChild(*style, "type") ); + OptionalString type = constant.IsString( IsChild(*childTemplate, KEYNAME_TYPE) ); if(!type) { - DALI_SCRIPT_WARNING("Cannot create style '%s' as style section is missing 'type'\n", styleName.c_str()); + DALI_SCRIPT_WARNING("Cannot create template '%s' as template section is missing 'type'\n", templateName.c_str()); } else { - baseHandle = Create( mSlotDelegate.GetConnectionTracker(), styles, *style, *mParser.GetRoot(), Actor(), *this ); + baseHandle = DoCreate( *mParser.GetRoot(), *childTemplate, Actor(), constant ); } } } @@ -676,10 +1289,63 @@ BaseHandle Builder::CreateFromStyle( const std::string& styleName ) return baseHandle; } +BaseHandle Builder::CreateFromJson( const std::string& json ) +{ + BaseHandle ret; + + // merge in new template, hoping no one else has one named '@temp@' + std::string newTemplate = + std::string("{\"templates\":{\"@temp@\":") + \ + json + \ + std::string("}}"); + + if( mParser.Parse(newTemplate) ) + { + Replacement replacement( mReplacementMap ); + ret = Create( "@temp@", replacement ); + } + + return ret; +} + +bool Builder::ApplyFromJson( Handle& handle, const std::string& json ) +{ + bool ret = false; + + // merge new style, hoping no one else has one named '@temp@' + std::string newStyle = + std::string("{\"styles\":{\"@temp@\":") + \ + json + \ + std::string("}}"); + + if( mParser.Parse(newStyle) ) + { + Replacement replacement( mReplacementMap ); + ret = ApplyStyle( "@temp@", handle, replacement ); + } + + return ret; +} + + +BaseHandle Builder::Create( const std::string& templateName ) +{ + Replacement replacement( mReplacementMap ); + return Create( templateName, replacement ); +} + Builder::Builder() : mSlotDelegate( this ) { mParser = Dali::Toolkit::JsonParser::New(); + + Property::Map defaultDirs; + defaultDirs[ TOKEN_STRING(DALI_IMAGE_DIR) ] = DALI_IMAGE_DIR; + defaultDirs[ TOKEN_STRING(DALI_SOUND_DIR) ] = DALI_SOUND_DIR; + defaultDirs[ TOKEN_STRING(DALI_STYLE_DIR) ] = DALI_STYLE_DIR; + defaultDirs[ TOKEN_STRING(DALI_STYLE_IMAGE_DIR) ] = DALI_STYLE_IMAGE_DIR; + + AddConstants( defaultDirs ); } Builder::~Builder()