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 getConfigTree(), and updateStylesheet().
Referenced by registerFactory().
|
override |
References getConfigTree().
std::unique_ptr< GuiItem > createGuiItem | ( | const juce::ValueTree & | node | ) |
Create a node from the description.
References getGuiRootNode().
Referenced by getColourNames(), and updateComponents().
void createGUI | ( | juce::Component & | parent | ) |
This triggers the rebuild of the GUI with setting the parent component.
References updateComponents().
Stylesheet & getStylesheet | ( | ) |
Grant access to the stylesheet to look up visual and layout properties.
Referenced by Decorator::configure(), and Decorator::updateColours().
juce::ValueTree & getConfigTree | ( | ) |
Grants access to the main XML, that holds all information.
Referenced by clearGUI(), getGuiRootNode(), MagicGUIBuilder(), updateStylesheet(), and ~MagicGUIBuilder().
juce::ValueTree getGuiRootNode | ( | ) |
Grants access to the GUI root node.
References getConfigTree().
Referenced by createGuiItem(), and 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.
References GuiItem::findGuiItemWithId().
GuiItem * findGuiItem | ( | const juce::ValueTree & | node | ) |
Seeks recursively for a GuiItem.
References GuiItem::findGuiItem().
Referenced by 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 getConfigTree().
Referenced by MagicGUIBuilder(), and 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 createGuiItem(), getGuiRootNode(), and updateStylesheet().
Referenced by clearGUI(), createGUI(), and valueTreeRedirected().
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.
If you need a reference to the application, you can capture that in the factory lambda.
References MagicGUIBuilder().
Referenced by 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)
Referenced by MagicProcessor::initialiseBuilder().
void registerJUCEFactories | ( | ) |
Calling this method will register the bundled JUCE factories to give already access to many JUCE Components.
References 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(), 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.
References removeStyleClassReferences().
Referenced by removeStyleClassReferences().
juce::StringArray getColourNames | ( | juce::Identifier | type | ) |
This method returns the names of colours for a certain Component type.
References createGuiItem().
void clearGUI | ( | ) |
This resets the GUI to show a single empty container.
References getConfigTree(), and 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.
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 |
std::function< void(juce::ComboBox &)> createObjectsMenuLambda | ( | ) | const |
RadioButtonManager & getRadioButtonManager | ( | ) |
Grant access to the RadioButtonManager
|
override |
|
override |
References updateComponents().
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.
References setSelectedNode().
bool isEditModeOn | ( | ) | const |
void setSelectedNode | ( | const juce::ValueTree & | node | ) |
References findGuiItem(), and MagicGUIBuilder::Listener::selectedItem().
Referenced by setEditMode().
const juce::ValueTree & getSelectedNode | ( | ) | const |
void draggedItemOnto | ( | juce::ValueTree | dropped, |
juce::ValueTree | target, | ||
int | index = -1 ) |