Traversing DrawableComposite (from createFromSVG)

Hi,

when creating a DrawableComposite via createFromSVG() JUCE hierarchically sets the component names from the svg tag IDs.

While I beleive setting the component names is cosmetical only it would add functionality to set the component IDs instead or additionally.

This way I can traverse the component tree by findChildWithID() and attach the returned components to GUI controls.

Cheers,

raketa

 

I can provide the changed file, if you think it make sense to generally implement it this way.

I'm surprised it doesn't already do that - sure, if it's a one-line change I should make that happen.

Great,

its actually a "three"-liner:

setName() ocurres three times in juce_SVGParser.cpp.

--- modules/juce_gui_basics/drawables/juce_SVGParser.cpp    (revision 61)
+++ modules/juce_gui_basics/drawables/juce_SVGParser.cpp    (working copy)
@@ -49,12 +49,12 @@
     //==============================================================================
     Drawable* parseSVGElement (const XmlPath& xml)
     {
         if (! xml->hasTagNameIgnoringNamespace ("svg"))
            return nullptr;

         DrawableComposite* const drawable = new DrawableComposite();
-        drawable->setName (xml->getStringAttribute ("id"));
+        drawable->setComponentID (xml->getStringAttribute ("id"));

         SVGState newState (*this);

@@ -397,7 +397,7 @@
     {
         DrawableComposite* const drawable = new DrawableComposite();

-        drawable->setName (xml->getStringAttribute ("id"));
+        drawable->setComponentID (xml->getStringAttribute ("id"));
         if (xml->hasAttribute ("transform"))
         {
@@ -542,7 +542,7 @@
         }

         DrawablePath* dp = new DrawablePath();
-        dp->setName (xml->getStringAttribute ("id"));
+        dp->setComponentID (xml->getStringAttribute ("id"));
         dp->setFill (Colours::transparentBlack);

         path.applyTransform (transform);