+ 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;
+ if( key == KEYNAME_TYPE ||
+ key == KEYNAME_ACTORS ||
+ key == KEYNAME_SIGNALS ||
+ key == KEYNAME_STYLES ||
+ key == KEYNAME_MAPPINGS ||
+ key == KEYNAME_INHERIT ||
+ key == KEYNAME_STATES ||
+ key == KEYNAME_VISUALS ||
+ key == KEYNAME_ENTRY_TRANSITION ||
+ key == KEYNAME_EXIT_TRANSITION ||
+ key == KEYNAME_TRANSITIONS )
+ {
+ continue;
+ }
+
+ Property::Index index;
+ Property::Value value;
+
+ bool mapped = MapToTargetProperty( handle, key, keyChild.second, constant, index, value );
+ 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 );
+ }
+
+ // Add custom properties
+ SetCustomProperties(node, handle, constant, PROPERTIES, Property::READ_WRITE);
+ SetCustomProperties(node, handle, constant, ANIMATABLE_PROPERTIES, Property::ANIMATABLE);
+
+ } // for property nodes
+ }
+ else
+ {
+ DALI_SCRIPT_WARNING("Style applied to empty handle\n");
+ }
+}
+
+bool Builder::MapToTargetProperty(
+ Handle& propertyObject,
+ const std::string& key,
+ const TreeNode& node,
+ const Replacement& constant,
+ Property::Index& index,
+ Property::Value& value )
+{
+ bool mapped = false;
+
+ index = propertyObject.GetPropertyIndex( key );
+ if( Property::INVALID_INDEX != index )
+ {
+ Property::Type type = propertyObject.GetPropertyType(index);
+
+ // if node.value is a mapping, get the property value from the "mappings" table
+ if( node.GetType() == TreeNode::STRING )
+ {
+ std::string mappingKey;
+ if( GetMappingKey( node.GetString(), mappingKey) )
+ {
+ OptionalChild mappingRoot = IsChild( mParser.GetRoot(), KEYNAME_MAPPINGS );
+ mapped = GetPropertyMap( *mappingRoot, mappingKey.c_str(), type, value );
+ }
+ }
+ if( ! mapped )
+ {
+ mapped = DeterminePropertyFromNode( node, type, value, constant );
+ if( ! mapped )
+ {
+ // Just determine the property from the node and if it's valid, let the property object handle it
+ DeterminePropertyFromNode( node, value, constant );
+ mapped = ( value.GetType() != Property::NONE );
+ }
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("Key '%s' not found.\n", key.c_str());
+ }
+ return mapped;
+}
+
+bool Builder::GetPropertyMap( const TreeNode& mappingRoot, const char* theKey, Property::Type propertyType, Property::Value& value )
+{
+ KeyStack keyStack;
+ return RecursePropertyMap( mappingRoot, keyStack, theKey, propertyType, value );
+}
+
+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;