foleys_gui_magic
WYSWYG editor for JUCE GUIs including Visualisers
Public Member Functions | List of all members
MagicGUIBuilder Class Reference

The MagicGUIBuilder is responsible to recreate the GUI from a single ValueTree. More...

Inherits ChangeListener.

Public Member Functions

 MagicGUIBuilder (MagicGUIState &magicStateToUse)
 
 ~MagicGUIBuilder () override
 
std::unique_ptr< GuiItemcreateGuiItem (const juce::ValueTree &node)
 Create a node from the description. More...
 
void createGUI (juce::Component &parent)
 This triggers the rebuild of the GUI with setting the parent component. More...
 
StylesheetgetStylesheet ()
 Grant access to the stylesheet to look up visual and layout properties. More...
 
juce::ValueTree & getConfigTree ()
 Grants access to the main XML, that holds all information. More...
 
juce::ValueTree getGuiRootNode ()
 Grants access to the GUI root node. More...
 
GuiItemfindGuiItemWithId (const juce::String &name)
 Lookup a Component through the tree. More...
 
GuiItemfindGuiItem (const juce::ValueTree &node)
 Seeks recursively for a GuiItem. More...
 
void updateStylesheet ()
 This selects the stylesheet node and sets it to the Stylesheet. More...
 
void updateComponents ()
 Recreates all components from the <View> tree. More...
 
void updateLayout ()
 Recalculates the layout of all components. More...
 
void updateColours ()
 Resolve all colours fresh, in case the palette has changed. More...
 
void registerFactory (juce::Identifier type, std::unique_ptr< GuiItem >(*factory)(MagicGUIBuilder &builder, const juce::ValueTree &))
 Register a factory for Components to be available in the GUI editor. More...
 
void registerLookAndFeel (juce::String name, std::unique_ptr< juce::LookAndFeel > lookAndFeel)
 With that method you can register your custom LookAndFeel class and apply it to different components. More...
 
void registerJUCELookAndFeels ()
 Registers automatically the JUCE LookAndFeel classes (V1..V4 at the time of writing) More...
 
void registerJUCEFactories ()
 Calling this method will register the bundled JUCE factories to give already access to many JUCE Components. More...
 
juce::var getStyleProperty (const juce::Identifier &name, const juce::ValueTree &node) const
 This method traverses the dom and checks each style, if that property was defined. More...
 
void removeStyleClassReferences (juce::ValueTree tree, const juce::String &name)
 This will go through all nodes and delete the reference to a class. More...
 
juce::StringArray getColourNames (juce::Identifier type)
 This method returns the names of colours for a certain Component type. More...
 
void clearGUI ()
 This resets the GUI to show a single empty container. More...
 
void showOverlayDialog (std::unique_ptr< juce::Component > dialog)
 This is used to display a dialog box. More...
 
void closeOverlayDialog ()
 Closes a possibly open overlay dialog. More...
 
juce::StringArray getFactoryNames () const
 returns the names of all registered factories More...
 
std::function< void(juce::ComboBox &)> createChoicesMenuLambda (juce::StringArray choices) const
 
std::function< void(juce::ComboBox &)> createParameterMenuLambda () const
 
std::function< void(juce::ComboBox &)> createPropertiesMenuLambda () const
 
std::function< void(juce::ComboBox &)> createTriggerMenuLambda () const
 
template<typename ObjectType >
std::function< void(juce::ComboBox &)> createObjectsMenuLambda () const
 
RadioButtonManagergetRadioButtonManager ()
 
void changeListenerCallback (juce::ChangeBroadcaster *sender) override
 
juce::var getPropertyDefaultValue (juce::Identifier property) const
 Lookup the default value of the property. More...
 
MagicGUIStategetMagicState ()
 
juce::UndoManager & getUndoManager ()
 

Detailed Description

The MagicGUIBuilder is responsible to recreate the GUI from a single ValueTree.

You can add your own factories to the builder to allow additional components.

Constructor & Destructor Documentation

◆ MagicGUIBuilder()

MagicGUIBuilder ( MagicGUIState magicStateToUse)

◆ ~MagicGUIBuilder()

~MagicGUIBuilder ( )
override

Member Function Documentation

◆ createGuiItem()

std::unique_ptr< GuiItem > createGuiItem ( const juce::ValueTree &  node)

◆ createGUI()

void createGUI ( juce::Component &  parent)

This triggers the rebuild of the GUI with setting the parent component.

References MagicGUIBuilder::updateComponents().

◆ getStylesheet()

Stylesheet & getStylesheet ( )

◆ getConfigTree()

juce::ValueTree & getConfigTree ( )

◆ getGuiRootNode()

juce::ValueTree getGuiRootNode ( )

Grants access to the GUI root node.

References MagicGUIBuilder::getConfigTree().

Referenced by MagicGUIBuilder::createGuiItem(), and MagicGUIBuilder::updateComponents().

◆ findGuiItemWithId()

GuiItem * findGuiItemWithId ( const juce::String &  name)

Lookup a Component through the tree.

It will return the first with that id regardless if there is another one. We discourage using that function, because that Component can be deleted and recreated at any time without notice.

◆ findGuiItem()

GuiItem * findGuiItem ( const juce::ValueTree &  node)

Seeks recursively for a GuiItem.

