X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fbuilder%2Fbuilder-impl.cpp;h=a7fabdfc20d74e870b2d563871fae380c8b14ae5;hb=e5dbcae1f8ee31b14d675793ab86161eeeefb029;hp=2cf23db21b4066078a97109f60929b54a47194c9;hpb=0695455c9e382f0b19d9e1062a384c32b91f0a38;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 index 2cf23db..a7fabdf 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +58,6 @@ class Replacement; 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); -extern Actor SetupActor( const TreeNode& node, Actor& actor, const Replacement& constant ); #if defined(DEBUG_ENABLED) Integration::Log::Filter* gFilterScript = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_SCRIPT"); @@ -79,6 +77,9 @@ 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; @@ -101,7 +102,7 @@ bool GetMappingKey( const std::string& str, std::string& key ) } /* - * Recursively collects all stylesin a node (An array of style names). + * 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 @@ -116,7 +117,7 @@ void CollectAllStyles( const TreeNode& stylesCollection, const TreeNode& style, { if( OptionalString styleName = IsString( (*iter).second ) ) { - if( OptionalChild node = IsChild( stylesCollection, *styleName) ) + if( OptionalChild node = IsChildIgnoreCase( stylesCollection, *styleName) ) { styleList.push_back( &(*node) ); @@ -153,68 +154,10 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace continue; } - // special field 'image' usually contains an json object description - // although sometimes refers to a framebuffer - if( key == "image" ) - { - if( 0 == keyChild.second.Size() ) - { - ImageActor imageActor = ImageActor::DownCast(handle); - if(imageActor) - { - if( OptionalString s = constant.IsString( keyChild.second ) ) - { - FrameBufferImage fb = GetFrameBufferImage(*s, constant); - if(fb) - { - imageActor.SetImage( fb ); - } - } - } - } - } - - // special field 'effect' references the shader effect instances - if( key == "effect" ) - { - ImageActor actor = ImageActor::DownCast(handle); - if( actor ) - { - OptionalString str = constant.IsString( keyChild.second ); - if( str ) - { - ShaderEffect effect = GetShaderEffect( *str, constant ); - actor.SetShaderEffect(effect); - } - } - else - { - DALI_SCRIPT_WARNING("Could not find or set shader effect\n"); - } - - continue; - } - Handle propertyObject( handle ); Dali::Property::Index index = propertyObject.GetPropertyIndex( key ); - if( Property::INVALID_INDEX == index ) - { - ImageActor actor = ImageActor::DownCast(handle); - if( actor ) - { - if( ShaderEffect effect = actor.GetShaderEffect() ) - { - index = effect.GetPropertyIndex( key ); - if(index != Property::INVALID_INDEX) - { - propertyObject = effect; - } - } - } - } - if( Property::INVALID_INDEX != index ) { Property::Type type = propertyObject.GetPropertyType(index); @@ -236,9 +179,9 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace mapped = DeterminePropertyFromNode( keyChild.second, type, value, constant ); if( ! mapped ) { - // verbose as this might not be a problem - // eg parentOrigin can be a string which is picked up later - DALI_SCRIPT_VERBOSE("Could not convert property:%s\n", key.c_str()); + // 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 ) @@ -250,9 +193,13 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace } else { - DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index); + DALI_LOG_ERROR("Key '%s' not found.\n", key.c_str()); } + // Add custom properties + SetCustomProperties(node, handle, constant, PROPERTIES, Property::READ_WRITE); + SetCustomProperties(node, handle, constant, ANIMATABLE_PROPERTIES, Property::ANIMATABLE); + } // for property nodes } else @@ -261,6 +208,27 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace } } +void Builder::SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant, + const std::string& childName, Property::AccessMode accessMode ) +{ + // Add custom properties + if( OptionalChild customPropertiesChild = IsChild(node, childName) ) + { + 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 ); + } + } +} + // Set properties from node on handle. void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node, Dali::Handle& handle, const Replacement& constant ) @@ -271,8 +239,6 @@ void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node, if( actor ) { - SetupActor( node, actor, constant ); - // add signals SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, this ); SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, this ); @@ -590,42 +556,6 @@ void Builder::CreateRenderTask( const std::string &name ) } } -ShaderEffect Builder::GetShaderEffect( const std::string &name) -{ - Replacement constant( mReplacementMap ); - return GetShaderEffect( name, constant ); -} - -ShaderEffect Builder::GetShaderEffect( const std::string &name, const Replacement& constant ) -{ - DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); - - ShaderEffect ret; - - ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) ); - if( iter != mShaderEffectLut.end() ) - { - ret = iter->second; - } - else - { - if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shaderEffects") ) - { - if( OptionalChild effect = IsChild( *effects, name ) ) - { - Dali::Property::Value propertyMap(Property::MAP); - if( DeterminePropertyFromNode( *effect, Property::MAP, propertyMap, constant ) ) - { - ret = Dali::Scripting::NewShaderEffect( propertyMap ); - mShaderEffectLut[ name ] = ret; - } - } - } - } - - return ret; -} - FrameBufferImage Builder::GetFrameBufferImage( const std::string &name ) { Replacement constant( mReplacementMap ); @@ -1084,10 +1014,13 @@ bool Builder::ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack case Property::MAP: { Property::Map* map = child.GetMap(); - for( Property::Map::SizeType i=0; i < map->Count(); ++i ) + if( map ) { - Property::Value& child = map->GetValue(i); - ConvertChildValue(mappingRoot, keyStack, child); + for( Property::Map::SizeType i=0; i < map->Count(); ++i ) + { + Property::Value& child = map->GetValue(i); + ConvertChildValue(mappingRoot, keyStack, child); + } } break; } @@ -1095,10 +1028,13 @@ bool Builder::ConvertChildValue( const TreeNode& mappingRoot, KeyStack& keyStack case Property::ARRAY: { Property::Array* array = child.GetArray(); - for( Property::Array::SizeType i=0; i < array->Count(); ++i ) + if( array ) { - Property::Value& child = array->GetElementAt(i); - ConvertChildValue(mappingRoot, keyStack, child); + for( Property::Array::SizeType i=0; i < array->Count(); ++i ) + { + Property::Value& child = array->GetElementAt(i); + ConvertChildValue(mappingRoot, keyStack, child); + } } break; } @@ -1295,7 +1231,9 @@ bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Re DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded"); OptionalChild styles = IsChild( *mParser.GetRoot(), KEYNAME_STYLES ); - OptionalChild style = IsChild( *styles, styleName ); + + std::string styleNameLower(styleName); + OptionalChild style = IsChildIgnoreCase( *styles, styleNameLower ); if( styles && style ) {