From 1476ef7f794435b27e4816b2e2c09764b62e6bec Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sun, 21 Mar 2021 00:19:14 +0100 Subject: [PATCH 1/9] Added timestamp to version --- VERSION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.md b/VERSION.md index a7dc3715..3f1d2b35 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,8 +1,8 @@ PluginGuiMagic - Versions history ================================ -1.3.1 ------ +1.3.1 - 21.03.2021 +------------------ - Added options to specify position and size relative or absolute to the parent component - Allow the selected component in a Contents to be draggable From 22866b7b104d7c1903e75d4ec5043946ad4af1fd Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Mon, 22 Mar 2021 12:05:49 +0100 Subject: [PATCH 2/9] Removed deprecated methods and declutter --- Editor/foleys_ToolBox.cpp | 1 + General/foleys_MagicGUIBuilder.h | 2 +- General/foleys_MagicPluginEditor.cpp | 45 ++++++---------------------- General/foleys_MagicPluginEditor.h | 26 ++-------------- VERSION.md | 3 ++ foleys_gui_magic.h | 2 +- 6 files changed, 18 insertions(+), 61 deletions(-) diff --git a/Editor/foleys_ToolBox.cpp b/Editor/foleys_ToolBox.cpp index a3110c59..e877010a 100644 --- a/Editor/foleys_ToolBox.cpp +++ b/Editor/foleys_ToolBox.cpp @@ -226,6 +226,7 @@ void ToolBox::stateWasReloaded() treeEditor.updateTree(); propertiesEditor.setStyle (builder.getStylesheet().getCurrentStyle()); palette.update(); + builder.updateComponents(); } void ToolBox::paint (juce::Graphics& g) diff --git a/General/foleys_MagicGUIBuilder.h b/General/foleys_MagicGUIBuilder.h index 91d66021..b78f0e99 100644 --- a/General/foleys_MagicGUIBuilder.h +++ b/General/foleys_MagicGUIBuilder.h @@ -93,7 +93,7 @@ class MagicGUIBuilder : public juce::ChangeListener void updateStylesheet(); /** - Recreates all components from the
tree. + Recreates all components from the tree. If no div tree is found, createDefaultGUITree is called to give subclasses a chance to create a suitable default. */ diff --git a/General/foleys_MagicPluginEditor.cpp b/General/foleys_MagicPluginEditor.cpp index 4aa39aca..b2a129fa 100644 --- a/General/foleys_MagicPluginEditor.cpp +++ b/General/foleys_MagicPluginEditor.cpp @@ -43,40 +43,22 @@ MagicPluginEditor::MagicPluginEditor (MagicProcessorState& stateToUse, std::uniq : juce::AudioProcessorEditor (*stateToUse.getProcessor()), processorState (stateToUse), builder (std::move (builderToUse)) -{ - initialise(); -} - -MagicPluginEditor::MagicPluginEditor (MagicProcessorState& stateToUse, const char* data, const int dataSize, std::unique_ptr builderToUse) - : juce::AudioProcessorEditor (*stateToUse.getProcessor()), - processorState (stateToUse), - builder (std::move (builderToUse)) -{ - initialise (data, dataSize); -} - -MagicPluginEditor::~MagicPluginEditor() -{ -#if JUCE_MODULE_AVAILABLE_juce_opengl && FOLEYS_ENABLE_OPEN_GL_CONTEXT - oglContext.detach(); -#endif -} - -void MagicPluginEditor::initialise (const char* data, int dataSize) { #if JUCE_MODULE_AVAILABLE_juce_opengl && FOLEYS_ENABLE_OPEN_GL_CONTEXT oglContext.attachTo (*this); #endif if (builder.get() == nullptr) - builder = createBuilderInstance(); + { + builder = std::make_unique(processorState); + builder->registerJUCEFactories(); + builder->registerJUCELookAndFeels(); + } #if FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE auto guiTree = processorState.getValueTree().getChildWithName ("magic"); if (guiTree.isValid()) setConfigTree (guiTree); - else if (data != nullptr) - setConfigTree (data, dataSize); else builder->createGUI (*this); #else // FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE @@ -93,13 +75,11 @@ void MagicPluginEditor::initialise (const char* data, int dataSize) #endif } -std::unique_ptr MagicPluginEditor::createBuilderInstance() +MagicPluginEditor::~MagicPluginEditor() { - auto newBuilder = std::make_unique(processorState); - newBuilder->registerJUCEFactories(); - newBuilder->registerJUCELookAndFeels(); - - return newBuilder; +#if JUCE_MODULE_AVAILABLE_juce_opengl && FOLEYS_ENABLE_OPEN_GL_CONTEXT + oglContext.detach(); +#endif } void MagicPluginEditor::updateSize() @@ -146,13 +126,6 @@ void MagicPluginEditor::setConfigTree (const juce::ValueTree& gui) updateSize(); } -void MagicPluginEditor::setConfigTree (const char* data, int dataSize) -{ - juce::String text (data, size_t (dataSize)); - auto gui = juce::ValueTree::fromXml (text); - setConfigTree (gui); -} - MagicGUIBuilder& MagicPluginEditor::getGUIBuilder() { // This shouldn't be possible, since the builder instance is created if none was supplied... diff --git a/General/foleys_MagicPluginEditor.h b/General/foleys_MagicPluginEditor.h index c8ec1220..8d3dfd0a 100644 --- a/General/foleys_MagicPluginEditor.h +++ b/General/foleys_MagicPluginEditor.h @@ -53,9 +53,6 @@ class MagicPluginEditor : public juce::AudioProcessorEditor, */ MagicPluginEditor (MagicProcessorState& processorState, std::unique_ptr builder = {}); - [[deprecated ("MagicPluginEditor will get the state from the processorState. Call processorState.setGuiValueTree() beforehand.")]] - MagicPluginEditor (MagicProcessorState& processorState, const char* data, const int dataSize, std::unique_ptr builder = {}); - ~MagicPluginEditor() override; /** @@ -65,23 +62,6 @@ class MagicPluginEditor : public juce::AudioProcessorEditor, */ void setConfigTree (const juce::ValueTree& gui); - /** - Setup a GUI from a previously stored ValueTree. This is the - usual way to deploy your finished GUI via the Projucer: - - @code{.cpp} - AudioProcessorEditor* MyAudioProcessor::createEditor() - { - auto* editor = new foleys::MagicPluginEditor (magicState, BinaryData::magic_xml, BinaryData::magic_xmlSize); - return editor; - } - @endcode - - @param data points to the binary data of the XML file - @param dataSize the number of bytes - */ - void setConfigTree (const char* data, int dataSize); - /** Grants access to the MagicGUIBuilder */ @@ -92,10 +72,10 @@ class MagicPluginEditor : public juce::AudioProcessorEditor, void resized() override; private: - void initialise (const char* data = nullptr, int dataSize = 0); - - std::unique_ptr createBuilderInstance(); + /** + Setup the size and resizable and size limits + */ void updateSize(); #if JUCE_MODULE_AVAILABLE_juce_opengl && FOLEYS_ENABLE_OPEN_GL_CONTEXT diff --git a/VERSION.md b/VERSION.md index 3f1d2b35..93b90e68 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,6 +1,9 @@ PluginGuiMagic - Versions history ================================ +1.3.2 +----- + 1.3.1 - 21.03.2021 ------------------ diff --git a/foleys_gui_magic.h b/foleys_gui_magic.h index e4c6d4f1..abc42a56 100644 --- a/foleys_gui_magic.h +++ b/foleys_gui_magic.h @@ -37,7 +37,7 @@ ID: foleys_gui_magic vendor: Foleys Finest Audio - version: 1.3.1 + version: 1.3.2 name: Foleys GUI magic description: This module allows to create GUI with a drag and drop editor dependencies: juce_core, juce_audio_basics, juce_audio_devices, juce_audio_formats, From ca1c994b00ad3e3143542e0510d931ca0b39de67 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sat, 27 Mar 2021 23:39:19 +0100 Subject: [PATCH 3/9] Fixed dragging and edit mode --- Layout/foleys_GuiItem.cpp | 18 +++++++++++++----- Layout/foleys_GuiItem.h | 4 ++-- VERSION.md | 3 +++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Layout/foleys_GuiItem.cpp b/Layout/foleys_GuiItem.cpp index 2f4fc9f0..1dcbce76 100644 --- a/Layout/foleys_GuiItem.cpp +++ b/Layout/foleys_GuiItem.cpp @@ -97,6 +97,10 @@ void GuiItem::updateInternal() update(); +#if FOLEYS_SHOW_GUI_EDITOR_PALLETTE + setEditMode (magicBuilder.isEditModeOn()); +#endif + repaint(); } @@ -374,10 +378,13 @@ void GuiItem::setEditMode (bool shouldEdit) void GuiItem::setDraggable (bool selected) { - if (selected && getParentsLayoutType() == LayoutType::Contents) + if (selected && + getParentsLayoutType() == LayoutType::Contents && + configNode != magicBuilder.getGuiRootNode()) { toFront (false); borderDragger = std::make_unique(this, nullptr); + componentDragger = std::make_unique(); borderDragger->onDragStart = [&] { @@ -398,6 +405,7 @@ void GuiItem::setDraggable (bool selected) else { borderDragger.reset(); + componentDragger.reset(); } } @@ -426,18 +434,18 @@ void GuiItem::mouseDown (const juce::MouseEvent& event) { magicBuilder.setSelectedNode (configNode); - if (getParentsLayoutType() == LayoutType::Contents) + if (componentDragger) { magicBuilder.getUndoManager().beginNewTransaction ("Drag component position"); - componentDragger.startDraggingComponent (this, event); + componentDragger->startDraggingComponent (this, event); } } void GuiItem::mouseDrag (const juce::MouseEvent& event) { - if (getParentsLayoutType() == LayoutType::Contents) + if (componentDragger) { - componentDragger.dragComponent (this, event, nullptr); + componentDragger->dragComponent (this, event, nullptr); savePosition(); } else if (event.mouseWasDraggedSinceMouseDown()) diff --git a/Layout/foleys_GuiItem.h b/Layout/foleys_GuiItem.h index a94c6d23..6991e2ea 100644 --- a/Layout/foleys_GuiItem.h +++ b/Layout/foleys_GuiItem.h @@ -223,8 +223,8 @@ class GuiItem : public juce::Component, private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BorderDragger) }; - std::unique_ptr borderDragger; - juce::ComponentDragger componentDragger; + std::unique_ptr borderDragger; + std::unique_ptr componentDragger; void valueChanged (juce::Value& source) override; diff --git a/VERSION.md b/VERSION.md index 93b90e68..2e1c9015 100644 --- a/VERSION.md +++ b/VERSION.md @@ -4,6 +4,9 @@ PluginGuiMagic - Versions history 1.3.2 ----- +- New components respect current edit mode +- Fixed accidently draggable components + 1.3.1 - 21.03.2021 ------------------ From 2a615b861ce7fb489b2869e7f9765be817b25ea1 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sun, 28 Mar 2021 00:47:20 +0100 Subject: [PATCH 4/9] Changed Analyser to use ballistics rather than rolling average --- Visualisers/foleys_MagicAnalyser.cpp | 28 ++++++++++++++++------------ Visualisers/foleys_MagicAnalyser.h | 3 +-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Visualisers/foleys_MagicAnalyser.cpp b/Visualisers/foleys_MagicAnalyser.cpp index 797c4c29..446beec5 100644 --- a/Visualisers/foleys_MagicAnalyser.cpp +++ b/Visualisers/foleys_MagicAnalyser.cpp @@ -126,8 +126,7 @@ void MagicAnalyser::AnalyserJob::setupAnalyser (int audioFifoSize) abstractFifo.setTotalSize (audioFifoSize); audioFifo.clear(); - averager.clear(); - averagerPtr = 1; + values.clear(); } void MagicAnalyser::AnalyserJob::pushSamples (const juce::AudioBuffer& buffer, int inChannel) @@ -180,16 +179,21 @@ int MagicAnalyser::AnalyserJob::useTimeSlice() { juce::ScopedLock lockedForWriting (owner.pathCreationLock); - auto factor = 1.0f / averager.getNumSamples(); - if (averager.getNumChannels() > 2) - factor = factor / (averager.getNumChannels() - 1.0f); + const auto factor = 1.0f / fft.getSize(); + const auto decay = 0.8f; // FIXME: calculate by fft size and sampleRate + const auto* read = fftBuffer.getReadPointer (0); + auto* write = values.getWritePointer (0); - averager.copyFrom (averagerPtr, 0, fftBuffer.getReadPointer (0), averager.getNumSamples(), factor); - if (++averagerPtr == averager.getNumChannels()) averagerPtr = 1; - - averager.copyFrom (0, 0, averager.getReadPointer (1), averager.getNumSamples()); - for (int i = 2; i < averager.getNumChannels(); ++i) - averager.addFrom (0, 0, averager.getReadPointer (i), averager.getNumSamples()); + for (int i=0; i < values.getNumSamples(); ++i, ++read, ++write) + { + auto v = *read * factor; + if (v >= *write) + *write = v; + else if (v < 1.12202e-05f) + *write = 0.0f; + else + *write = *write * decay; + } owner.resetLastDataFlag(); } @@ -199,7 +203,7 @@ int MagicAnalyser::AnalyserJob::useTimeSlice() const juce::AudioBuffer MagicAnalyser::AnalyserJob::getAnalyserData() const { - return averager; + return values; } diff --git a/Visualisers/foleys_MagicAnalyser.h b/Visualisers/foleys_MagicAnalyser.h index b8bcee9b..e9040a15 100644 --- a/Visualisers/foleys_MagicAnalyser.h +++ b/Visualisers/foleys_MagicAnalyser.h @@ -111,8 +111,7 @@ class MagicAnalyser : public MagicPlotSource juce::dsp::WindowingFunction windowing { size_t (fft.getSize()), juce::dsp::WindowingFunction::hann, true }; juce::AudioBuffer fftBuffer { 1, fft.getSize() * 2 }; - juce::AudioBuffer averager { 5, fft.getSize() / 2 }; - int averagerPtr = 1; + juce::AudioBuffer values { 1, fft.getSize() / 2 }; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnalyserJob) }; From 266739101ffa5924ca5674647990d016137ae999 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sun, 28 Mar 2021 23:28:48 +0200 Subject: [PATCH 5/9] Fixes for click-drag and gui setup --- General/foleys_MagicPluginEditor.cpp | 7 +++++-- Layout/foleys_GuiItem.cpp | 9 +++++++-- Layout/foleys_GuiItem.h | 1 + VERSION.md | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/General/foleys_MagicPluginEditor.cpp b/General/foleys_MagicPluginEditor.cpp index b2a129fa..bb94567c 100644 --- a/General/foleys_MagicPluginEditor.cpp +++ b/General/foleys_MagicPluginEditor.cpp @@ -63,6 +63,8 @@ MagicPluginEditor::MagicPluginEditor (MagicProcessorState& stateToUse, std::uniq builder->createGUI (*this); #else // FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE auto guiTree = processorState.getGuiTree(); + if (guiTree.isValid()) + setConfigTree (guiTree); #endif // FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE updateSize(); @@ -101,10 +103,11 @@ void MagicPluginEditor::updateSize() { processorState.getLastEditorSize (width, height); + auto maximalBounds = juce::Desktop::getInstance().getDisplays().getTotalBounds (true); int minWidth = rootNode.getProperty (IDs::minWidth, 10); int minHeight = rootNode.getProperty (IDs::minHeight, 10); - int maxWidth = rootNode.getProperty (IDs::maxWidth, std::numeric_limits::max()); - int maxHeight = rootNode.getProperty (IDs::maxHeight, std::numeric_limits::max()); + int maxWidth = rootNode.getProperty (IDs::maxWidth, maximalBounds.getWidth()); + int maxHeight = rootNode.getProperty (IDs::maxHeight, maximalBounds.getHeight()); setResizable (resizable, resizeCorner); setResizeLimits (minWidth, minHeight, maxWidth, maxHeight); } diff --git a/Layout/foleys_GuiItem.cpp b/Layout/foleys_GuiItem.cpp index 1dcbce76..2dae789b 100644 --- a/Layout/foleys_GuiItem.cpp +++ b/Layout/foleys_GuiItem.cpp @@ -432,8 +432,6 @@ void GuiItem::savePosition () void GuiItem::mouseDown (const juce::MouseEvent& event) { - magicBuilder.setSelectedNode (configNode); - if (componentDragger) { magicBuilder.getUndoManager().beginNewTransaction ("Drag component position"); @@ -454,6 +452,13 @@ void GuiItem::mouseDrag (const juce::MouseEvent& event) container->startDragging (IDs::dragSelected, this); } } + +void GuiItem::mouseUp (const juce::MouseEvent& event) +{ + if (! event.mouseWasDraggedSinceMouseDown()) + magicBuilder.setSelectedNode (configNode); +} + #endif bool GuiItem::isInterestedInDragSource (const juce::DragAndDropTarget::SourceDetails &) diff --git a/Layout/foleys_GuiItem.h b/Layout/foleys_GuiItem.h index 6991e2ea..38a7c306 100644 --- a/Layout/foleys_GuiItem.h +++ b/Layout/foleys_GuiItem.h @@ -176,6 +176,7 @@ class GuiItem : public juce::Component, void mouseDown (const juce::MouseEvent& event) override; void mouseDrag (const juce::MouseEvent& event) override; + void mouseUp (const juce::MouseEvent& event) override; #endif diff --git a/VERSION.md b/VERSION.md index 2e1c9015..1fcf4bdf 100644 --- a/VERSION.md +++ b/VERSION.md @@ -6,6 +6,9 @@ PluginGuiMagic - Versions history - New components respect current edit mode - 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 +- Changed Analyser to use ballistics rather than rolling average 1.3.1 - 21.03.2021 ------------------ From 05f408a5e2bb0d482321ad4991f02e6a1b197824 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Tue, 30 Mar 2021 12:29:34 +0200 Subject: [PATCH 6/9] Don't need BinaryData config switch any longer --- General/foleys_Resources.cpp | 19 ++++++++++--------- foleys_gui_magic.h | 8 -------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/General/foleys_Resources.cpp b/General/foleys_Resources.cpp index 60a85229..44d56353 100644 --- a/General/foleys_Resources.cpp +++ b/General/foleys_Resources.cpp @@ -35,11 +35,19 @@ */ +namespace BinaryDataFallbacks { +const int namedResourceListSize = 0; +const char* namedResourceList[]{}; +const char* getNamedResource(const char*, int&) { return nullptr; } +} // namespace BinaryDataFallbacks + +namespace BinaryData { +using namespace BinaryDataFallbacks; +} + namespace foleys { -#if FOLEYS_ENABLE_BINARY_DATA - juce::StringArray Resources::getResourceFileNames() { juce::StringArray names; @@ -60,11 +68,4 @@ juce::Image Resources::getImage (const juce::String& name) return {}; } -#else - -juce::StringArray Resources::getResourceFileNames() { return {}; } -juce::Image Resources::getImage (const juce::String&) { return {}; } - -#endif - } diff --git a/foleys_gui_magic.h b/foleys_gui_magic.h index abc42a56..727ba6e1 100644 --- a/foleys_gui_magic.h +++ b/foleys_gui_magic.h @@ -69,14 +69,6 @@ #define FOLEYS_SAVE_EDITED_GUI_IN_PLUGIN_STATE 1 #endif -/** Config: FOLEYS_ENABLE_BINARY_DATA - Makes the binary resources available to the GUI. Make sure you actually have - at least one file added, or this will fail to compile. - */ -#ifndef FOLEYS_ENABLE_BINARY_DATA -#define FOLEYS_ENABLE_BINARY_DATA 0 -#endif - /** Config: FOLEYS_ENABLE_OPEN_GL_CONTEXT If selected an juce OpenGLCOntext is attached. Not a big difference on OSX, but vital on Windows. */ From 1d0302544f2cc5b311b326e8df4d97e7d687837c Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Tue, 30 Mar 2021 12:30:42 +0200 Subject: [PATCH 7/9] Fixed CSS class creation without load/save workaround --- Editor/foleys_PropertiesEditor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Editor/foleys_PropertiesEditor.cpp b/Editor/foleys_PropertiesEditor.cpp index b81078e5..a151828c 100644 --- a/Editor/foleys_PropertiesEditor.cpp +++ b/Editor/foleys_PropertiesEditor.cpp @@ -179,7 +179,10 @@ void PropertiesEditor::createNewClass() if (auto* editor = dlg.getTextEditor (editorID)) { auto name = editor->getText().replaceCharacters (".&$@ ", "---__"); - builder.getStylesheet().addNewStyleClass (name, &undo); + auto newNode = builder.getStylesheet().addNewStyleClass (name, &undo); + auto index = newNode.getParent().indexOf (newNode); + updatePopupMenu(); + nodeSelect.setSelectedId (3000 + index); } } @@ -188,6 +191,7 @@ void PropertiesEditor::deleteClass (const juce::String& name) auto& stylesheet = builder.getStylesheet(); stylesheet.deleteStyleClass (name, &undo); builder.removeStyleClassReferences (builder.getGuiRootNode(), name); + updatePopupMenu(); } //============================================================================== From d0eeec752029a310c83a49e5cba5aa68902b26fb Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Tue, 30 Mar 2021 14:07:26 +0200 Subject: [PATCH 8/9] Fixed class creation and update when a property changes --- Layout/foleys_GuiItem.cpp | 17 +++++++++++++++++ Layout/foleys_GuiItem.h | 1 + Layout/foleys_Stylesheet.cpp | 10 ++++++++++ Layout/foleys_Stylesheet.h | 3 +++ VERSION.md | 2 ++ 5 files changed, 33 insertions(+) diff --git a/Layout/foleys_GuiItem.cpp b/Layout/foleys_GuiItem.cpp index 2dae789b..e4ecbbe5 100644 --- a/Layout/foleys_GuiItem.cpp +++ b/Layout/foleys_GuiItem.cpp @@ -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> mapping) @@ -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(); } } diff --git a/Layout/foleys_GuiItem.h b/Layout/foleys_GuiItem.h index 38a7c306..6b3a576d 100644 --- a/Layout/foleys_GuiItem.h +++ b/Layout/foleys_GuiItem.h @@ -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! diff --git a/Layout/foleys_Stylesheet.cpp b/Layout/foleys_Stylesheet.cpp index fdf08386..7984d494 100644 --- a/Layout/foleys_Stylesheet.cpp +++ b/Layout/foleys_Stylesheet.cpp @@ -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) diff --git a/Layout/foleys_Stylesheet.h b/Layout/foleys_Stylesheet.h index 6f3a00c3..64275e49 100644 --- a/Layout/foleys_Stylesheet.h +++ b/Layout/foleys_Stylesheet.h @@ -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; diff --git a/VERSION.md b/VERSION.md index 1fcf4bdf..7155d24b 100644 --- a/VERSION.md +++ b/VERSION.md @@ -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 From e9b4e2ba73583e93281fd2d353c7a7fd9461e313 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 30 Mar 2021 23:00:13 +0200 Subject: [PATCH 9/9] Fixed warnings on windows --- Editor/foleys_StyleColourPropertyComponent.cpp | 8 ++++---- Editor/foleys_StyleGradientPropertyComponent.cpp | 8 ++++---- Editor/foleys_ToolBox.cpp | 12 ++++++------ General/foleys_Resources.cpp | 2 +- Layout/foleys_Decorator.cpp | 2 +- Layout/foleys_GuiItem.cpp | 4 ++-- State/foleys_MagicProcessorState.cpp | 14 +++++++------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Editor/foleys_StyleColourPropertyComponent.cpp b/Editor/foleys_StyleColourPropertyComponent.cpp index f32d769f..05894481 100644 --- a/Editor/foleys_StyleColourPropertyComponent.cpp +++ b/Editor/foleys_StyleColourPropertyComponent.cpp @@ -254,9 +254,9 @@ juce::Colour StyleColourPropertyComponent::ColourPanel::ColourSelectorWithSwatch return swatchColours [size_t (index)]; } -void StyleColourPropertyComponent::ColourPanel::ColourSelectorWithSwatches::setSwatchColour (int index, const juce::Colour& colour) +void StyleColourPropertyComponent::ColourPanel::ColourSelectorWithSwatches::setSwatchColour (int index, const juce::Colour& newColour) { - swatchColours [size_t (index)] = colour; + swatchColours [size_t (index)] = newColour; } void StyleColourPropertyComponent::ColourPanel::ColourSelectorWithSwatches::loadSwatches() @@ -281,8 +281,8 @@ void StyleColourPropertyComponent::ColourPanel::ColourSelectorWithSwatches::save coloursNode->deleteAllChildElements(); for (int i = 0; i < int (swatchColours.size()); ++i) { - auto* node = coloursNode->createNewChildElement (IDs::colour); - node->addTextElement (swatchColours [size_t (i)].toDisplayString (true)); + auto* colourNode = coloursNode->createNewChildElement (IDs::colour); + colourNode->addTextElement (swatchColours [size_t (i)].toDisplayString (true)); } p->setValue (IDs::swatches, coloursNode.get()); diff --git a/Editor/foleys_StyleGradientPropertyComponent.cpp b/Editor/foleys_StyleGradientPropertyComponent.cpp index 93e860ba..4ff5b29a 100644 --- a/Editor/foleys_StyleGradientPropertyComponent.cpp +++ b/Editor/foleys_StyleGradientPropertyComponent.cpp @@ -240,9 +240,9 @@ juce::Colour StyleGradientPropertyComponent::GradientPanel::ColourSelectorWithSw return swatchColours [size_t (index)]; } -void StyleGradientPropertyComponent::GradientPanel::ColourSelectorWithSwatches::setSwatchColour (int index, const juce::Colour& colour) +void StyleGradientPropertyComponent::GradientPanel::ColourSelectorWithSwatches::setSwatchColour (int index, const juce::Colour& newColour) { - swatchColours [size_t (index)] = colour; + swatchColours [size_t (index)] = newColour; } void StyleGradientPropertyComponent::GradientPanel::ColourSelectorWithSwatches::loadSwatches() @@ -267,8 +267,8 @@ void StyleGradientPropertyComponent::GradientPanel::ColourSelectorWithSwatches:: coloursNode->deleteAllChildElements(); for (int i = 0; i < int (swatchColours.size()); ++i) { - auto* node = coloursNode->createNewChildElement (IDs::colour); - node->addTextElement (swatchColours [size_t (i)].toDisplayString (true)); + auto* colourNode = coloursNode->createNewChildElement (IDs::colour); + colourNode->addTextElement (swatchColours [size_t (i)].toDisplayString (true)); } p->setValue (IDs::swatches, coloursNode.get()); diff --git a/Editor/foleys_ToolBox.cpp b/Editor/foleys_ToolBox.cpp index e877010a..945adbe8 100644 --- a/Editor/foleys_ToolBox.cpp +++ b/Editor/foleys_ToolBox.cpp @@ -362,9 +362,9 @@ juce::File ToolBox::getLastLocation() const { juce::File lastLocation; - juce::ApplicationProperties properties; - properties.setStorageParameters (ToolBox::getApplicationPropertyStorage()); - if (auto* p = properties.getUserSettings()) + juce::ApplicationProperties appProperties; + appProperties.setStorageParameters (ToolBox::getApplicationPropertyStorage()); + if (auto* p = appProperties.getUserSettings()) lastLocation = juce::File (p->getValue (IDs::lastLocation)); if (lastLocation.exists()) @@ -390,9 +390,9 @@ juce::File ToolBox::getLastLocation() const void ToolBox::setLastLocation(juce::File file) { - juce::ApplicationProperties properties; - properties.setStorageParameters (ToolBox::getApplicationPropertyStorage()); - if (auto* p = properties.getUserSettings()) + juce::ApplicationProperties appProperties; + appProperties.setStorageParameters (ToolBox::getApplicationPropertyStorage()); + if (auto* p = appProperties.getUserSettings()) p->setValue (IDs::lastLocation, file.getFullPathName()); } diff --git a/General/foleys_Resources.cpp b/General/foleys_Resources.cpp index 44d56353..c0e8d97e 100644 --- a/General/foleys_Resources.cpp +++ b/General/foleys_Resources.cpp @@ -37,7 +37,7 @@ namespace BinaryDataFallbacks { const int namedResourceListSize = 0; -const char* namedResourceList[]{}; +const char** namedResourceList = nullptr; const char* getNamedResource(const char*, int&) { return nullptr; } } // namespace BinaryDataFallbacks diff --git a/Layout/foleys_Decorator.cpp b/Layout/foleys_Decorator.cpp index ab9ab52b..c5ebf36b 100644 --- a/Layout/foleys_Decorator.cpp +++ b/Layout/foleys_Decorator.cpp @@ -135,7 +135,7 @@ Decorator::ClientBounds Decorator::getClientBounds (juce::Rectangle overall else { juce::Font f (captionSize * 0.8f); - auto w = f.getStringWidth (caption); + auto w = float (f.getStringWidth (caption)); if (justification.getOnlyHorizontalFlags() & juce::Justification::left) captionBox = box.removeFromLeft (w).toNearestInt(); diff --git a/Layout/foleys_GuiItem.cpp b/Layout/foleys_GuiItem.cpp index e4ecbbe5..6a1e53f3 100644 --- a/Layout/foleys_GuiItem.cpp +++ b/Layout/foleys_GuiItem.cpp @@ -91,8 +91,8 @@ void GuiItem::updateInternal() { auto& stylesheet = magicBuilder.getStylesheet(); - if (auto* lookAndFeel = stylesheet.getLookAndFeel (configNode)) - setLookAndFeel (lookAndFeel); + if (auto* newLookAndFeel = stylesheet.getLookAndFeel (configNode)) + setLookAndFeel (newLookAndFeel); decorator.configure (magicBuilder, configNode); configureComponent(); diff --git a/State/foleys_MagicProcessorState.cpp b/State/foleys_MagicProcessorState.cpp index e4ac4de3..869a9a8e 100644 --- a/State/foleys_MagicProcessorState.cpp +++ b/State/foleys_MagicProcessorState.cpp @@ -142,11 +142,11 @@ bool MagicProcessorState::getLastEditorSize (int& width, int& height) void MagicProcessorState::getStateInformation (juce::MemoryBlock& destData) { - auto state = getValueTree(); - parameters.saveParameterValues (state); + auto newState = getValueTree(); + parameters.saveParameterValues (newState); juce::MemoryOutputStream stream (destData, false); - state.writeToStream (stream); + newState.writeToStream (stream); } void MagicProcessorState::setStateInformation (const void* data, int sizeInBytes, juce::AudioProcessorEditor* editor) @@ -155,13 +155,13 @@ void MagicProcessorState::setStateInformation (const void* data, int sizeInBytes if (tree.isValid() == false) return; - auto state = getValueTree(); - if (state.getType() != tree.getType()) + auto newState = getValueTree(); + if (newState.getType() != tree.getType()) return; - state.copyPropertiesAndChildrenFrom (tree, nullptr); + newState.copyPropertiesAndChildrenFrom (tree, nullptr); - parameters.loadParameterValues (state); + parameters.loadParameterValues (newState); if (editor) {