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... | |
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.
Stylesheet | ( | MagicGUIBuilder & | builder | ) |
References Stylesheet::setColourPalette().
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().
bool setMediaSize | ( | int | width, |
int | height | ||
) |
Set the size of the UI.
This will be used to resolve the properties from the style classes.
width | is the width of the UI |
height | is the height of the UI |
Referenced by MagicGUIBuilder::updateLayout().
void updateValidRanges | ( | ) |
Reads the range, in which the properties won't change due to conditional classes.
Referenced by MagicGUIBuilder::updateLayout().
void updateStyleClasses | ( | ) |
Read the style classes and connect variables.
builder | is the managed builder instance, so the style class can connect to the variables |
void setColourPalette | ( | ) |
Updates the colourPalette.
References MagicGUIBuilder::getUndoManager().
Referenced by Stylesheet::setStyle(), and Stylesheet::Stylesheet().
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.
name | the name of the property. |
node | is the node in the DOM. This is used for inheritance by traversing upwards. |
Referenced by Stylesheet::getLookAndFeel(), and StylePropertyComponent::lookupValue().
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.
node | is the node in the GUI DOM |
References Stylesheet::getStyleProperty().
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.
node | is the node in the GUI DOM |
|
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)
name | a string representing the colour, can be an actual name or a RGB tuple or ARGB tuple. |
Referenced by RootItem::updateColours().
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().
juce::ValueTree getCurrentStyle | ( | ) | const |
Referenced by ToolBox::stateWasReloaded().
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.
name | is 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. |
undo | the UndoManager to track the action |
void deleteStyleClass | ( | const juce::String & | name, |
juce::UndoManager * | undo | ||
) |
Delete a style class.
This will not delete references to the class.
name | the name of the class to be deleted. |
undo | the UndoManager to track the action |
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.
name | the name the LookAndFeel can be referenced in the GUI editor |
lookAndFeel | is an actual LookAndFeel instance, that is owned by the Stylesheet |
Referenced by MagicGUIBuilder::registerJUCELookAndFeels().
juce::StringArray getAllClassesNames | ( | ) | const |
juce::StringArray getLookAndFeelNames | ( | ) | const |
Referenced by PropertiesEditor::addDecoratorProperties().
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 | ) |
Referenced by GuiItem::GuiItem().
void removeListener | ( | juce::ValueTree::Listener * | listener | ) |
Referenced by GuiItem::~GuiItem().