Skip to content

Commit

Permalink
Fixed class creation and update when a property changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ffAudio committed Mar 30, 2021
1 parent 1d03025 commit d0eeec7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Layout/foleys_GuiItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ GuiItem::GuiItem (MagicGUIBuilder& builder, juce::ValueTree node)

visibility.addListener (this);
configNode.addListener (this);
magicBuilder.getStylesheet().addListener (this);
}

GuiItem::~GuiItem()
{
magicBuilder.getStylesheet().removeListener (this);
}

void GuiItem::setColourTranslation (std::vector<std::pair<juce::String, int>> mapping)
Expand Down Expand Up @@ -289,6 +295,17 @@ void GuiItem::valueTreePropertyChanged (juce::ValueTree& treeThatChanged, const
parent->updateInternal();
else
updateInternal();

return;
}

auto& stylesheet = magicBuilder.getStylesheet();
if (stylesheet.isClassNode (treeThatChanged))
{
auto name = treeThatChanged.getType().toString();
auto classes = configNode.getProperty (IDs::styleClass, juce::String()).toString();
if (classes.contains (name))
updateInternal();
}
}

Expand Down
1 change: 1 addition & 0 deletions Layout/foleys_GuiItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class GuiItem : public juce::Component,
{
public:
GuiItem (MagicGUIBuilder& builder, juce::ValueTree node);
~GuiItem() override;

/**
Allows accessing the Component inside that GuiItem. Don't keep this pointer!
Expand Down
10 changes: 10 additions & 0 deletions Layout/foleys_Stylesheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ juce::StringArray Stylesheet::getAllClassesNames() const
return names;
}

void Stylesheet::addListener (juce::ValueTree::Listener* listener)
{
currentStyle.addListener (listener);
}

void Stylesheet::removeListener (juce::ValueTree::Listener* listener)
{
currentStyle.removeListener (listener);
}

//==============================================================================

Stylesheet::StyleClass::StyleClass (juce::ValueTree style)
Expand Down
3 changes: 3 additions & 0 deletions Layout/foleys_Stylesheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class Stylesheet : private juce::ValueTree::Listener
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);

private:
void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override;

Expand Down
2 changes: 2 additions & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PluginGuiMagic - Versions history
- Fixed accidently draggable components
- Allow dragging of groups (instead of selecting the child)
- Fixed setup when FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE is off
- Don't need BinaryData config switch any longer
- Fixed creation of CSS classes and update when a property there changes
- Changed Analyser to use ballistics rather than rolling average

1.3.1 - 21.03.2021
Expand Down

0 comments on commit d0eeec7

Please sign in to comment.