diff --git a/Source/GlobalSettingsArea.cpp b/Source/GlobalSettingsArea.cpp index 6172ada..4791429 100644 --- a/Source/GlobalSettingsArea.cpp +++ b/Source/GlobalSettingsArea.cpp @@ -65,11 +65,11 @@ GlobalSettingsArea::GlobalSettingsArea (const LumatoneEditorState& stateIn) lblColourActiveMacroButton->setColour (juce::TextEditor::textColourId, juce::Colours::black); lblColourActiveMacroButton->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - buttonCalibrate.reset (new juce::TextButton ("buttonCalibrate")); - addAndMakeVisible (buttonCalibrate.get()); - buttonCalibrate->setTooltip (TRANS("Show controls for calibration, setting controller MIDI channels, and updating firmware")); - buttonCalibrate->setButtonText (TRANS("Settings")); - buttonCalibrate->addListener (this); + settingsButton.reset (new juce::TextButton ("buttonCalibrate")); + addAndMakeVisible (settingsButton.get()); + settingsButton->setTooltip (TRANS("Show controls for calibration, setting controller MIDI channels, and updating firmware")); + settingsButton->setButtonText (TRANS("Settings")); + settingsButton->addListener (this); //[UserPreSize] @@ -91,7 +91,7 @@ GlobalSettingsArea::GlobalSettingsArea (const LumatoneEditorState& stateIn) addStatusListener(this); - buttonCalibrate->setEnabled(false); + settingsButton->setEnabled(false); /* We don't want a resize here /* @@ -119,7 +119,7 @@ GlobalSettingsArea::~GlobalSettingsArea() lblPresetButtonColours = nullptr; lblColourInactiveMacroButton = nullptr; lblColourActiveMacroButton = nullptr; - buttonCalibrate = nullptr; + settingsButton = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -143,10 +143,10 @@ void GlobalSettingsArea::resized() // Build right-to-left int calbrateBtnHeight = roundToInt(getHeight() * calibrateHeight); - int calibrateWidth = getLookAndFeel().getTextButtonWidthToFitText(*buttonCalibrate, calbrateBtnHeight); + int calibrateWidth = getLookAndFeel().getTextButtonWidthToFitText(*settingsButton, calbrateBtnHeight); - buttonCalibrate->setSize(calibrateWidth, calbrateBtnHeight); - buttonCalibrate->setTopRightPosition(getWidth(), roundToInt((getHeight() - buttonCalibrate->getHeight()) * 0.5f)); + settingsButton->setSize(calibrateWidth, calbrateBtnHeight); + settingsButton->setTopRightPosition(getWidth(), roundToInt((getHeight() - settingsButton->getHeight()) * 0.5f)); float margin = roundToInt(getHeight() * 0.1f); float colourEditHeight = proportionOfHeight(controlsHeight); @@ -156,7 +156,7 @@ void GlobalSettingsArea::resized() lblColourInactiveMacroButton->setFont(colourLabelsFont); resizeLabelWithHeight(lblColourInactiveMacroButton.get(), colourEditHeight); - lblColourInactiveMacroButton->setTopRightPosition(buttonCalibrate->getX() - margin, controlY); + lblColourInactiveMacroButton->setTopRightPosition(settingsButton->getX() - margin, controlY); inactiveMacroButtonColourEdit->setSize(colourButtonWidth, colourEditHeight); inactiveMacroButtonColourEdit->setTopRightPosition(lblColourInactiveMacroButton->getX() - margin, controlY); @@ -185,7 +185,7 @@ void GlobalSettingsArea::buttonClicked (juce::Button* buttonThatWasClicked) //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] - if (buttonThatWasClicked == buttonCalibrate.get()) + if (buttonThatWasClicked == settingsButton.get()) { //[UserButtonCode_buttonCalibrate] -- add your button handler code here.. @@ -227,8 +227,8 @@ void GlobalSettingsArea::lookAndFeelChanged() lblColourActiveMacroButton->setColour(Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::DescriptionText)); lblColourInactiveMacroButton->setColour(Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::DescriptionText)); - buttonCalibrate->setColour(TextButton::ColourIds::buttonColourId, Colour(0xff383b3d)); - buttonCalibrate->setColour(TextButton::ColourIds::textColourOffId, Colour(0xffffffff)); + settingsButton->setColour(TextButton::ColourIds::buttonColourId, Colour(0xff383b3d)); + settingsButton->setColour(TextButton::ColourIds::textColourOffId, Colour(0xffffffff)); } void GlobalSettingsArea::changeListenerCallback(ChangeBroadcaster *source) @@ -248,19 +248,19 @@ void GlobalSettingsArea::changeListenerCallback(ChangeBroadcaster *source) void GlobalSettingsArea::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) { inactiveMacroButtonColourEdit->setColour( - propertiesFile->getValue("InactiveMacroButtonColour", "000000")); + propertiesFile->getValue(LumatoneEditorProperty::InactiveMacroButtonColour, "000000")); activeMacroButtonColourEdit->setColour( - propertiesFile->getValue("ActiveMacroButtonColour", "FFFFFF")); + propertiesFile->getValue(LumatoneEditorProperty::ActiveMacroButtonColour, "FFFFFF")); } void GlobalSettingsArea::saveStateToPropertiesFile(PropertiesFile* propertiesFile) { String inactiveMacroButtonColour = inactiveMacroButtonColourEdit->getColourAsString(); - propertiesFile->setValue("InactiveMacroButtonColour", inactiveMacroButtonColour); + propertiesFile->setValue(LumatoneEditorProperty::InactiveMacroButtonColour, inactiveMacroButtonColour); String activeMacroButtonColour = activeMacroButtonColourEdit->getColourAsString(); - propertiesFile->setValue("ActiveMacroButtonColour", activeMacroButtonColour); + propertiesFile->setValue(LumatoneEditorProperty::ActiveMacroButtonColour, activeMacroButtonColour); } void GlobalSettingsArea::listenToColourEditButtons(Button::Listener* listenerIn) @@ -274,18 +274,18 @@ void GlobalSettingsArea::setDeveloperMode(bool devModeOn) showDeveloperMode = devModeOn; lblDeveloperMode->setVisible(showDeveloperMode); if (devModeOn) - buttonCalibrate->setEnabled(true); + settingsButton->setEnabled(true); repaint(); } void GlobalSettingsArea::connectionStateChanged(ConnectionState state) { - buttonCalibrate->setEnabled(state == ConnectionState::ONLINE); + settingsButton->setEnabled(state == ConnectionState::ONLINE); } // void GlobalSettingsArea::connectionFaile() // { -// buttonCalibrate->setEnabled(false); +// settingsButton->setEnabled(false); // } //[/MiscUserCode] @@ -321,7 +321,7 @@ BEGIN_JUCER_METADATA edBkgCol="0" labelText="active" editableSingleClick="0" editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font" fontsize="15.0" kerning="0.0" bold="0" italic="0" justification="33"/> - diff --git a/Source/GlobalSettingsArea.h b/Source/GlobalSettingsArea.h index 6033435..f2472ed 100644 --- a/Source/GlobalSettingsArea.h +++ b/Source/GlobalSettingsArea.h @@ -105,7 +105,7 @@ class GlobalSettingsArea : public juce::Component, std::unique_ptr lblPresetButtonColours; std::unique_ptr lblColourInactiveMacroButton; std::unique_ptr lblColourActiveMacroButton; - std::unique_ptr buttonCalibrate; + std::unique_ptr settingsButton; //============================================================================== diff --git a/Source/LumatoneEditorState.cpp b/Source/LumatoneEditorState.cpp index 61f0d68..daf4d8c 100644 --- a/Source/LumatoneEditorState.cpp +++ b/Source/LumatoneEditorState.cpp @@ -204,6 +204,8 @@ juce::ValueTree LumatoneEditorState::loadStateProperties(juce::ValueTree stateIn void LumatoneEditorState::handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier &property) { + LumatoneApplicationState::handleStatePropertyChange(stateIn, property); + if (property == LumatoneEditorProperty::HasChangesToSave) { hasChangesToSave = (bool)stateIn[property]; @@ -219,41 +221,18 @@ void LumatoneEditorState::handleStatePropertyChange(juce::ValueTree stateIn, con else if (property == LumatoneEditorProperty::FirmwareUpdatePerformed) { firmwareUpdateWasPerformed = (bool)stateIn[property]; - } - else if (property == LumatoneEditorProperty::ColourPalettes) - { - } else if (property == LumatoneEditorProperty::CurrentFile) { currentFile = juce::File(stateIn[property]); - } - else if (property == LumatoneEditorProperty::RecentFiles) - { - } - else if (property == LumatoneEditorProperty::UserDocumentsDirectory) - { - - } - else if (property == LumatoneEditorProperty::UserMappingsDirectory) - { - - } - else if (property == LumatoneEditorProperty::UserPalettesDirectory) - { - } else if (property == LumatoneEditorProperty::DeveloperModeOn) { - + inDeveloperMode = (bool)stateIn[property]; } else if (property == LumatoneEditorProperty::EditorMode) { - - } - else - { - LumatoneApplicationState::handleStatePropertyChange(stateIn, property); + editorMode = EditorMode((int)stateIn[property]); } } diff --git a/Source/LumatoneEditorState.h b/Source/LumatoneEditorState.h index 47a7362..9438d82 100644 --- a/Source/LumatoneEditorState.h +++ b/Source/LumatoneEditorState.h @@ -33,6 +33,9 @@ namespace LumatoneEditorProperty static const juce::Identifier InCalibrationMode = juce::Identifier("InCalibrationMode"); static const juce::Identifier FirmwareUpdatePerformed = juce::Identifier("FirmwareUpdatePerformed"); + static const juce::Identifier InactiveMacroButtonColour = juce::Identifier("InactiveMacroButtonColour"); + static const juce::Identifier ActiveMacroButtonColour = juce::Identifier("ActiveMacroButtonColour"); + static const juce::Identifier ColourPalettes = juce::Identifier("ColourPalettes"); static const juce::Identifier CurrentFile = juce::Identifier("CurrentFile"); @@ -55,6 +58,8 @@ namespace LumatoneEditorProperty static const juce::Identifier SingleNoteColourSetActive = juce::Identifier("SingleNoteColourSetActive"); static const juce::Identifier SingleNoteKeyTypeSetActive = juce::Identifier("SingleNoteKeyTypeSetActive"); + static const juce::Identifier IsomorphicMassAssign = juce::Identifier("IsomorphicMassAssign"); + static const juce::Identifier LastSettingsPanel = juce::Identifier("LastSettingsPanel"); } diff --git a/Source/Main.cpp b/Source/Main.cpp index f3f9d81..1516636 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -527,7 +527,7 @@ bool TerpstraSysExApplication::performUndoableAction(UndoableAction* editAction, if (undoManager.perform(editAction)) // UndoManager will check for nullptr and also for disposing of the object { // setHasChangesToSave(true); - ((MainContentComponent*)(mainWindow->getContentComponent()))->refreshAllFields(); + //((MainContentComponent*)(mainWindow->getContentComponent()))->refreshAllFields(); return true; } } diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index c9131d1..db61607 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -115,7 +115,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j btnImportFile->setEnabled(false); // Initialize mapping structure - deleteAll(); + //deleteAll(); } MainContentComponent::~MainContentComponent() @@ -139,11 +139,6 @@ MainContentComponent::~MainContentComponent() lblAppVersion = nullptr; } -void MainContentComponent::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) -{ - noteEditArea->restoreStateFromPropertiesFile(propertiesFile); -} - void MainContentComponent::saveStateToPropertiesFile(PropertiesFile* propertiesFile) { noteEditArea->saveStateToPropertiesFile(propertiesFile); @@ -151,29 +146,29 @@ void MainContentComponent::saveStateToPropertiesFile(PropertiesFile* propertiesF } // Set the currentSectionKey mapping to be edited to the value passed in parameter -void MainContentComponent::setData(LumatoneLayout& newData, bool withRefresh) -{ - *mappingData = newData; - - noteEditArea->onSetData(newData); - - if (withRefresh) - { - refreshAllFields(); - } -} - -void MainContentComponent::deleteAll(bool withRefresh) -{ - LumatoneLayout keyMapping; - setData(keyMapping, withRefresh); -} - -// Copy the edited mapping to the variable passed as parameter -void MainContentComponent::getData(LumatoneLayout& newData) -{ - newData = *getMappingData(); -} +//void MainContentComponent::setData(LumatoneLayout& newData, bool withRefresh) +//{ +// *mappingData = newData; +// +// noteEditArea->onSetData(newData); +// +// if (withRefresh) +// { +// refreshAllFields(); +// } +//} +// +//void MainContentComponent::deleteAll(bool withRefresh) +//{ +// LumatoneLayout keyMapping; +// setData(keyMapping, withRefresh); +//} +// +//// Copy the edited mapping to the variable passed as parameter +//void MainContentComponent::getData(LumatoneLayout& newData) +//{ +// newData = *getMappingData(); +//} TabbedButtonBar *MainContentComponent::getOctaveBoardSelectorTab() { @@ -282,114 +277,114 @@ void MainContentComponent::connectionStateChanged(ConnectionState state) btnImportFile->setEnabled(state == ConnectionState::ONLINE); } -void MainContentComponent::octaveColourConfigReceived(int octaveIndex, uint8 rgbFlag, const int* colourData) -{ - for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) - { - // LumatoneKey& keyData = getBoard(octaveIndex - 1)->theKeys[keyIndex]; - // auto newValue = colourData[keyIndex]; - - // if (rgbFlag == 0) - // { - // keyData.colour = Colour(newValue, keyData.colour.getGreen(), keyData.colour.getBlue()); - // } - // else if (rgbFlag == 1) - // { - // keyData.colour = Colour(keyData.colour.getRed(), newValue, keyData.colour.getBlue()); - // } - // else if (rgbFlag == 2) - // { - // keyData.colour = Colour(keyData.colour.getRed(), keyData.colour.getGreen(), newValue); - // } - // else - // jassertfalse; - } - - refreshKeyDataFields(); -} - -void MainContentComponent::octaveChannelConfigReceived(int octaveIndex, const int* channelData) -{ - for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) - { - // Check channel values? - // getBoard(octaveIndex - 1)->theKeys[keyIndex].channelNumber = channelData[keyIndex]; - } - - refreshKeyDataFields(); -} - -void MainContentComponent::octaveNoteConfigReceived(int octaveIndex, const int* noteData) -{ - for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) - { - // Check note values? - // getBoard(octaveIndex - 1)->theKeys[keyIndex].noteNumber = noteData[keyIndex]; - } - - refreshKeyDataFields(); -} - -void MainContentComponent::keyTypeConfigReceived(int octaveIndex, const int* keyTypeData) -{ - for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) - { - // Check type values? - // getBoard(octaveIndex - 1)->theKeys[keyIndex].keyType = LumatoneKeyType(keyTypeData[keyIndex]); - } - - refreshKeyDataFields(); -} - -void MainContentComponent::velocityConfigReceived(const int* velocityData) -{ - // mappingData.velocityTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; - // for (int i = 0; i < 128; i++) - // mappingData.velocityTable.velocityValues[i] = velocityData[127 - i]; // Reversed - curvesArea->loadFromMapping(); -} - -void MainContentComponent::aftertouchConfigReceived(const int* aftertouch) -{ - // mappingData.afterTouchTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; - // memmove(mappingData.afterTouchTable.velocityValues, aftertouch, sizeof(int) * 128); - curvesArea->loadFromMapping(); -} - -void MainContentComponent::velocityIntervalConfigReceived(const int* velocityData) -{ - // memmove(mappingData.table, velocityData, sizeof(int) * VELOCITYINTERVALTABLESIZE); - curvesArea->loadFromMapping(); -} - -void MainContentComponent::faderConfigReceived(const int* faderData) -{ - // mappingData.faderTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; - // memmove(mappingData.faderTable.velocityValues, faderData, sizeof(int) * 128); - curvesArea->loadFromMapping(); -} - -void MainContentComponent::faderTypeConfigReceived(int octaveIndex, const int* faderTypeData) -{ - for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) - { - // getBoard(octaveIndex - 1)->theKeys[keyIndex].ccFaderDefault = faderTypeData[keyIndex]; - } -} - -void MainContentComponent::lumatouchConfigReceived(const int* lumatouchData) -{ - // mappingData.lumaTouchTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; - // memmove(mappingData.lumaTouchTable.velocityValues, lumatouchData, sizeof(int) * 128); - curvesArea->loadFromMapping(); -} - -void MainContentComponent::firmwareRevisionReceived(LumatoneFirmware::Version version) -{ - // Make sure changes happen in proper order - noteEditArea->resetOctaveSize(); - allKeysOverview->resetOctaveSize(); -} +//void MainContentComponent::octaveColourConfigReceived(int octaveIndex, uint8 rgbFlag, const int* colourData) +//{ +// for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) +// { +// // LumatoneKey& keyData = getBoard(octaveIndex - 1)->theKeys[keyIndex]; +// // auto newValue = colourData[keyIndex]; +// +// // if (rgbFlag == 0) +// // { +// // keyData.colour = Colour(newValue, keyData.colour.getGreen(), keyData.colour.getBlue()); +// // } +// // else if (rgbFlag == 1) +// // { +// // keyData.colour = Colour(keyData.colour.getRed(), newValue, keyData.colour.getBlue()); +// // } +// // else if (rgbFlag == 2) +// // { +// // keyData.colour = Colour(keyData.colour.getRed(), keyData.colour.getGreen(), newValue); +// // } +// // else +// // jassertfalse; +// } +// +// refreshKeyDataFields(); +//} +// +//void MainContentComponent::octaveChannelConfigReceived(int octaveIndex, const int* channelData) +//{ +// for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) +// { +// // Check channel values? +// // getBoard(octaveIndex - 1)->theKeys[keyIndex].channelNumber = channelData[keyIndex]; +// } +// +// refreshKeyDataFields(); +//} +// +//void MainContentComponent::octaveNoteConfigReceived(int octaveIndex, const int* noteData) +//{ +// for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) +// { +// // Check note values? +// // getBoard(octaveIndex - 1)->theKeys[keyIndex].noteNumber = noteData[keyIndex]; +// } +// +// refreshKeyDataFields(); +//} +// +//void MainContentComponent::keyTypeConfigReceived(int octaveIndex, const int* keyTypeData) +//{ +// for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) +// { +// // Check type values? +// // getBoard(octaveIndex - 1)->theKeys[keyIndex].keyType = LumatoneKeyType(keyTypeData[keyIndex]); +// } +// +// refreshKeyDataFields(); +//} +// +//void MainContentComponent::velocityConfigReceived(const int* velocityData) +//{ +// // mappingData.velocityTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; +// // for (int i = 0; i < 128; i++) +// // mappingData.velocityTable.velocityValues[i] = velocityData[127 - i]; // Reversed +// curvesArea->loadFromMapping(); +//} +// +//void MainContentComponent::aftertouchConfigReceived(const int* aftertouch) +//{ +// // mappingData.afterTouchTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; +// // memmove(mappingData.afterTouchTable.velocityValues, aftertouch, sizeof(int) * 128); +// curvesArea->loadFromMapping(); +//} +// +//void MainContentComponent::velocityIntervalConfigReceived(const int* velocityData) +//{ +// // memmove(mappingData.table, velocityData, sizeof(int) * VELOCITYINTERVALTABLESIZE); +// curvesArea->loadFromMapping(); +//} +// +//void MainContentComponent::faderConfigReceived(const int* faderData) +//{ +// // mappingData.faderTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; +// // memmove(mappingData.faderTable.velocityValues, faderData, sizeof(int) * 128); +// curvesArea->loadFromMapping(); +//} +// +//void MainContentComponent::faderTypeConfigReceived(int octaveIndex, const int* faderTypeData) +//{ +// for (int keyIndex = 0; keyIndex < getOctaveBoardSize(); keyIndex++) +// { +// // getBoard(octaveIndex - 1)->theKeys[keyIndex].ccFaderDefault = faderTypeData[keyIndex]; +// } +//} +// +//void MainContentComponent::lumatouchConfigReceived(const int* lumatouchData) +//{ +// // mappingData.lumaTouchTable.editStrategy = LumatoneConfigTable::DrawMode::freeDrawing; +// // memmove(mappingData.lumaTouchTable.velocityValues, lumatouchData, sizeof(int) * 128); +// curvesArea->loadFromMapping(); +//} + +//void MainContentComponent::firmwareRevisionReceived(LumatoneFirmware::Version version) +//{ +// // Make sure changes happen in proper order +// //noteEditArea->resetOctaveSize(); +// //allKeysOverview->resetOctaveSize(); +//} void MainContentComponent::changeListenerCallback(ChangeBroadcaster *source) { @@ -509,33 +504,30 @@ void MainContentComponent::resized() resizeLabelWithHeight(lblAppVersion.get(), roundToInt(lblAppName->getHeight() * 0.75f)); lblAppVersion->setTopLeftPosition(lblAppName->getRight(), lblAppName->getBottom() - lblAppVersion->getHeight()); } - -void MainContentComponent::refreshKeyDataFields() -{ - noteEditArea->refreshKeyFields(); - // allKeysOverview->mappingUpdateCallback(); - // juce::Timer::callAfterDelay(1, [&]() { allKeysOverview->refreshMappingData(); }); -} - -void MainContentComponent::refreshAllFields() -{ - refreshKeyDataFields(); - generalOptionsArea->loadFromMapping(); - pedalSensitivityDlg->loadFromMapping(); - curvesArea->loadFromMapping(); - curvesArea->repaint(); -} +// +//void MainContentComponent::refreshKeyDataFields() +//{ +// noteEditArea->refreshKeyFields(); +// // allKeysOverview->mappingUpdateCallback(); +// // juce::Timer::callAfterDelay(1, [&]() { allKeysOverview->refreshMappingData(); }); +//} +// +//void MainContentComponent::refreshAllFields() +//{ +// refreshKeyDataFields(); +// generalOptionsArea->loadFromMapping(); +// pedalSensitivityDlg->loadFromMapping(); +// curvesArea->loadFromMapping(); +// curvesArea->repaint(); +//} void MainContentComponent::handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) { + LumatoneEditorState::handleStatePropertyChange(stateIn, property); + if (property == LumatoneEditorProperty::DeveloperModeOn) { - inDeveloperMode = (bool)stateIn[property]; updateDeveloperMode(); } - else - { - LumatoneApplicationState::handleStatePropertyChange(stateIn, property); - } } diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 4e1af39..4d83d54 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -14,7 +14,6 @@ #include "./lumatone_editor_library/data/lumatone_layout.h" #include "./lumatone_editor_library/listeners/status_listener.h" -#include "./lumatone_editor_library/listeners/firmware_listener.h" #include "./lumatone_editor_library/lumatone_midi_driver/firmware_types.h" class LumatoneKeyboardComponent; @@ -34,7 +33,6 @@ class PedalSensitivityDlg; class MainContentComponent : public juce::Component , public LumatoneEditorState , public LumatoneEditor::StatusListener - , public LumatoneEditor::FirmwareListener , public juce::ChangeListener , public juce::Button::Listener { @@ -43,16 +41,8 @@ class MainContentComponent : public juce::Component MainContentComponent(const LumatoneEditorState& stateIn, juce::ApplicationCommandManager* commandManager); ~MainContentComponent(); - void restoreStateFromPropertiesFile(PropertiesFile* propertiesFile); void saveStateToPropertiesFile(PropertiesFile* propertiesFile); - // Transfer of data - void setData(LumatoneLayout& newData, bool withRefresh = true); - void deleteAll(bool withRefresh = true); - - void getData(LumatoneLayout& newData); - // LumatoneLayout& getMappingInEdit() { return getMapping; } - juce::TabbedButtonBar* getOctaveBoardSelectorTab(); CurvesArea* getCurvesArea() { return curvesArea.get(); } @@ -73,45 +63,22 @@ class MainContentComponent : public juce::Component void paint (juce::Graphics&) override; void resized() override; - void refreshKeyDataFields(); - void refreshAllFields(); + //void refreshKeyDataFields(); + //void refreshAllFields(); // Implementation of LumatoneEditor::StatusListener void connectionStateChanged(ConnectionState state) override; - // Implementation of LumatoneEditor::FirmwareListener - - void octaveColourConfigReceived(int octaveIndex, uint8 rgbFlag, const int* colourData) override; - - void octaveChannelConfigReceived(int octaveIndex, const int* channelData) override; - - void octaveNoteConfigReceived(int octaveIndex, const int* noteData) override; - - void keyTypeConfigReceived(int octaveIndex, const int* keyTypeData) override; - - void velocityConfigReceived(const int* velocityData) override; - - void aftertouchConfigReceived(const int* aftertouchData) override; - void velocityIntervalConfigReceived(const int* velocityData) override; - - void faderConfigReceived(const int* faderData) override; - - void faderTypeConfigReceived(int octaveIndex, const int* faderTypeData) override; - - void lumatouchConfigReceived(const int* lumatouchData) override; - - void firmwareRevisionReceived(LumatoneFirmware::Version version) override; + //============================================================================== + // Implementation of LumatoneEditorState - // Implementation of LumatoneState void handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) override; - private: void updateDeveloperMode(); - private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainContentComponent) diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index 9e58e15..fd6a32b 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -122,8 +122,6 @@ void MainWindow::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) fixWindowPositionAndSize(!useSavedState); setVisible(true); - - ((MainContentComponent*)(getContentComponent()))->restoreStateFromPropertiesFile(propertiesFile); } void MainWindow::updateBounds() diff --git a/Source/NoteEditArea.cpp b/Source/NoteEditArea.cpp index 1da8863..5d64e5e 100644 --- a/Source/NoteEditArea.cpp +++ b/Source/NoteEditArea.cpp @@ -43,7 +43,6 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) , currentSingleKeySelection(-1) { //[Constructor_pre] You can add your own custom stuff here.. - // showIsomorphicMassAssign = TerpstraSysExApplication::getApp().getPropertiesFile()->getBoolValue("IsomorphicMassAssign", false); //[/Constructor_pre] setName ("NoteEditArea"); @@ -53,20 +52,15 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) editFunctionsTab->addTab (TRANS("Manual Assign"), juce::Colours::lightgrey, new SingleNoteAssign(stateIn), true); editFunctionsTab->setCurrentTabIndex (0); - editFunctionsTab->setBounds (8, 48, 320, 422); - labelWindowTitle.reset (new juce::Label ("labelWindowTitle", TRANS("Assign Keys"))); addAndMakeVisible (labelWindowTitle.get()); - labelWindowTitle->setFont (juce::Font (18.00f, juce::Font::plain).withTypefaceStyle ("Regular")); + labelWindowTitle->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); labelWindowTitle->setJustificationType (juce::Justification::centredLeft); labelWindowTitle->setEditable (false, false, false); - labelWindowTitle->setColour (juce::Label::textColourId, juce::Colour (0xff61acc8)); - labelWindowTitle->setColour (juce::TextEditor::textColourId, juce::Colours::black); + labelWindowTitle->setColour(Label::ColourIds::textColourId, getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::LabelBlue)); labelWindowTitle->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - labelWindowTitle->setBounds (8, 8, 104, 24); - //[UserPreSize] editFunctionsTab->setIndent(0); @@ -75,10 +69,6 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) editFunctionsTab->setColour(TabbedComponent::ColourIds::outlineColourId, Colour()); editFunctionsTab->setColour(TabbedComponent::ColourIds::backgroundColourId, Colour()); - labelWindowTitle->setFont(getAppFonts().getFont(LumatoneEditorFont::UniviaProBold)); - - if (showIsomorphicMassAssign) - editFunctionsTab->addTab(TRANS("Isomorphic Assign"), juce::Colours::lightgrey, new IsomorphicMassAssign(*this), true); // Selector for octave boards octaveBoardSelectorTab.reset(new TabbedButtonBar(TabbedButtonBar::Orientation::TabsAtTop)); @@ -108,6 +98,8 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) getEditorLookAndFeel().setColour(LumatoneKeyEdit::outlineColourId, Colour(0xffd7d9da)); getEditorLookAndFeel().setColour(LumatoneKeyEdit::selectedKeyOutlineId, Colour(0xfff7990d)); + backgroundColour = getEditorLookAndFeel().findColour(LumatoneEditorColourIDs::ControlAreaBackground); + // First octaveboard selection, selection on first key: see MainComponent (Has to be done after change listener has been established) auto singleNoteAssign = dynamic_cast(editFunctionsTab->getTabContentComponent(0)); @@ -118,6 +110,10 @@ NoteEditArea::NoteEditArea (const LumatoneEditorState& stateIn) addEditorListener(this); + showIsomorphicMassAssign = (bool)getProperty(LumatoneEditorProperty::IsomorphicMassAssign); + updateShowIsomorphicAssign(); + + refreshKeyFields(); //[/Constructor] } @@ -268,8 +264,9 @@ void NoteEditArea::mouseDown (const juce::MouseEvent& e) { // TerpstraSysExApplication::getApp().setHasChangesToSave(true); + // TODO // Refresh key fields (all may be affected) - ((MainContentComponent*)getParentComponent())->refreshKeyDataFields(); + //((MainContentComponent*)getParentComponent())->refreshKeyDataFields(); } break; } @@ -288,28 +285,20 @@ void NoteEditArea::mouseDown (const juce::MouseEvent& e) //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... -void NoteEditArea::lookAndFeelChanged() -{ - LookAndFeel& lookAndFeel = getLookAndFeel(); - backgroundColour = lookAndFeel.findColour(LumatoneEditorColourIDs::ControlAreaBackground); - labelWindowTitle->setColour(Label::ColourIds::textColourId, lookAndFeel.findColour(LumatoneEditorColourIDs::LabelBlue)); -} - void NoteEditArea::setControlsTopLeftPosition(int controlsAreaX, int controlsAreaY) { setTopLeftPosition(controlsAreaX, controlsAreaY - octaveTabsArea.getHeight()); } - -void NoteEditArea::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) -{ - dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::SingleNoteAssignMode))->restoreStateFromPropertiesFile(propertiesFile); - - if (showIsomorphicMassAssign) - dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::IsomorphicMassAssignMode))->restoreStateFromPropertiesFile(propertiesFile); - - resized(); -} +//void NoteEditArea::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) +//{ +// dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::SingleNoteAssignMode))->restoreStateFromPropertiesFile(propertiesFile); +// +// if (showIsomorphicMassAssign) +// dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::IsomorphicMassAssignMode))->restoreStateFromPropertiesFile(propertiesFile); +// +// resized(); +//} void NoteEditArea::saveStateToPropertiesFile(PropertiesFile* propertiesFile) { @@ -329,13 +318,12 @@ void NoteEditArea::changeListenerCallback(ChangeBroadcaster *source) setKeyFieldValues(getBoard(setSelection)); } } - - -void NoteEditArea::onSetData(LumatoneLayout& newData) -{ - // Add colours of the mapping to the colour combo box - return dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::SingleNoteAssignMode))->onSetData(newData); -} +// +//void NoteEditArea::onSetData(LumatoneLayout& newData) +//{ +// // Add colours of the mapping to the colour combo box +// //return dynamic_cast(editFunctionsTab->getTabContentComponent(noteEditMode::SingleNoteAssignMode))->onSetData(newData); +//} void NoteEditArea::setKeyFieldValues(const LumatoneBoard& keySet) { @@ -445,6 +433,30 @@ void NoteEditArea::selectionChanged(juce::Array selection) refreshKeyFields(); } +void NoteEditArea::updateShowIsomorphicAssign() +{ + bool showMode = showIsomorphicMassAssign || getInDeveloperMode(); + + if (showMode && editFunctionsTab->getNumTabs() == 1) + { + editFunctionsTab->addTab(TRANS("Isomorphic Assign"), juce::Colours::lightgrey, new IsomorphicMassAssign(*this), true); + } + else if (!showMode && editFunctionsTab->getNumTabs() == 2) + { + editFunctionsTab->removeTab(1); + } +} + +void NoteEditArea::handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) +{ + LumatoneEditorState::handleStatePropertyChange(stateIn, property); + + if (property == LumatoneEditorProperty::DeveloperModeOn) + { + updateShowIsomorphicAssign(); + } +} + //[/MiscUserCode] diff --git a/Source/NoteEditArea.h b/Source/NoteEditArea.h index 9c1be41..6dfe968 100644 --- a/Source/NoteEditArea.h +++ b/Source/NoteEditArea.h @@ -58,18 +58,12 @@ class NoteEditArea : public juce::Component, //============================================================================== //[UserMethods] -- You can add your own custom methods in this section. - void restoreStateFromPropertiesFile(PropertiesFile* propertiesFile); + //void restoreStateFromPropertiesFile(PropertiesFile* propertiesFile); void saveStateToPropertiesFile(PropertiesFile* propertiesFile); // Implementation of ChangeListener void changeListenerCallback(ChangeBroadcaster *source) override; - // Things to be done when a new mapping is loaded. E. g. fill the colour combo box with the colours appearing in the mapping. - void onSetData(LumatoneLayout& newData); - - // Fill key fields with values from a certain octaveboard subset - void setKeyFieldValues(const LumatoneBoard& keySet); - juce::TabbedButtonBar* getOctaveBoardSelectorTab() { return octaveBoardSelectorTab.get(); } ColourViewComponent* getColourViewComponent(); @@ -80,32 +74,43 @@ class NoteEditArea : public juce::Component, void changeSingleKeySelection(int newSelection); - void refreshKeyFields(); - void lookAndFeelChanged() override; + // ColourSelectionBroadcaster Implementation + juce::Colour getSelectedColour() override; + void deselectColour() override {}; // Helper method for aligning the Octave Section TabbedButtonBar void setControlsTopLeftPosition(int controlsAreaX, int controlsAreaY); - void resetOctaveSize(bool refreshAndResize=true); + //[/UserMethods] + + void paint (juce::Graphics& g) override; + void resized() override; + void mouseDown (const juce::MouseEvent& e) override; - // ColourSelectionBroadcaster Implementation - juce::Colour getSelectedColour() override; - void deselectColour() override {}; +private: + void refreshKeyFields(); + void resetOctaveSize(bool refreshAndResize = true); + + + // Things to be done when a new mapping is loaded. E. g. fill the colour combo box with the colours appearing in the mapping. + //void onSetData(LumatoneLayout& newData); + + // Fill key fields with values from a certain octaveboard subset + void setKeyFieldValues(const LumatoneBoard& keySet); + void updateShowIsomorphicAssign(); + +private: + // LumatoneEditor::EditorListener void completeMappingLoaded(LumatoneLayout mappingData) override; void boardChanged(LumatoneBoard boardData) override; void keyChanged(int boardIndex, int keyIndex, LumatoneKey lumatoneKey) override; void selectionChanged(juce::Array selection) override; - - //[/UserMethods] - - void paint (juce::Graphics& g) override; - void resized() override; - void mouseDown (const juce::MouseEvent& e) override; - + // LumatoneEditorState implementaiton + void handleStatePropertyChange(juce::ValueTree stateIn, const juce::Identifier& property) override; private: diff --git a/Source/SingleNoteAssign.cpp b/Source/SingleNoteAssign.cpp index 4cfe6fa..473c4d9 100644 --- a/Source/SingleNoteAssign.cpp +++ b/Source/SingleNoteAssign.cpp @@ -44,43 +44,31 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) noteAutoIncrButton->setButtonText (TRANS("Notes-Per-Click")); noteAutoIncrButton->addListener (this); - noteAutoIncrButton->setBounds (8, 232, 160, 24); - channelAutoIncrButton.reset (new juce::ToggleButton ("channelAutoIncrButton")); addAndMakeVisible (channelAutoIncrButton.get()); channelAutoIncrButton->setButtonText (TRANS("Channels, after Note #:")); channelAutoIncrButton->addListener (this); - channelAutoIncrButton->setBounds (8, 264, 160, 24); - setNoteToggleButton.reset (new juce::ToggleButton ("setNoteToggleButton")); addAndMakeVisible (setNoteToggleButton.get()); setNoteToggleButton->setButtonText (TRANS("Note # (0-127):")); setNoteToggleButton->addListener (this); - setNoteToggleButton->setBounds (8, 128, 112, 24); - setChannelToggleButton.reset (new juce::ToggleButton ("setChannelToggleButton")); addAndMakeVisible (setChannelToggleButton.get()); setChannelToggleButton->setButtonText (TRANS("Channel (1-16):")); setChannelToggleButton->addListener (this); - setChannelToggleButton->setBounds (8, 160, 112, 24); - setColourToggleButton.reset (new juce::ToggleButton ("setColourToggleButton")); addAndMakeVisible (setColourToggleButton.get()); setColourToggleButton->setButtonText (TRANS("Key Colour: ")); setColourToggleButton->addListener (this); - setColourToggleButton->setBounds (8, 96, 112, 24); - keyTypeToggleButton.reset (new juce::ToggleButton ("keyTypeToggleButton")); addAndMakeVisible (keyTypeToggleButton.get()); keyTypeToggleButton->setButtonText (TRANS("Key type:")); keyTypeToggleButton->addListener (this); - keyTypeToggleButton->setBounds (8, 64, 112, 24); - keyTypeCombo.reset (new juce::ComboBox ("keyTypeCombo")); addAndMakeVisible (keyTypeCombo.get()); keyTypeCombo->setEditableText (false); @@ -93,8 +81,6 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) keyTypeCombo->addItem (TRANS("Disabled"), 4); keyTypeCombo->addListener (this); - keyTypeCombo->setBounds (120, 64, 192, 24); - noteInput.reset (new juce::Slider ("noteInput")); addAndMakeVisible (noteInput.get()); noteInput->setTooltip (TRANS("MIDI note or MIDI controller no. (for key type \'continuous controller\')")); @@ -103,14 +89,10 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) noteInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20); noteInput->addListener (this); - noteInput->setBounds (120, 128, 112, 24); - colourSubwindow.reset (new ColourViewComponent()); addAndMakeVisible (colourSubwindow.get()); colourSubwindow->setName ("colourSubwindow"); - colourSubwindow->setBounds (120, 96, 56, 24); - autoIncrementLabel.reset (new juce::Label ("autoIncrementLabel", TRANS("Auto-Increment"))); addAndMakeVisible (autoIncrementLabel.get()); @@ -120,13 +102,11 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) autoIncrementLabel->setColour (juce::TextEditor::textColourId, juce::Colours::black); autoIncrementLabel->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000)); - autoIncrementLabel->setBounds (8, 204, 111, 24); - colourTextEditor.reset (new ColourTextEditor ("colourTextEditor", "60aac5")); addAndMakeVisible (colourTextEditor.get()); colourTextEditor->setName ("colourTextEditor"); + getEditorLookAndFeel().setupTextEditor(*colourTextEditor); - colourTextEditor->setBounds (184, 96, 128, 24); channelInput.reset (new juce::Slider ("channelInput")); addAndMakeVisible (channelInput.get()); @@ -135,8 +115,6 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) channelInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20); channelInput->addListener (this); - channelInput->setBounds (120, 160, 112, 24); - channelAutoIncrNoteInput.reset (new juce::Slider ("channelAutoIncrNoteInput")); addAndMakeVisible (channelAutoIncrNoteInput.get()); channelAutoIncrNoteInput->setTooltip (TRANS("After reaching this note, the channel is incremented and the note is reset to 0.")); @@ -145,8 +123,6 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) channelAutoIncrNoteInput->setTextBoxStyle (juce::Slider::TextBoxLeft, false, 56, 20); channelAutoIncrNoteInput->addListener (this); - channelAutoIncrNoteInput->setBounds (176, 264, 112, 24); - //[UserPreSize] @@ -205,11 +181,11 @@ SingleNoteAssign::SingleNoteAssign (const LumatoneEditorState& stateIn) //[Constructor] You can add your own custom stuff here.. - setNoteToggleButton->setToggleState(true, juce::NotificationType::sendNotification); - setChannelToggleButton->setToggleState(true, juce::NotificationType::sendNotification); - setColourToggleButton->setToggleState(true, juce::NotificationType::sendNotification); - keyTypeToggleButton->setToggleState(true, juce::NotificationType::sendNotification); - keyTypeCombo->setSelectedId(LumatoneKeyType::noteOnNoteOff); + 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); + keyTypeCombo->setSelectedId(LumatoneKeyType::noteOnNoteOff); //[/Constructor] } @@ -559,14 +535,6 @@ void SingleNoteAssign::sliderValueChanged (juce::Slider* sliderThatWasMoved) //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... -void SingleNoteAssign::lookAndFeelChanged() -{ - auto lookAndFeel = dynamic_cast(&getLookAndFeel()); - if (lookAndFeel) - { - lookAndFeel->setupTextEditor(*colourTextEditor); - } -} void SingleNoteAssign::colourChangedCallback(ColourSelectionBroadcaster* source, Colour newColour) { @@ -621,30 +589,6 @@ LumatoneAction* SingleNoteAssign::createEditAction(int setSelection, int keySele return editAction; } -void SingleNoteAssign::onSetData(LumatoneLayout& newData) -{ - // TODO: switch to palettes & active colour - //SortedSet usedColours = newData.getUsedColours(); - //for (int pos = 0; pos < usedColours.size(); pos++) - // colourSubwindow->addColourToBox(usedColours[pos]); -} - -void SingleNoteAssign::restoreStateFromPropertiesFile(PropertiesFile* propertiesFile) -{ - setNoteToggleButton->setToggleState( - propertiesFile->getBoolValue(LumatoneEditorProperty::SingleNoteNoteSetActive, true), - juce::NotificationType::sendNotification); - setChannelToggleButton->setToggleState( - propertiesFile->getBoolValue(LumatoneEditorProperty::SingleNoteChannelSetActive, true), - juce::NotificationType::sendNotification); - setColourToggleButton->setToggleState( - propertiesFile->getBoolValue(LumatoneEditorProperty::SingleNoteColourSetActive, true), - juce::NotificationType::sendNotification); - keyTypeToggleButton->setToggleState( - propertiesFile->getBoolValue(LumatoneEditorProperty::SingleNoteKeyTypeSetActive, true), - juce::NotificationType::sendNotification); -} - void SingleNoteAssign::saveStateToPropertiesFile(PropertiesFile* propertiesFile) { propertiesFile->setValue(LumatoneEditorProperty::SingleNoteNoteSetActive, setNoteToggleButton->getToggleState()); diff --git a/Source/SingleNoteAssign.h b/Source/SingleNoteAssign.h index 804efd3..bcf0e13 100644 --- a/Source/SingleNoteAssign.h +++ b/Source/SingleNoteAssign.h @@ -57,13 +57,11 @@ class SingleNoteAssign : public juce::Component, //============================================================================== //[UserMethods] -- You can add your own custom methods in this section. LumatoneAction* createEditAction(int setSelection, int keySelection); - void onSetData(LumatoneLayout& newData); + //void onSetData(LumatoneLayout& newData); - void restoreStateFromPropertiesFile(juce::PropertiesFile* propertiesFile); + //void restoreStateFromPropertiesFile(juce::PropertiesFile* propertiesFile); void saveStateToPropertiesFile(juce::PropertiesFile* propertiesFile); - void lookAndFeelChanged() override; - ColourViewComponent* getColourViewComponent() { return colourSubwindow.get(); } ColourTextEditor* getColourTextEditor() { return colourTextEditor.get(); }