From 3f791472185f61eee90b3286e355f6f701d649c4 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sat, 13 Jan 2024 17:51:36 -0500 Subject: [PATCH] improve some state value recalls, add fallback value --- Source/GlobalSettingsArea.cpp | 11 +++++------ Source/GlobalSettingsArea.h | 4 ++-- Source/LumatoneEditorState.cpp | 4 ++-- Source/LumatoneEditorState.h | 2 +- Source/NoteEditArea.cpp | 2 +- Source/Settings/SettingsContainer.cpp | 2 +- Source/SingleNoteAssign.cpp | 8 ++++---- .../listeners/firmware_listener.h | 2 ++ 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Source/GlobalSettingsArea.cpp b/Source/GlobalSettingsArea.cpp index 47914297..3bb0a76b 100644 --- a/Source/GlobalSettingsArea.cpp +++ b/Source/GlobalSettingsArea.cpp @@ -245,13 +245,10 @@ void GlobalSettingsArea::changeListenerCallback(ChangeBroadcaster *source) } } -void GlobalSettingsArea::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) +void GlobalSettingsArea::restoreStateFromPropertiesFile() { - inactiveMacroButtonColourEdit->setColour( - propertiesFile->getValue(LumatoneEditorProperty::InactiveMacroButtonColour, "000000")); - - activeMacroButtonColourEdit->setColour( - propertiesFile->getValue(LumatoneEditorProperty::ActiveMacroButtonColour, "FFFFFF")); + inactiveMacroButtonColourEdit->setColour(getProperty(LumatoneEditorProperty::InactiveMacroButtonColour, "000000")); + activeMacroButtonColourEdit->setColour(getProperty(LumatoneEditorProperty::ActiveMacroButtonColour, "FFFFFF")); } void GlobalSettingsArea::saveStateToPropertiesFile(PropertiesFile* propertiesFile) @@ -281,6 +278,8 @@ void GlobalSettingsArea::setDeveloperMode(bool devModeOn) void GlobalSettingsArea::connectionStateChanged(ConnectionState state) { settingsButton->setEnabled(state == ConnectionState::ONLINE); + inactiveMacroButtonColourEdit->setEnabled(state == ConnectionState::ONLINE); + activeMacroButtonColourEdit->setEnabled(state == ConnectionState::ONLINE); } // void GlobalSettingsArea::connectionFaile() diff --git a/Source/GlobalSettingsArea.h b/Source/GlobalSettingsArea.h index f2472ed3..fbbd918d 100644 --- a/Source/GlobalSettingsArea.h +++ b/Source/GlobalSettingsArea.h @@ -54,7 +54,6 @@ class GlobalSettingsArea : public juce::Component, //[UserMethods] -- You can add your own custom methods in this section. void changeListenerCallback(ChangeBroadcaster *source) override; - void restoreStateFromPropertiesFile(PropertiesFile* propertiesFile); void saveStateToPropertiesFile(PropertiesFile* propertiesFile); void listenToColourEditButtons(Button::Listener* listenerIn); @@ -74,7 +73,8 @@ class GlobalSettingsArea : public juce::Component, void resized() override; void buttonClicked (juce::Button* buttonThatWasClicked) override; - +private: + void restoreStateFromPropertiesFile(); private: //[UserVariables] -- You can add your own custom variables in this section. diff --git a/Source/LumatoneEditorState.cpp b/Source/LumatoneEditorState.cpp index daf4d8c7..5095921e 100644 --- a/Source/LumatoneEditorState.cpp +++ b/Source/LumatoneEditorState.cpp @@ -79,9 +79,9 @@ LumatoneEditorState::~LumatoneEditorState() appFonts = nullptr; } -juce::var LumatoneEditorState::getProperty(juce::Identifier propertyId) const +juce::String LumatoneEditorState::getProperty(juce::Identifier propertyId, juce::String fallbackValue) const { - return propertiesFile->getValue(propertyId.toString()); + return propertiesFile->getValue(propertyId, fallbackValue); } juce::RecentlyOpenedFilesList& LumatoneEditorState::getRecentFiles() diff --git a/Source/LumatoneEditorState.h b/Source/LumatoneEditorState.h index 9438d821..20778e7c 100644 --- a/Source/LumatoneEditorState.h +++ b/Source/LumatoneEditorState.h @@ -98,7 +98,7 @@ class LumatoneEditorState : public LumatoneApplicationState const LumatoneEditorFontLibrary& getAppFonts() const { return *appFonts; } - juce::var getProperty(juce::Identifier propertyId) const; + juce::String getProperty(juce::Identifier propertyId, juce::String fallbackValue=juce::String()) const; // juce::PropertiesFile& getPropertiesFile() { return *propertiesFile; } juce::File getCurrentFile() const { return currentFile; } diff --git a/Source/NoteEditArea.cpp b/Source/NoteEditArea.cpp index 5d64e5ef..087fbf58 100644 --- a/Source/NoteEditArea.cpp +++ b/Source/NoteEditArea.cpp @@ -110,7 +110,7 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) addEditorListener(this); - showIsomorphicMassAssign = (bool)getProperty(LumatoneEditorProperty::IsomorphicMassAssign); + showIsomorphicMassAssign = getProperty(LumatoneEditorProperty::IsomorphicMassAssign).getIntValue(); updateShowIsomorphicAssign(); refreshKeyFields(); diff --git a/Source/Settings/SettingsContainer.cpp b/Source/Settings/SettingsContainer.cpp index b08b6220..22c91e47 100644 --- a/Source/Settings/SettingsContainer.cpp +++ b/Source/Settings/SettingsContainer.cpp @@ -53,7 +53,7 @@ SettingsContainer::SettingsContainer(const LumatoneEditorState& stateIn) addAndMakeVisible(categoryList.get()); model.addChangeListener(this); - auto lastPanelIndex = (int)getProperty(LumatoneEditorProperty::LastSettingsPanel); + auto lastPanelIndex = getProperty(LumatoneEditorProperty::LastSettingsPanel).getIntValue(); categoryList->selectRow(lastPanelIndex); } diff --git a/Source/SingleNoteAssign.cpp b/Source/SingleNoteAssign.cpp index 473c4d98..29474449 100644 --- a/Source/SingleNoteAssign.cpp +++ b/Source/SingleNoteAssign.cpp @@ -181,10 +181,10 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) //[Constructor] You can add your own custom stuff here.. - setNoteToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteNoteSetActive), juce::NotificationType::sendNotification); - setChannelToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteChannelSetActive), juce::NotificationType::sendNotification); - setColourToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteColourSetActive), juce::NotificationType::sendNotification); - keyTypeToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteKeyTypeSetActive),juce::NotificationType::sendNotification); + setNoteToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteNoteSetActive).getIntValue(), juce::NotificationType::sendNotification); + setChannelToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteChannelSetActive).getIntValue(), juce::NotificationType::sendNotification); + setColourToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteColourSetActive).getIntValue(), juce::NotificationType::sendNotification); + keyTypeToggleButton->setToggleState(getProperty(LumatoneEditorProperty::SingleNoteKeyTypeSetActive).getIntValue(), juce::NotificationType::sendNotification); keyTypeCombo->setSelectedId(LumatoneKeyType::noteOnNoteOff); //[/Constructor] } diff --git a/Source/lumatone_editor_library/listeners/firmware_listener.h b/Source/lumatone_editor_library/listeners/firmware_listener.h index 5ef13622..ed8c5ac7 100644 --- a/Source/lumatone_editor_library/listeners/firmware_listener.h +++ b/Source/lumatone_editor_library/listeners/firmware_listener.h @@ -51,6 +51,8 @@ class FirmwareListener virtual void presetFlagsReceived(LumatoneFirmware::PresetFlags presetFlags) {}; + virtual void macroButtonColoursReceived(juce::Colour inactiveColour, juce::Colour activeColour) {}; + virtual void expressionPedalSensitivityReceived(int sensitivity) {}; virtual void noAnswerToCommand(int cmd) {};