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) | |
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().
|
override |
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().
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(), and MagicGUIBuilder::updateStylesheet().
void updateStyleClasses | ( | ) |
Read the style classes and connect variables.
References MagicGUIBuilder::getMagicState(), and MagicGUIState::getPropertyAsValue().
Referenced by MagicGUIBuilder::updateStylesheet().
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 ) |
References MagicGUIBuilder::getUndoManager().
Referenced by PropertiesEditor::PropertiesEditor().
juce::ValueTree getCurrentPalette | ( | ) |
juce::StringArray getPaletteEntryNames | ( | ) | const |
Returns all variables for selection in colour values.
Referenced by StyleColourPropertyComponent::StyleColourPropertyComponent().
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. |
inherit | if this is true, it will impact child nodes as well |
definedHere | this 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().
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().
Referenced by StyleColourPropertyComponent::StyleColourPropertyComponent().
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 |
References Stylesheet::getStyleProperty().
|
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 Stylesheet::getColour(), and RootItem::updateColours().
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().
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 |
Referenced by PropertiesEditor::deleteClass().
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(), and MagicGUIBuilder::registerLookAndFeel().
juce::StringArray getAllClassesNames | ( | ) | const |
Referenced by PropertiesEditor::addNodeProperties().
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().