Reusable Components

Hi - with the sunsetting of the JUCE GUI editor, we’re looking at PGM as an alternative. There are many things I like about it so far. I’ve experimented with the GuiItem and have successfully added a JUCE component as a reusable component, so this is usable, but are there any thoughts on the ability to add a sub-view that would have its own magic state/builder, such that you could have a DOM within a DOM, so to speak? That would allow for creating reusable PGM components purely in the PGM editor at runtime.

One of the things I’d like to do is drop a PGM component into my GuiItem (eg a Meter), but that’s not feasible, so if the component was purely a PGM component with its own backing XML, that would solve that.


Hi and welcome!

Thanks for checking out Plugin-gui-magic.
There are two ways to achieve that. My preferred would be this:

The ValueTree can be changed even at runtime, so you could simply copy or even generate dynamically the child views you want to embed and hang it into the tree. The GUI should react automatically and display the new children accordingly.

The other method involves coding, but is also doable:

The machinery to create a View is not limited to the MagicPluginEditor. You can create a component and wrap it into a GuiItem. This component would need it’s own MagicState or at least a reference to one.
Then you would add a MagicBuilder and connect it to the callbacks of the component.

If you want examples on how to do that you could either look at the MagicPluginEditor or the PlayerExample:

If you want to embed hosted plugins though, it might get tricky, but theoretically it could be possibl as well.

Thanks @daniel!

Yes, I’ve tried both of those methods. Method #2 seems to work best for our situation (this is for an app and not a plugin), but I hadn’t considered supplying the component/GuiItem its own MagicState/MagicBuilder (right now it’s just a plane JUCE component containing standard JUCE controls). I will experiment with that. Thanks for the help!