+
+ // a style may have other styles, which has other styles etc so we apply in reverse by convention.
+ for(TreeNodeList::reverse_iterator iter = additionalStyleNodes.rbegin(); iter != additionalStyleNodes.rend(); ++iter)
+ {
+ RecordStyle(style, *(*iter), handle, constant);
+ ApplySignals(root, *(*iter), handle);
+ ApplyStylesByActor(root, *(*iter), handle, constant);
+ }
+ }
+
+ RecordStyle(style, node, handle, constant);
+ mStyles.Add(styleName, style); // shallow copy
+ matchedStyle = &style;
+ }
+ }
+ }
+
+ if(matchedStyle)
+ {
+ StylePtr style(*matchedStyle);
+ Dictionary<Property::Map> instancedProperties;
+ style->ApplyVisualsAndPropertiesRecursively(handle, instancedProperties);
+ }
+ else // If there were no styles, instead set properties
+ {
+ SetProperties(node, handle, constant);
+ }
+ ApplySignals(root, node, handle);
+ ApplyStylesByActor(root, node, handle, constant);
+}
+
+void Builder::RecordStyle(StylePtr style,
+ const TreeNode& node,
+ Dali::Handle& handle,
+ const Replacement& replacements)
+{
+ // With repeated calls, accumulate inherited states, visuals and properties
+ // but override any with same name
+
+ for(TreeNode::ConstIterator iter = node.CBegin(); iter != node.CEnd(); ++iter)
+ {
+ const TreeNode::KeyNodePair& keyValue = *iter;
+ std::string key(keyValue.first);
+ if(key == KEYNAME_STATES)
+ {
+ const TreeNode& states = keyValue.second;
+ if(states.GetType() != TreeNode::OBJECT)
+ {
+ DALI_LOG_WARNING("RecordStyle() Node \"%s\" is not a JSON object\n", key.c_str());
+ continue;
+ }
+
+ for(TreeNode::ConstIterator iter = states.CBegin(); iter != states.CEnd(); ++iter)
+ {
+ const TreeNode& stateNode = (*iter).second;
+ const char* stateName = stateNode.GetName();
+ if(stateNode.GetType() != TreeNode::OBJECT)
+ {
+ DALI_LOG_WARNING("RecordStyle() Node \"%s\" is not a JSON object\n", stateName);
+ continue;
+ }
+
+ StylePtr* stylePtr = style->subStates.Find(stateName);
+ if(stylePtr)