PluginGuiMagic allows you to add your own Components or LookAndFeel methods. This is how it’s done:
First you have to create a little wrapper around your component. This is simply inheriting foleys::GuiItem:
The minimum for the wrapper is to have a member of your component type, call addAndMakeVisible in the constructor and add the macro FOLEYS_DECLARE_GUI_FACTORY that allows the builder to create an instance of your component.
The colour translation and the settableProperties are optional. For more examples have a look into the file General/foleys_MagicJUCEFactories.cpp. This is how all the existing juce components are integrated.
Now you have to change the createEditor class to use the enhanced MagicBuilder:
juce::AudioProcessorEditor* ExtendingExampleAudioProcessor::createEditor()
{
// MAGIC GUI: we create our custom builder instance here, that will be available for all factories we add
auto builder = std::make_unique<foleys::MagicGUIBuilder>(magicState);
builder->registerJUCEFactories();
builder->registerFactory ("Lissajour", &LissajourItem::factory);
return new foleys::MagicPluginEditor (magicState, BinaryData::magic_xml, BinaryData::magic_xmlSize, std::move (builder));
}
The next time you start the plugin you will find the company in the list of components that you can drag into the tree or the plugin itself, if “edit” is enabled.
To add your own lookAndFeel class you use the same builder instance in the createEditor():
Nicely done. Makes it very easy to add custom components! I’m having one issue though that hopefully you can help me with… I added a custom component and it’s working. However it seems to mess up some things with the FoleysFinest look and feel, which I’m using as a starting point for developing my plugin. In particular my rotary sliders suddenly have a totally different style. Concerned that either I’m not doing something right, or there’s a bug lurking in there somewhere.
I’ve found that I can actually make this happen simply by overriding initializeBuilder and calling uilder.registerJUCEFactories(). i.e. without adding any of my own custom code. I’m attaching screenshots that show how the rotary slider look changes. One other clue is that I can no longer seem to select look and feel anymore when I’m in this state. Hopefully I’m just missing something simple?
The example in the above post was when you still needed to create and provide the MagicBuilder in the constructor. Now this happens automatically but with the callback you have the chance to add only those components and LookAndFeels you are going to use.
I hope that helps, let me know if you still have problems or need further explanations.