Home to Foleys Finest Audio

How to #3 add your own Components or LookAndFeel

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->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():

builder->registerLookAndFeel ("LookAndFeelName", std::make_unique<MyLookAndFeel>());

Now you will find the MyLookAndFeelName in the drop down and you can select it.

I hope that helps, let me know if there are questions.

Copyright © 2020 Foleys Finest Audio UG. All rights reserved.