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< GuiItem > | createGuiItem (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... | |
Stylesheet & | getStylesheet () |
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... | |
GuiItem * | findGuiItemWithId (const juce::String &name) |
Lookup a Component through the tree. More... | |
GuiItem * | findGuiItem (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 |
RadioButtonManager & | getRadioButtonManager () |
void | changeListenerCallback (juce::ChangeBroadcaster *sender) override |
juce::var | getPropertyDefaultValue (juce::Identifier property) const |
Lookup the default value of the property. More... | |
MagicGUIState & | getMagicState () |
juce::UndoManager & | getUndoManager () |
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.
MagicGUIBuilder | ( | MagicGUIState & | magicStateToUse | ) |
References MagicGUIBuilder::updateStylesheet().
|
override |
std::unique_ptr< GuiItem > createGuiItem | ( | const juce::ValueTree & | node | ) |
Create a node from the description.
References MagicGUIBuilder::getGuiRootNode().
Referenced by PropertiesEditor::addTypeProperties(), Container::createSubComponents(), MagicGUIBuilder::getColourNames(), and MagicGUIBuilder::updateComponents().
void createGUI | ( | juce::Component & | parent | ) |
This triggers the rebuild of the GUI with setting the parent component.
References MagicGUIBuilder::updateComponents().
Stylesheet & getStylesheet | ( | ) |
Grant access to the stylesheet to look up visual and layout properties.
Referenced by PropertiesEditor::addDecoratorProperties(), PropertiesEditor::addNodeProperties(), Decorator::configure(), GuiItem::GuiItem(), StylePropertyComponent::lookupValue(), PropertiesEditor::setNodeToEdit(), ToolBox::stateWasReloaded(), PlotItem::update(), Decorator::updateColours(), GuiItem::updateInternal(), and GuiItem::~GuiItem().
juce::ValueTree & getConfigTree | ( | ) |
Grants access to the main XML, that holds all information.
References MagicGUIState::getGuiTree().
Referenced by MagicGUIBuilder::clearGUI(), MagicGUIBuilder::getGuiRootNode(), ToolBox::saveGUI(), MagicGUIBuilder::updateStylesheet(), and GUITreeEditor::updateTree().
juce::ValueTree getGuiRootNode | ( | ) |
Grants access to the GUI root node.
References MagicGUIBuilder::getConfigTree().
Referenced by MagicGUIBuilder::createGuiItem(), and MagicGUIBuilder::updateComponents().
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.
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().
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().
void updateLayout | ( | ) |
Recalculates the layout of all components.
References Stylesheet::setMediaSize(), and Stylesheet::updateValidRanges().
Referenced by MagicGUIBuilder::changeListenerCallback(), and MagicGUIBuilder::showOverlayDialog().
void updateColours | ( | ) |
Resolve all colours fresh, in case the palette has changed.
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().
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)
References Stylesheet::registerLookAndFeel().
Referenced by MagicProcessor::initialiseBuilder().
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().
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.
name | the name of the property. |
node | is 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().
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.
References MagicGUIBuilder::createGuiItem().
void clearGUI | ( | ) |
This resets the GUI to show a single empty container.
References MagicGUIBuilder::getConfigTree(), and MagicGUIBuilder::updateComponents().
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().
void closeOverlayDialog | ( | ) |
Closes a possibly open overlay dialog.
Referenced by ToolBox::loadDialog(), and ToolBox::saveDialog().
juce::StringArray getFactoryNames | ( | ) | const |
returns the names of all registered factories
Referenced by PropertiesEditor::setNodeToEdit(), and Palette::update().
std::function< void(juce::ComboBox &)> createChoicesMenuLambda | ( | juce::StringArray | choices | ) | const |
std::function< void(juce::ComboBox &)> createParameterMenuLambda | ( | ) | const |
References MagicGUIState::createParameterMenu().
Referenced by SliderItem::getSettableProperties(), ComboBoxItem::getSettableProperties(), TextButtonItem::getSettableProperties(), ToggleButtonItem::getSettableProperties(), LabelItem::getSettableProperties(), and XYDraggerItem::getSettableProperties().
std::function< void(juce::ComboBox &)> createPropertiesMenuLambda | ( | ) | const |
std::function< void(juce::ComboBox &)> createTriggerMenuLambda | ( | ) | const |
References MagicGUIState::createTriggerMenu().
Referenced by TextButtonItem::getSettableProperties().
std::function<void(juce::ComboBox&)> createObjectsMenuLambda | ( | ) | const |
RadioButtonManager & getRadioButtonManager | ( | ) |
Grant access to the RadioButtonManager
|
override |
References MagicGUIBuilder::updateLayout().
juce::var getPropertyDefaultValue | ( | juce::Identifier | property | ) | const |
Lookup the default value of the property.
Referenced by StylePropertyComponent::lookupValue().
MagicGUIState & getMagicState | ( | ) |
Referenced by GuiItem::getMagicState(), GuiItem::itemDropped(), and ToolBox::loadGUI().
juce::UndoManager & getUndoManager | ( | ) |