+void Builder::RecordTransitions(
+ const TreeNode::KeyNodePair& keyValue,
+ Property::Array& value,
+ const Replacement& replacements )
+{
+ //@todo add new transitions to style.transitions
+ // override existing transitions. A transition matches on target & property name
+ const TreeNode& node = keyValue.second;
+ if( node.GetType() == TreeNode::ARRAY )
+ {
+ Dali::Property::Value property(Property::ARRAY);
+ if( DeterminePropertyFromNode( node, Property::ARRAY, property, replacements ) )
+ {
+ value = *property.GetArray();
+ }
+ }
+ else if( node.GetType() == TreeNode::OBJECT )
+ {
+ Dali::Property::Value property(Property::MAP);
+ if( DeterminePropertyFromNode( node, Property::MAP, property, replacements ) )
+ {
+ Property::Array propertyArray;
+ propertyArray.Add( property );
+ value = propertyArray;
+ }
+ }
+ else
+ {
+ DALI_LOG_WARNING( "RecordStyle() Node \"%s\" is not a JSON array or object\n", keyValue.first );
+ }
+}
+
+void Builder::RecordTransitionData(
+ const TreeNode::KeyNodePair& keyValue,
+ Toolkit::TransitionData& transitionData,
+ const Replacement& replacements )
+{
+ const TreeNode& node = keyValue.second;
+ if( node.GetType() == TreeNode::ARRAY )
+ {
+ Dali::Property::Value property(Property::ARRAY);
+ if( DeterminePropertyFromNode( keyValue.second, Property::ARRAY, property, replacements ) )
+ {
+ transitionData = Toolkit::TransitionData::New( *property.GetArray() );
+ }
+ }
+ else if( node.GetType() == TreeNode::OBJECT )
+ {
+ Dali::Property::Value property(Property::MAP);
+ if( DeterminePropertyFromNode( keyValue.second, Property::MAP, property, replacements ) )
+ {
+ transitionData = Toolkit::TransitionData::New( *property.GetMap() );
+ }
+ }
+}
+
+
+// Set properties from node on handle.
+void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node,
+ Dali::Handle& handle, const Replacement& constant )
+{
+ SetProperties( node, handle, constant );
+ ApplySignals( root, node, handle );
+}
+
+void Builder::ApplySignals(const TreeNode& root, const TreeNode& node, Dali::Handle& handle )
+{
+ Actor actor = Actor::DownCast(handle);
+ if( actor )
+ {
+ // add signals
+ SetupSignalAction( mSlotDelegate.GetConnectionTracker(), root, node, actor, this );
+ SetupPropertyNotification( mSlotDelegate.GetConnectionTracker(), root, node, actor, this );
+ }
+}
+
+
+// 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 )
+ {
+ Dali::Actor foundActor;
+
+ if( (*iter).first )
+ {
+ foundActor = actor.FindChildByName( (*iter).first );
+ }
+
+ if( !foundActor )
+ {
+ DALI_SCRIPT_VERBOSE("Cannot find actor in style application '%s'\n", (*iter).first);
+ }
+ else
+ {
+ DALI_SCRIPT_VERBOSE("Styles applied to actor '%s'\n", (*iter).first);
+ ApplyProperties( root, (*iter).second, foundActor, constant );
+ }
+ }
+ }
+ }
+}
+
+/*
+ * 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;
+ 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 )