Request: DrawableButtons in the GUI editor


I'd like to make a request for the Introjucer GUI editor to support DrawableButtons. Specifically, I'd like to be able to use SVG resources in buttons. I figured out how to do it, but GUI editor support would save me a lot of work. In case anyone else is trying to do this, here's what I figured out:

1) Add an SVG resource to your custom component.

2) Add a new Generic Component in the GUI editor.

3) Set its class to DrawableButton

4) Set the constructor params to "name", DrawableButton::ImageOnButtonBackground    (Set the name and style to whatever you want, but the constructor is going to require you to pass something in. Reasonable default values would make this less cumbersome.)

5) Add a Drawable member variable to your custom component.

6) Initialize the Drawable member variable like so: myDrawable = Drawable::createFromImageData (test_svg, test_svgSize);

7) Tell your drawable button to use the SVG drawable: myDrawableButton->setImages(myDrawable);

8) Add your custom component as a listener of the drawable button.

This is a lot of work for a button with an SVG resource in the middle of it. It's rather straightforward once you've figured it out, but it feels like you're fighting the GUI editor. If the GUI editor could support drawable buttons natively, it would be as simple as adding an image button:

1) Add an SVG resource to your custom component.

2) Add a DrawableButton and set it to use the SVG as its drawable source.


Or maybe the GUI editor could be a little smart about things, and if you use an SVG as a button's source, construct a DrawableButton. Or, if you use a PNG, construct a regular ImageButton.


Anyway, I hope I don't come across as too "complainy". I'm new to JUCE, but I really like what I've learned so far. I'm not sure how much the community contributes to the source code - is this the kind of feature that I should try adding to the Introjucer myself?


I would chime in here and say yes, if you have the inclination go ahead and try implementing it yourself, then submit a patch to Jules / Fabian / ROLI and see what they say. I've submitted a few small patches to Introjucer over the last few months. 


Exactly, it sounds like a very useful addition, but unfortunately right now we don't have the time to implement this ourselves.


OK, I'll give it a shot. I've looked into how other GUI components work, and I think I can do a DrawableButton.

Thanks for the repsonsiveness on this forum, it's a great help getting into the world of JUCE!