◆ updateStylesheet()

void updateStylesheet ( )

This selects the stylesheet node and sets it to the Stylesheet.

If no stylesheet is found, a default one is created.

References MagicGUIBuilder::getConfigTree().

Referenced by MagicGUIBuilder::MagicGUIBuilder(), and MagicGUIBuilder::updateComponents().

◆ updateComponents()

void updateComponents ( )

Recreates all components from the <View> tree.

If no div tree is found, createDefaultGUITree is called to give subclasses a chance to create a suitable default.

References MagicGUIBuilder::createGuiItem(), MagicGUIBuilder::getGuiRootNode(), and MagicGUIBuilder::updateStylesheet().

Referenced by MagicGUIBuilder::clearGUI(), MagicGUIBuilder::createGUI(), and ToolBox::stateWasReloaded().

◆ updateLayout()

void updateLayout ( )

◆ updateColours()

void updateColours ( )

Resolve all colours fresh, in case the palette has changed.

◆ registerFactory()

void registerFactory ( juce::Identifier  type,
std::unique_ptr< GuiItem >(*)(MagicGUIBuilder &builder, const juce::ValueTree &)  factory 
)

Register a factory for Components to be available in the GUI editor.

If you need a reference to the application, you can capture that in the factory lambda.

Referenced by MagicGUIBuilder::registerJUCEFactories().

◆ registerLookAndFeel()

void registerLookAndFeel ( juce::String  name,
std::unique_ptr< juce::LookAndFeel >  lookAndFeel 
)

With that method you can register your custom LookAndFeel class and apply it to different components.

◆ registerJUCELookAndFeels()

void registerJUCELookAndFeels ( )

Registers automatically the JUCE LookAndFeel classes (V1..V4 at the time of writing)

References Stylesheet::registerLookAndFeel().

Referenced by MagicProcessor::initialiseBuilder().

◆ registerJUCEFactories()

void registerJUCEFactories ( )

Calling this method will register the bundled JUCE factories to give already access to many JUCE Components.

References MagicGUIBuilder::registerFactory().

Referenced by MagicProcessor::initialiseBuilder().

◆ getStyleProperty()

juce::var getStyleProperty ( const juce::Identifier &  name,
const juce::ValueTree &  node 
) const

This method traverses the dom and checks each style, if that property was defined.

Parameters
namethe name of the property.
nodeis the node in the DOM. This is used for inheritance by traversing upwards.

Referenced by Decorator::configure(), Container::configureFlexBox(), GuiItem::configurePosition(), GuiItem::getProperty(), TextButtonItem::update(), ToggleButtonItem::update(), LabelItem::update(), Container::update(), RootItem::updateColours(), and Decorator::updateColours().

◆ removeStyleClassReferences()

void removeStyleClassReferences ( juce::ValueTree  tree,
const juce::String &  name 
)

This will go through all nodes and delete the reference to a class.

◆ getColourNames()

juce::StringArray getColourNames ( juce::Identifier  type)

This method returns the names of colours for a certain Component type.

References MagicGUIBuilder::createGuiItem().

◆ clearGUI()

void clearGUI ( )

This resets the GUI to show a single empty container.

References MagicGUIBuilder::getConfigTree(), and MagicGUIBuilder::updateComponents().

◆ showOverlayDialog()

void showOverlayDialog ( std::unique_ptr< juce::Component >  dialog)

This is used to display a dialog box.

It is called by the GUI editor, but in future it might be reached using the configured GUI.

References MagicGUIBuilder::updateLayout().

Referenced by ToolBox::loadDialog(), and ToolBox::saveDialog().

◆ closeOverlayDialog()

void closeOverlayDialog ( )

Closes a possibly open overlay dialog.

Referenced by ToolBox::loadDialog(), and ToolBox::saveDialog().

◆ getFactoryNames()

juce::StringArray getFactoryNames ( ) const

returns the names of all registered factories

Referenced by PropertiesEditor::setNodeToEdit(), and Palette::update().

◆ createChoicesMenuLambda()

std::function< void(juce::ComboBox &)> createChoicesMenuLambda ( juce::StringArray  choices) const

◆ createParameterMenuLambda()

std::function< void(juce::ComboBox &)> createParameterMenuLambda ( ) const

◆ createPropertiesMenuLambda()

std::function< void(juce::ComboBox &)> createPropertiesMenuLambda ( ) const

◆ createTriggerMenuLambda()

std::function< void(juce::ComboBox &)> createTriggerMenuLambda ( ) const

◆ createObjectsMenuLambda()

std::function<void(juce::ComboBox&)> createObjectsMenuLambda ( ) const

◆ getRadioButtonManager()

RadioButtonManager & getRadioButtonManager ( )

Grant access to the RadioButtonManager

Returns
the radioButtonManager

◆ changeListenerCallback()

void changeListenerCallback ( juce::ChangeBroadcaster *  sender)
override

◆ getPropertyDefaultValue()

juce::var getPropertyDefaultValue ( juce::Identifier  property) const

Lookup the default value of the property.

Referenced by StylePropertyComponent::lookupValue().

◆ getMagicState()

MagicGUIState & getMagicState ( )

◆ getUndoManager()

juce::UndoManager & getUndoManager ( )

The documentation for this class was generated from the following files: