From 28299dbe89661af05ea584d42e798a6e742b47f9 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sun, 28 Jul 2024 16:14:41 -0400 Subject: [PATCH] add colour selection group to editor state --- Source/LumatoneEditorState.cpp | 26 ++++++++++++++++++++++++++ Source/LumatoneEditorState.h | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Source/LumatoneEditorState.cpp b/Source/LumatoneEditorState.cpp index 164d717..a729994 100644 --- a/Source/LumatoneEditorState.cpp +++ b/Source/LumatoneEditorState.cpp @@ -15,6 +15,8 @@ #include "./lumatone_editor_library/device/lumatone_controller.h" #include "./lumatone_editor_library/listeners/editor_listener.h" +#include "./lumatone_editor_library/palettes/colour_selection_group.h" + static juce::File getDefaultUserDocumentsDirectory() { @@ -59,6 +61,7 @@ LumatoneEditorState::LumatoneEditorState(juce::ValueTree stateIn, LumatoneFirmwa loadPropertiesFile(nullptr); colourPalettes = std::make_shared>(); + colourSelectionGroup = std::make_shared("LumatoneEditorAppColourGroup"); } LumatoneEditorState::LumatoneEditorState(juce::String name, const LumatoneEditorState &stateIn) @@ -70,6 +73,7 @@ LumatoneEditorState::LumatoneEditorState(juce::String name, const LumatoneEditor , recentFiles(stateIn.recentFiles) , propertiesFile(stateIn.propertiesFile) , colourPalettes(stateIn.colourPalettes) + , colourSelectionGroup(stateIn.colourSelectionGroup) { // DBG(name + " LumatoneEditorState created"); } @@ -85,6 +89,8 @@ LumatoneEditorState::~LumatoneEditorState() if (name == LumatoneEditorProperty::StateTree.toString()) DBG(state.toXmlString()); + colourSelectionGroup = nullptr; + recentFiles = nullptr; propertiesFile = nullptr; lookAndFeel = nullptr; @@ -195,6 +201,26 @@ void LumatoneEditorState::setHasChangesToSave(bool hasChangesToSaveIn) setStateProperty(LumatoneEditorProperty::HasChangesToSave, hasChangesToSave); } +void LumatoneEditorState::addColourSelectionBroadcaster(ColourSelectionBroadcaster *broadcasterIn) +{ + colourSelectionGroup->addSelector(broadcasterIn); +} + +void LumatoneEditorState::removeColourSelectionBroadcaster(ColourSelectionBroadcaster *broadcasterIn) +{ + colourSelectionGroup->removeSelector(broadcasterIn); +} + +void LumatoneEditorState::addColourSelectionListener(ColourSelectionListener *listenerIn) +{ + colourSelectionGroup->addColourSelectionListener(listenerIn); +} + +void LumatoneEditorState::removeColourSelectionListener(ColourSelectionListener *listenerIn) +{ + colourSelectionGroup->removeColourSelectionListener(listenerIn); +} + bool LumatoneEditorState::doSendChangesToDevice() const { return LumatoneApplicationState::doSendChangesToDevice() && editorMode == EditorMode::ONLINE; diff --git a/Source/LumatoneEditorState.h b/Source/LumatoneEditorState.h index b0fc523..e7f4b28 100644 --- a/Source/LumatoneEditorState.h +++ b/Source/LumatoneEditorState.h @@ -24,6 +24,10 @@ class LumatoneEditorLookAndFeel; class LumatoneController; class LumatoneEditorColourPalette; +class ColourSelectionBroadcaster; +class ColourSelectionListener; +class ColourSelectionGroup; + namespace LumatoneEditorProperty { static const juce::Identifier StateTree = juce::Identifier("LumatoneEditorState"); @@ -126,6 +130,15 @@ class LumatoneEditorState : public LumatoneApplicationState juce::File getLastOpenedMappingsDirectory() const; +private: + std::shared_ptr colourSelectionGroup; +public: + void addColourSelectionBroadcaster(ColourSelectionBroadcaster* broadcasterIn); + void removeColourSelectionBroadcaster(ColourSelectionBroadcaster* broadcasterIn); + + void addColourSelectionListener(ColourSelectionListener* listenerIn); + void removeColourSelectionListener(ColourSelectionListener* listenerIn); + public: bool doSendChangesToDevice() const override;