diff --git a/Source/AllKeysOverview.cpp b/Source/AllKeysOverview.cpp index 54ec9ed3..1aa688ce 100644 --- a/Source/AllKeysOverview.cpp +++ b/Source/AllKeysOverview.cpp @@ -7,7 +7,7 @@ the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded and re-saved. - Created with Projucer version: 6.0.4 + Created with Projucer version: 6.0.5 ------------------------------------------------------------------------------ @@ -51,14 +51,17 @@ KeyMiniDisplayInsideAllKeysOverview::~KeyMiniDisplayInsideAllKeysOverview() void KeyMiniDisplayInsideAllKeysOverview::paint(Graphics& g) { jassert(getParentComponent() != nullptr); - bool isSelected = boardIndex == dynamic_cast(getParentComponent())->getCurrentSetSelection(); + bool boardIsSelected = boardIndex == dynamic_cast(getParentComponent())->getCurrentSetSelection(); Colour hexagonColour = findColour(TerpstraKeyEdit::backgroundColourId).overlaidWith(getKeyColour() - .withAlpha(isSelected ? TERPSTRASINGLEKEYCOLOURALPHA : TERPSTRASINGLEKEYCOLOURUNSELECTEDMINIALPHA)); + .withAlpha(boardIsSelected ? TERPSTRASINGLEKEYCOLOURALPHA : TERPSTRASINGLEKEYCOLOURUNSELECTEDMINIALPHA)); + // ToDo if highlighted: even different alpha? g.setColour(hexagonColour); g.fillPath(hexPath); - Colour lineColour = findColour(TerpstraKeyEdit::outlineColourId); + // Key highlighted or not: color and thickness of the line + float lineWidth = isHighlighted ? 1.5 : 1; + Colour lineColour = findColour(isHighlighted ? TerpstraKeyEdit::selectedKeyOutlineId : TerpstraKeyEdit::outlineColourId); g.setColour(lineColour); g.strokePath(hexPath, PathStrokeType(1)); } @@ -99,29 +102,61 @@ void KeyMiniDisplayInsideAllKeysOverview::mouseDown(const MouseEvent& e) dynamic_cast(getParentComponent()->getParentComponent())-> getOctaveBoardSelectorTab()->setCurrentTabIndex(boardIndex); - // ToDo NoteOn MIDI message (here or in parent component) + isHighlighted = true; + repaint(); + + // NoteOn MIDI message + auto keyData = getKeyData(); + if (keyData != nullptr && keyData->channelNumber > 0) + { + if (keyData->keyType == TerpstraKey::noteOnNoteOff) + { + // Send "note on" event + TerpstraSysExApplication::getApp().getMidiDriver().sendNoteOnMessage(keyData->noteNumber, keyData->channelNumber, 60); + } + // ToDo if keyType is "continuous controller": send controller event? + } } void KeyMiniDisplayInsideAllKeysOverview::mouseUp(const MouseEvent& e) { Component::mouseDown(e); - // ToDo NoteOff MIDI message (here or in parent component) -} + isHighlighted = false; + repaint(); + // NoteOff MIDI message + auto keyData = getKeyData(); + if (keyData != nullptr && keyData->channelNumber > 0) + { + if (keyData->keyType == TerpstraKey::noteOnNoteOff) + { + // Send "note off" event + TerpstraSysExApplication::getApp().getMidiDriver().sendNoteOffMessage(keyData->noteNumber, keyData->channelNumber, 60); + } + } +} -Colour KeyMiniDisplayInsideAllKeysOverview::getKeyColour() +const TerpstraKey* KeyMiniDisplayInsideAllKeysOverview::getKeyData() const { if (boardIndex >= 0 && boardIndex < NUMBEROFBOARDS && keyIndex >= 0 && keyIndex < TERPSTRABOARDSIZE) { jassert(getParentComponent() != nullptr); jassert(getParentComponent()->getParentComponent() != nullptr); - return Colour( - dynamic_cast(getParentComponent()->getParentComponent()) - ->getMappingInEdit().sets[boardIndex].theKeys[keyIndex].colour); + return &dynamic_cast(getParentComponent()->getParentComponent()) + ->getMappingInEdit().sets[boardIndex].theKeys[keyIndex]; } - return findColour(TerpstraKeyEdit::backgroundColourId); + return nullptr; +} + +Colour KeyMiniDisplayInsideAllKeysOverview::getKeyColour() const +{ + auto keyData = getKeyData(); + if ( keyData != nullptr) + return Colour(keyData->colour); + else + return findColour(TerpstraKeyEdit::backgroundColourId); } //[/MiscUserDefs] @@ -311,20 +346,6 @@ void AllKeysOverview::buttonClicked (juce::Button* buttonThatWasClicked) //[/UserbuttonClicked_Post] } -void AllKeysOverview::mouseDown (const juce::MouseEvent& e) -{ - //[UserCode_mouseDown] -- Add your code here... - // MIDI NoteOn message - here or in key component - //[/UserCode_mouseDown] -} - -void AllKeysOverview::mouseUp (const juce::MouseEvent& e) -{ - //[UserCode_mouseUp] -- Add your code here... - // MIDI NoteOff message - here or in key component - //[/UserCode_mouseUp] -} - //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... @@ -344,10 +365,6 @@ BEGIN_JUCER_METADATA parentClasses="public juce::Component" constructorParams="" variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="0" initialWidth="928" initialHeight="214"> - - - - getMappingInEdit(); - buttonAfterTouchActive->setToggleState(mappingInEdit.afterTouchActive, juce::NotificationType::sendNotification); - buttonLightOnKeyStrokes->setToggleState(mappingInEdit.lightOnKeyStrokes, juce::NotificationType::sendNotification); + buttonAfterTouchActive->setToggleState(mappingInEdit.afterTouchActive, juce::NotificationType::dontSendNotification); + buttonLightOnKeyStrokes->setToggleState(mappingInEdit.lightOnKeyStrokes, juce::NotificationType::dontSendNotification); - btnInvertFootCtrl->setToggleState(mappingInEdit.invertFootController, juce::NotificationType::sendNotification); - txtExprCtrlSensivity->setText(String(mappingInEdit.expressionControllerSensivity)); + btnInvertFootCtrl->setToggleState(mappingInEdit.invertFootController, juce::NotificationType::dontSendNotification); + txtExprCtrlSensivity->setText(String(mappingInEdit.expressionControllerSensivity), false); } //[/MiscUserCode] diff --git a/Source/Main.cpp b/Source/Main.cpp index 428a00fe..e0b31bf7 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -140,7 +140,7 @@ void TerpstraSysExApplication::anotherInstanceStarted(const String& commandLine) bool TerpstraSysExApplication::openSysExMapping() { - FileChooser chooser("Open a Lumatone key mapping", recentFiles.getFile(0).getParentDirectory(), "*.lmt"); + FileChooser chooser("Open a Lumatone key mapping", recentFiles.getFile(0).getParentDirectory(), "*.ltn"); if (chooser.browseForFileToOpen()) { currentFile = chooser.getResult(); @@ -160,7 +160,7 @@ bool TerpstraSysExApplication::saveSysExMapping() bool TerpstraSysExApplication::saveSysExMappingAs() { - FileChooser chooser("Lumatone Key Mapping Files", recentFiles.getFile(0).getParentDirectory(), "*.lmt"); + FileChooser chooser("Lumatone Key Mapping Files", recentFiles.getFile(0).getParentDirectory(), "*.ltn"); if (chooser.browseForFileToSave(true)) { currentFile = chooser.getResult(); @@ -320,15 +320,15 @@ bool TerpstraSysExApplication::openFromCurrentFile() ((MainContentComponent*)(mainWindow->getContentComponent()))->setData(keyMapping); - // Mark file as unchanged - setHasChangesToSave(false); - // Window title updateMainTitle(); - // Send configuraiton to controller, if connected + // Send configuration to controller, if connected sendCurrentMappingToDevice(); + // Mark file as unchanged + setHasChangesToSave(false); + // Add file to recent files list recentFiles.addFile(currentFile); diff --git a/Source/TerpstraMidiDriver.cpp b/Source/TerpstraMidiDriver.cpp index 40d3adf9..7a8ecc9d 100644 --- a/Source/TerpstraMidiDriver.cpp +++ b/Source/TerpstraMidiDriver.cpp @@ -411,6 +411,7 @@ bool TerpstraMidiDriver::messageIsVelocityIntervalConfigReceptionMessage(const M void TerpstraMidiDriver::sendMessageWithAcknowledge(const MidiMessage& message) { // If there is no MIDI input port active: just send, without expecting acknowledge + // ToDo Or do nothing? if ( lastInputCallback == nullptr) { sendMessageNow(message); diff --git a/TerpstraSysEx.jucer b/TerpstraSysEx.jucer index 1eded300..9d11138c 100644 --- a/TerpstraSysEx.jucer +++ b/TerpstraSysEx.jucer @@ -1,6 +1,6 @@ -