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< GuiItem > | createGuiItem (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. | |
Stylesheet & | getStylesheet () |
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. | |
GuiItem * | findGuiItemWithId (const juce::String &name) |
Lookup a Component through the tree. | |
GuiItem * | findGuiItem (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 |
RadioButtonManager & | getRadioButtonManager () |
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. | |
MagicGUIState & | getMagicState () |
juce::UndoManager & | getUndoManager () |
void | attachToolboxToWindow (juce::Component &window) |
ToolBox & | getMagicToolBox () |
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) |
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::getConfigTree(), and MagicGUIBuilder::updateStylesheet().
|
override |
References MagicGUIBuilder::getConfigTree().
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(), PropertiesEditor::deleteClass(), GuiItem::GuiItem(), StylePropertyComponent::lookupValue(), PropertiesEditor::PropertiesEditor(), PropertiesEditor::setNodeToEdit(), ToolBox::stateWasReloaded(), StyleColourPropertyComponent::StyleColourPropertyComponent(), PlotItem::update(), Decorator::updateColours(), GuiItem::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(), MagicGUIBuilder::MagicGUIBuilder(), ToolBox::saveGUI(), MagicGUIBuilder::updateStylesheet(), GUITreeEditor::updateTree(), and MagicGUIBuilder::~MagicGUIBuilder().
juce::ValueTree getGuiRootNode | ( | ) |
Grants access to the GUI root node.
References MagicGUIBuilder::getConfigTree().
Referenced by PropertiesEditor::addNodeProperties(), MagicGUIBuilder::createGuiItem(), PropertiesEditor::deleteClass(), GuiItem::setDraggable(), 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.
GuiItem * findGuiItem | ( | const juce::ValueTree & | node | ) |
Seeks recursively for a GuiItem.
Referenced by MagicGUIBuilder::setSelectedNode().
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().
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().
void updateLayout | ( | juce::Rectangle< int > | bounds | ) |
Recalculates the layout of all components.
References Stylesheet::setMediaSize(), and Stylesheet::updateValidRanges().
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.
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.
References Stylesheet::registerLookAndFeel().
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. |
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().
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().
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().
Referenced by ToolBox::ToolBox().
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().
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 ComboBoxItem::getSettableProperties(), LabelItem::getSettableProperties(), SliderItem::getSettableProperties(), TextButtonItem::getSettableProperties(), ToggleButtonItem::getSettableProperties(), and XYDraggerItem::getSettableProperties().
std::function< void(juce::ComboBox &)> createPropertiesMenuLambda | ( | ) | const |
References MagicGUIState::populatePropertiesMenu().
Referenced by PropertiesEditor::addContainerProperties(), PropertiesEditor::addDecoratorProperties(), PropertiesEditor::addNodeProperties(), LabelItem::getSettableProperties(), SliderItem::getSettableProperties(), TextButtonItem::getSettableProperties(), and ToggleButtonItem::getSettableProperties().
std::function< void(juce::ComboBox &)> createTriggerMenuLambda | ( | ) | const |
References MagicGUIState::createTriggerMenu().
Referenced by TextButtonItem::getSettableProperties().
std::function< void(juce::ComboBox &)> createObjectsMenuLambda | ( | ) | const |
References MagicGUIState::getObjectIDsByType().
Referenced by LevelMeterItem::getSettableProperties(), ListBoxItem::getSettableProperties(), and PlotItem::getSettableProperties().
RadioButtonManager & getRadioButtonManager | ( | ) |
Grant access to the RadioButtonManager
|
override |
|
override |
References MagicGUIBuilder::updateComponents().
juce::var getPropertyDefaultValue | ( | juce::Identifier | property | ) | const |
Lookup the default value of the property.
Referenced by Stylesheet::getStyleProperty(), and StylePropertyComponent::lookupValue().
MagicGUIState & getMagicState | ( | ) |
juce::UndoManager & getUndoManager | ( | ) |
Referenced by Stylesheet::addPaletteEntry(), GuiItem::mouseDown(), StyleBoolPropertyComponent::refresh(), StyleChoicePropertyComponent::refresh(), StyleColourPropertyComponent::refresh(), StyleGradientPropertyComponent::refresh(), StyleTextPropertyComponent::refresh(), Stylesheet::setColourPalette(), GuiItem::setDraggable(), StyleBoolPropertyComponent::StyleBoolPropertyComponent(), StyleColourPropertyComponent::StyleColourPropertyComponent(), StyleGradientPropertyComponent::StyleGradientPropertyComponent(), StylePropertyComponent::StylePropertyComponent(), and StyleTextPropertyComponent::StyleTextPropertyComponent().
void attachToolboxToWindow | ( | juce::Component & | window | ) |
References MagicGUIState::getResourcesFolder().
ToolBox & getMagicToolBox | ( | ) |
Referenced by StylePropertyComponent::mouseDoubleClick().
void addListener | ( | Listener * | listener | ) |
Referenced by ToolBox::ToolBox().
void removeListener | ( | Listener * | listener | ) |
Referenced by ToolBox::~ToolBox().
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().
bool isEditModeOn | ( | ) | const |
Referenced by GuiItem::paintOverChildren(), and GuiItem::updateInternal().
void setSelectedNode | ( | const juce::ValueTree & | node | ) |
References MagicGUIBuilder::findGuiItem(), and MagicGUIBuilder::Listener::selectedItem().
Referenced by GuiItem::mouseUp(), MagicGUIBuilder::setEditMode(), and ToolBox::setSelectedNode().
const juce::ValueTree & getSelectedNode | ( | ) | const |
Referenced by GuiItem::itemDropped(), ToolBox::keyPressed(), and GuiItem::paintOverChildren().
void draggedItemOnto | ( | juce::ValueTree | dropped, |
juce::ValueTree | target, | ||
int | index = -1 ) |
Referenced by GuiItem::itemDropped(), and ToolBox::keyPressed().