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

The Stylesheet class represents all style information. More...

Inherits Listener.

Public Member Functions

 Stylesheet (MagicGUIBuilder &builder)
 
void setStyle (const juce::ValueTree &node)
 The Stylesheet node in the XML can contain several Styles to select from. More...
 
bool setMediaSize (int width, int height)
 Set the size of the UI. More...
 
void updateValidRanges ()
 Reads the range, in which the properties won't change due to conditional classes. More...
 
void updateStyleClasses ()
 Read the style classes and connect variables. More...
 
void setColourPalette ()
 Updates the colourPalette. More...
 
void addPaletteEntry (const juce::String &name, juce::Colour colour, bool keepIfExists)
 
juce::ValueTree getCurrentPalette ()
 
juce::StringArray getPaletteEntryNames () const
 Returns all variables for selection in colour values. More...
 
juce::var getStyleProperty (const juce::Identifier &name, const juce::ValueTree &node, bool inherit=true, juce::ValueTree *definedHere=nullptr) const
 This method traverses the dom and checks each style, if that property was defined. More...
 
juce::LookAndFeel * getLookAndFeel (const juce::ValueTree &node) const
 Return the LookAndFeel for the node. More...
 
juce::Image getBackgroundImage (const juce::ValueTree &node) const
 Finds a background image for the given node. More...
 
juce::Colour getColour (const juce::String &name) const
 Lookup a colour. More...
 
juce::ValueTree getCurrentStyle () const
 
juce::ValueTree addNewStyleClass (const juce::String &name, juce::UndoManager *undo)
 Add a new style class node, so elements of your GUI can inherit that class. More...
 
void deleteStyleClass (const juce::String &name, juce::UndoManager *undo)
 Delete a style class. 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...
 
juce::StringArray getAllClassesNames () const
 
juce::StringArray getLookAndFeelNames () const
 
bool isClassNode (const juce::ValueTree &node) const
 
bool isTypeNode (const juce::ValueTree &node) const
 
bool isIdNode (const juce::ValueTree &node) const
 
bool isColourPaletteNode (const juce::ValueTree &node) const
 
void addListener (juce::ValueTree::Listener *listener)
 
void removeListener (juce::ValueTree::Listener *listener)
 

Static Public Member Functions

static juce::Colour parseColour (const juce::String &name)
 This is a slightly more intelligent colour lookup than the JUCE one, as it allows to use colour names, as well as 6 digit colour tuples (JUCE will use red as alpha in that case) More...
 

Detailed Description

The Stylesheet class represents all style information.

It is organised in types, which corresponds to the Components created, classes that can be referenced by any node, and nodes referenced by id.

Constructor & Destructor Documentation

◆ Stylesheet()

Stylesheet ( MagicGUIBuilder builder)

Member Function Documentation

◆ setStyle()

void setStyle ( const juce::ValueTree &  node)

The Stylesheet node in the XML can contain several Styles to select from.

Use this method to select a style.

References Stylesheet::setColourPalette().

◆ setMediaSize()

bool setMediaSize ( int  width,
int  height 
)

Set the size of the UI.

This will be used to resolve the properties from the style classes.

Parameters
widthis the width of the UI
heightis the height of the UI
Returns
false, if the properties are likely to have changed (because a conditional class became valid or invalid)

Referenced by MagicGUIBuilder::updateLayout().

◆ updateValidRanges()

void updateValidRanges ( )

Reads the range, in which the properties won't change due to conditional classes.

Referenced by MagicGUIBuilder::updateLayout().

◆ updateStyleClasses()

void updateStyleClasses ( )

Read the style classes and connect variables.

Parameters
builderis the managed builder instance, so the style class can connect to the variables

◆ setColourPalette()

void setColourPalette ( )

Updates the colourPalette.

References MagicGUIBuilder::getUndoManager().

Referenced by Stylesheet::setStyle(), and Stylesheet::Stylesheet().

◆ addPaletteEntry()

void addPaletteEntry ( const juce::String &  name,
juce::Colour  colour,
bool  keepIfExists 
)

◆ getCurrentPalette()

juce::ValueTree getCurrentPalette ( )

◆ getPaletteEntryNames()

juce::StringArray getPaletteEntryNames ( ) const

Returns all variables for selection in colour values.

◆ getStyleProperty()

juce::var getStyleProperty ( const juce::Identifier &  name,
const juce::ValueTree &  node,
bool  inherit = true,
juce::ValueTree *  definedHere = nullptr 
) 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 Stylesheet::getLookAndFeel(), and StylePropertyComponent::lookupValue().

◆ getLookAndFeel()

juce::LookAndFeel * getLookAndFeel ( const juce::ValueTree &  node) const

Return the LookAndFeel for the node.

Make sure never to remove a LookAndFeel, especially as long as the ComponentTree is still referencing any of them.

Parameters
nodeis the node in the GUI DOM

References Stylesheet::getStyleProperty().

◆ getBackgroundImage()

juce::Image getBackgroundImage ( const juce::ValueTree &  node) const

Finds a background image for the given node.

Note that this will only return anything useful, if you have added any actual images into the BinaryData and have enabled the FOLEYS_ENABLE_BINARY_DATA setting in the module page.

Parameters
nodeis the node in the GUI DOM

◆ parseColour()

juce::Colour parseColour ( const juce::String &  name)
static

This is a slightly more intelligent colour lookup than the JUCE one, as it allows to use colour names, as well as 6 digit colour tuples (JUCE will use red as alpha in that case)

Parameters
namea string representing the colour, can be an actual name or a RGB tuple or ARGB tuple.

Referenced by RootItem::updateColours().

◆ getColour()

juce::Colour getColour ( const juce::String &  name) const

Lookup a colour.

This will go through the colourPalette to catch variables like $text.

Referenced by GradientBackground::setup().

◆ getCurrentStyle()

juce::ValueTree getCurrentStyle ( ) const

◆ addNewStyleClass()

juce::ValueTree addNewStyleClass ( const juce::String &  name,
juce::UndoManager *  undo 
)

Add a new style class node, so elements of your GUI can inherit that class.

Parameters
nameis the name of the new class. Make sure you only use XML conform identifiers, i.e. characters, numbers but not starting with a number, dash and underscore only.
undothe UndoManager to track the action

◆ deleteStyleClass()

void deleteStyleClass ( const juce::String &  name,
juce::UndoManager *  undo 
)

Delete a style class.

This will not delete references to the class.

Parameters
namethe name of the class to be deleted.
undothe UndoManager to track the action

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

Parameters
namethe name the LookAndFeel can be referenced in the GUI editor
lookAndFeelis an actual LookAndFeel instance, that is owned by the Stylesheet

Referenced by MagicGUIBuilder::registerJUCELookAndFeels().

◆ getAllClassesNames()

juce::StringArray getAllClassesNames ( ) const

◆ getLookAndFeelNames()

juce::StringArray getLookAndFeelNames ( ) const

◆ isClassNode()

bool isClassNode ( const juce::ValueTree &  node) const

◆ isTypeNode()

bool isTypeNode ( const juce::ValueTree &  node) const

◆ isIdNode()

bool isIdNode ( const juce::ValueTree &  node) const

◆ isColourPaletteNode()

bool isColourPaletteNode ( const juce::ValueTree &  node) const

◆ addListener()

void addListener ( juce::ValueTree::Listener *  listener)

Referenced by GuiItem::GuiItem().

◆ removeListener()

void removeListener ( juce::ValueTree::Listener *  listener)

Referenced by GuiItem::~GuiItem().


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