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

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

#include <foleys_Stylesheet.h>

Inherits Listener.

Public Member Functions

 Stylesheet (MagicGUIBuilder &builder)
 
 ~Stylesheet () override
 
void setStyle (const juce::ValueTree &node)
 The Stylesheet node in the XML can contain several Styles to select from.
 
bool setMediaSize (int width, int height)
 Set the size of the UI.
 
void updateValidRanges ()
 Reads the range, in which the properties won't change due to conditional classes.
 
void updateStyleClasses ()
 Read the style classes and connect variables.
 
void setColourPalette ()
 Updates the colourPalette.
 
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.
 
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.
 
juce::LookAndFeel * getLookAndFeel (const juce::ValueTree &node) const
 Return the LookAndFeel for the node.
 
juce::Image getBackgroundImage (const juce::ValueTree &node) const
 Finds a background image for the given node.
 
juce::Colour getColour (const juce::String &name) const
 Lookup a colour.
 
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.
 
void deleteStyleClass (const juce::String &name, juce::UndoManager *undo)
 Delete a style class.
 
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.
 
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)
 

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

~Stylesheet ( )
override

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

Referenced by MagicGUIBuilder::updateStylesheet().

◆ 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(), and MagicGUIBuilder::updateStylesheet().

◆ updateStyleClasses()

void updateStyleClasses ( )

Read the style classes and connect variables.

References MagicGUIBuilder::getMagicState(), and MagicGUIState::getPropertyAsValue().

Referenced by MagicGUIBuilder::updateStylesheet().

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

Referenced by StyleColourPropertyComponent::StyleColourPropertyComponent().

◆ 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.
inheritif this is true, it will impact child nodes as well
definedHerethis is a hint for the editor where the property was actually set

References MagicGUIBuilder::getPropertyDefaultValue(), and Stylesheet::getStyleProperty().

Referenced by Stylesheet::getBackgroundImage(), Stylesheet::getLookAndFeel(), MagicGUIBuilder::getStyleProperty(), Stylesheet::getStyleProperty(), 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().

Referenced by StyleColourPropertyComponent::StyleColourPropertyComponent().

◆ 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

References Stylesheet::getStyleProperty().

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

References Stylesheet::parseColour().

Referenced by GradientBackground::setup(), StyleColourPropertyComponent::StyleColourPropertyComponent(), and GuiItem::updateColours().

◆ 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

Referenced by PropertiesEditor::deleteClass().

◆ 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(), and MagicGUIBuilder::registerLookAndFeel().

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