WYSWYG editor for JUCE GUIs including Visualisers
Loading...
Searching...
No Matches
MagicGUIBuilder Class Reference

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

#include <foleys_MagicGUIBuilder.h>

Inherits ChangeListener, and Listener.

Classes

class  Listener
 

Public Member Functions

 MagicGUIBuilder (MagicGUIState &magicStateToUse)
 
 ~MagicGUIBuilder () override
 
std::unique_ptr< GuiItemcreateGuiItem (const juce::ValueTree &node)
 Create a node from the description.
 
void createGUI (juce::Component &parent)
 This triggers the rebuild of the GUI with setting the parent component.
 
StylesheetgetStylesheet ()
 Grant access to the stylesheet to look up visual and layout properties.
 
juce::ValueTree & getConfigTree ()
 Grants access to the main XML, that holds all information.
 
juce::ValueTree getGuiRootNode ()
 Grants access to the GUI root node.
 
GuiItemfindGuiItemWithId (const juce::String &name)
 Lookup a Component through the tree.
 
GuiItemfindGuiItem (const juce::ValueTree &node)
 Seeks recursively for a GuiItem.
 
void updateStylesheet ()
 This selects the stylesheet node and sets it to the Stylesheet.
 
void updateComponents ()
 Recreates all components from the <View/> tree.
 
void updateLayout (juce::Rectangle< int > bounds)
 Recalculates the layout of all components.
 
void updateColours ()
 Resolve all colours fresh, in case the palette has changed.
 
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.
 
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.
 
void registerJUCELookAndFeels ()
 Registers automatically the JUCE LookAndFeel classes (V1..V4 at the time of writing)
 
void registerJUCEFactories ()
 Calling this method will register the bundled JUCE factories to give already access to many JUCE Components.
 
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.
 
void removeStyleClassReferences (juce::ValueTree tree, const juce::String &name)
 This will go through all nodes and delete the reference to a class.
 
juce::StringArray getColourNames (juce::Identifier type)
 This method returns the names of colours for a certain Component type.
 
void clearGUI ()
 This resets the GUI to show a single empty container.
 
void showOverlayDialog (std::unique_ptr< juce::Component > dialog)
 This is used to display a dialog box.
 
void closeOverlayDialog ()
 Closes a possibly open overlay dialog.
 
juce::StringArray getFactoryNames () const
 returns the names of all registered factories
 
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
 
void valueTreeRedirected (juce::ValueTree &treeWhichHasBeenChanged) override
 
juce::var getPropertyDefaultValue (juce::Identifier property) const
 Lookup the default value of the property.
 
MagicGUIStategetMagicState ()
 
juce::UndoManager & getUndoManager ()
 
void attachToolboxToWindow (juce::Component &window)
 
ToolBoxgetMagicToolBox ()
 
void addListener (Listener *listener)
 
void removeListener (Listener *listener)
 
void setEditMode (bool shouldEdit)
 This method sets the GUI in edit mode, that allows to drag the components around.
 
bool isEditModeOn () const
 
void setSelectedNode (const juce::ValueTree &node)
 
const juce::ValueTree & getSelectedNode () const
 
void draggedItemOnto (juce::ValueTree dropped, juce::ValueTree target, int index=-1)
 

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

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

◆ getConfigTree()

◆ getGuiRootNode()

◆ 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.

Referenced by MagicGUIBuilder::setSelectedNode().

◆ 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(), Stylesheet::setStyle(), Stylesheet::updateStyleClasses(), and Stylesheet::updateValidRanges().

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(), ToolBox::stateWasReloaded(), ToolBox::ToolBox(), and MagicGUIBuilder::valueTreeRedirected().

◆ updateLayout()

void updateLayout ( juce::Rectangle< int > bounds)

Recalculates the layout of all components.

References Stylesheet::setMediaSize(), and Stylesheet::updateValidRanges().

◆ updateColours()

void updateColours ( )

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

◆ registerFactory()

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.

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.

References Stylesheet::registerLookAndFeel().

◆ 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.

References Stylesheet::getStyleProperty().

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

◆ removeStyleClassReferences()

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

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

References MagicGUIBuilder::removeStyleClassReferences().

Referenced by PropertiesEditor::deleteClass(), and MagicGUIBuilder::removeStyleClassReferences().

◆ 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().

Referenced by ToolBox::ToolBox().

◆ 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.

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

◆ createPropertiesMenuLambda()

◆ createTriggerMenuLambda()

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

◆ createObjectsMenuLambda()

template<typename ObjectType >
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

◆ valueTreeRedirected()

void valueTreeRedirected ( juce::ValueTree & treeWhichHasBeenChanged)
override

◆ getPropertyDefaultValue()

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

Lookup the default value of the property.

Referenced by Stylesheet::getStyleProperty(), and StylePropertyComponent::lookupValue().

◆ getMagicState()

◆ getUndoManager()

◆ attachToolboxToWindow()

void attachToolboxToWindow ( juce::Component & window)

◆ getMagicToolBox()

ToolBox & getMagicToolBox ( )

◆ addListener()

void addListener ( Listener * listener)

Referenced by ToolBox::ToolBox().

◆ removeListener()

void removeListener ( Listener * listener)

Referenced by ToolBox::~ToolBox().

◆ setEditMode()

void setEditMode ( bool shouldEdit)

This method sets the GUI in edit mode, that allows to drag the components around.

References MagicGUIBuilder::setSelectedNode().

Referenced by ToolBox::ToolBox().

◆ isEditModeOn()

bool isEditModeOn ( ) const

◆ setSelectedNode()

void setSelectedNode ( const juce::ValueTree & node)

◆ getSelectedNode()

const juce::ValueTree & getSelectedNode ( ) const

◆ draggedItemOnto()

void draggedItemOnto ( juce::ValueTree dropped,
juce::ValueTree target,
int index = -1 )

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