Skip to content

Commit

Permalink
add colour selection group to editor state
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jul 28, 2024
1 parent 95c90db commit 28299db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Source/LumatoneEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -59,6 +61,7 @@ LumatoneEditorState::LumatoneEditorState(juce::ValueTree stateIn, LumatoneFirmwa
loadPropertiesFile(nullptr);

colourPalettes = std::make_shared<juce::Array<LumatoneEditorColourPalette>>();
colourSelectionGroup = std::make_shared<ColourSelectionGroup>("LumatoneEditorAppColourGroup");
}

LumatoneEditorState::LumatoneEditorState(juce::String name, const LumatoneEditorState &stateIn)
Expand All @@ -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");
}
Expand All @@ -85,6 +89,8 @@ LumatoneEditorState::~LumatoneEditorState()
if (name == LumatoneEditorProperty::StateTree.toString())
DBG(state.toXmlString());

colourSelectionGroup = nullptr;

recentFiles = nullptr;
propertiesFile = nullptr;
lookAndFeel = nullptr;
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions Source/LumatoneEditorState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -126,6 +130,15 @@ class LumatoneEditorState : public LumatoneApplicationState
juce::File getLastOpenedMappingsDirectory() const;


private:
std::shared_ptr<ColourSelectionGroup> colourSelectionGroup;
public:
void addColourSelectionBroadcaster(ColourSelectionBroadcaster* broadcasterIn);
void removeColourSelectionBroadcaster(ColourSelectionBroadcaster* broadcasterIn);

void addColourSelectionListener(ColourSelectionListener* listenerIn);
void removeColourSelectionListener(ColourSelectionListener* listenerIn);

public:
bool doSendChangesToDevice() const override;

Expand Down

0 comments on commit 28299db

Please sign in to comment.