From 40d021eec2bbdf39fcf5c31e5303bf4cd0169692 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Fri, 7 Jul 2023 00:28:53 +0200 Subject: [PATCH] Added update when something in the Stylesheet changes --- Layout/foleys_RootItem.cpp | 3 +++ Layout/foleys_Stylesheet.cpp | 16 ++++++++++++++-- Layout/foleys_Stylesheet.h | 1 + VERSION.md | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Layout/foleys_RootItem.cpp b/Layout/foleys_RootItem.cpp index 2c163567..b64db1e6 100644 --- a/Layout/foleys_RootItem.cpp +++ b/Layout/foleys_RootItem.cpp @@ -56,6 +56,9 @@ void RootItem::updateColours() auto outline = magicBuilder.getStyleProperty (IDs::tooltipOutline, configNode); if (! outline.isVoid()) tooltip.getLookAndFeel().setColour (juce::TooltipWindow::outlineColourId, Stylesheet::parseColour (outline)); + + for (const auto& child : *this) + child->updateColours(); } diff --git a/Layout/foleys_Stylesheet.cpp b/Layout/foleys_Stylesheet.cpp index 27c5560f..a767d556 100644 --- a/Layout/foleys_Stylesheet.cpp +++ b/Layout/foleys_Stylesheet.cpp @@ -42,6 +42,15 @@ namespace foleys Stylesheet::Stylesheet (MagicGUIBuilder& builderToUse) : builder (builderToUse) { setColourPalette(); + + currentStyle.addListener(this); + currentPalette.addListener(this); +} + +Stylesheet::~Stylesheet() +{ + currentStyle.removeListener(this); + currentPalette.removeListener(this); } void Stylesheet::setStyle (const juce::ValueTree& node) @@ -99,9 +108,12 @@ juce::ValueTree Stylesheet::getCurrentPalette() return currentPalette; } -void Stylesheet::valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) +void Stylesheet::valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier& name) { - builder.updateColours(); + if (name.toString().contains("color")) + builder.updateColours(); + else + builder.updateComponents(); } void Stylesheet::updateValidRanges() diff --git a/Layout/foleys_Stylesheet.h b/Layout/foleys_Stylesheet.h index 51ac18a4..31fd56b4 100644 --- a/Layout/foleys_Stylesheet.h +++ b/Layout/foleys_Stylesheet.h @@ -53,6 +53,7 @@ class Stylesheet : private juce::ValueTree::Listener public: Stylesheet (MagicGUIBuilder& builder); + ~Stylesheet() override; /** The Stylesheet node in the XML can contain several Styles to select from. diff --git a/VERSION.md b/VERSION.md index 2d1aa648..d35b6c84 100644 --- a/VERSION.md +++ b/VERSION.md @@ -14,6 +14,7 @@ PluginGuiMagic - Versions history - Allow setting of Tab-Bar height - Add a property "tab-selected" to connect to a property in the state - Avoid update feedback loop in RadioButtonManager +- Added update when something in the Stylesheet changes 1.3.8 - 31.10.2022 ------------------