Skip to content

Commit

Permalink
improve some state value recalls, add fallback value
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jan 13, 2024
1 parent 4f6cc3f commit 3f79147
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
11 changes: 5 additions & 6 deletions Source/GlobalSettingsArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Source/GlobalSettingsArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Source/LumatoneEditorState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Source/LumatoneEditorState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion Source/NoteEditArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn)

addEditorListener(this);

showIsomorphicMassAssign = (bool)getProperty(LumatoneEditorProperty::IsomorphicMassAssign);
showIsomorphicMassAssign = getProperty(LumatoneEditorProperty::IsomorphicMassAssign).getIntValue();
updateShowIsomorphicAssign();

refreshKeyFields();
Expand Down
2 changes: 1 addition & 1 deletion Source/Settings/SettingsContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions Source/SingleNoteAssign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
2 changes: 2 additions & 0 deletions Source/lumatone_editor_library/listeners/firmware_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};
Expand Down

0 comments on commit 3f79147

Please sign in to comment.