From a18eac9a0c7dd7fb46e8a35566a86a72adc45ebc Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 3 Nov 2017 21:39:28 +0100 Subject: [PATCH] Update midi modules for refactor of event framework (8e251c0ddbfc1f4a2e03a6123d8eda42218b76fe) --- src/core/MidiCCToCV.cpp | 20 ++++++++++++-------- src/core/MidiClockToCV.cpp | 4 ++-- src/core/MidiIO.cpp | 8 ++++---- src/core/MidiIO.hpp | 8 ++++---- src/core/MidiTriggerToCV.cpp | 19 +++++++++++-------- src/core/QuadMidiToCV.cpp | 4 ++-- 6 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/core/MidiCCToCV.cpp b/src/core/MidiCCToCV.cpp index 781277d1..3d98267f 100644 --- a/src/core/MidiCCToCV.cpp +++ b/src/core/MidiCCToCV.cpp @@ -169,11 +169,11 @@ struct CCTextField : TextField { void draw(NVGcontext *vg); - void onMouseDownOpaque(int button); + void onMouseDown(EventMouseDown &e); - void onMouseUpOpaque(int button); + void onMouseUp(EventMouseUp &e); - void onMouseLeave(); + void onMouseLeave(EventMouseLeave &e); int outNum; @@ -196,21 +196,25 @@ void CCTextField::draw(NVGcontext *vg) { TextField::draw(vg); } -void CCTextField::onMouseUpOpaque(int button) { - if (button == 1) { +void CCTextField::onMouseUp(EventMouseUp &e) { + if (e.button == 1) { module->cc[outNum].numSelected = false; + e.consumed = true; } + } -void CCTextField::onMouseDownOpaque(int button) { - if (button == 1) { +void CCTextField::onMouseDown(EventMouseDown &e) { + if (e.button == 1) { module->cc[outNum].numSelected = true; + e.consumed = true; } } -void CCTextField::onMouseLeave() { +void CCTextField::onMouseLeave(EventMouseLeave &e) { module->cc[outNum].numSelected = false; + e.consumed = true; } diff --git a/src/core/MidiClockToCV.cpp b/src/core/MidiClockToCV.cpp index 2ee63d37..6d9f1a6b 100644 --- a/src/core/MidiClockToCV.cpp +++ b/src/core/MidiClockToCV.cpp @@ -210,7 +210,7 @@ struct ClockRatioItem : MenuItem { int ratio; int *clockRatio; - void onAction() { + void onAction(EventAction &e) { *clockRatio = ratio; } }; @@ -226,7 +226,7 @@ struct ClockRatioChoice : ChoiceButton { const std::vector ratioNames_short = {"1:4 ratio", "1:3 ratio", "1:2 ratio", "2:3 ratio", "1:1 ratio", "4:3", "2:1 ratio", "4:1 ratio", "8:1 ratio"}; - void onAction() { + void onAction(EventAction &e) { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round(); menu->box.size.x = box.size.x; diff --git a/src/core/MidiIO.cpp b/src/core/MidiIO.cpp index 144b042e..e89e05e1 100644 --- a/src/core/MidiIO.cpp +++ b/src/core/MidiIO.cpp @@ -195,11 +195,11 @@ void MidiIO::close() { } -void MidiItem::onAction() { +void MidiItem::onAction(EventAction &e) { midiModule->openDevice(text); } -void MidiChoice::onAction() { +void MidiChoice::onAction(EventAction &e) { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round(); menu->box.size.x = box.size.x; @@ -229,12 +229,12 @@ void MidiChoice::step() { text = ellipsize(name, 15); } -void ChannelItem::onAction() { +void ChannelItem::onAction(EventAction &e) { midiModule->resetMidi(); // reset Midi values midiModule->setChannel(channel); } -void ChannelChoice::onAction() { +void ChannelChoice::onAction(EventAction &e) { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round(); menu->box.size.x = box.size.x; diff --git a/src/core/MidiIO.hpp b/src/core/MidiIO.hpp index 27c4304f..082180bc 100644 --- a/src/core/MidiIO.hpp +++ b/src/core/MidiIO.hpp @@ -174,13 +174,13 @@ struct TransitionSmoother { struct MidiItem : MenuItem { MidiIO *midiModule; - void onAction(); + void onAction(EventAction &e); }; struct MidiChoice : ChoiceButton { MidiIO *midiModule; - void onAction(); + void onAction(EventAction &e); void step(); }; @@ -189,13 +189,13 @@ struct ChannelItem : MenuItem { MidiIO *midiModule; int channel; - void onAction(); + void onAction(EventAction &e); }; struct ChannelChoice : ChoiceButton { MidiIO *midiModule; - void onAction(); + void onAction(EventAction &e); void step(); }; diff --git a/src/core/MidiTriggerToCV.cpp b/src/core/MidiTriggerToCV.cpp index b90aa8b1..d69bc552 100644 --- a/src/core/MidiTriggerToCV.cpp +++ b/src/core/MidiTriggerToCV.cpp @@ -135,11 +135,11 @@ struct TriggerTextField : TextField { void draw(NVGcontext *vg); - void onMouseDownOpaque(int button); + void onMouseDown(EventMouseDown &e); - void onMouseUpOpaque(int button); + void onMouseUp(EventMouseUp &e); - void onMouseLeave(); + void onMouseLeave(EventMouseLeave &e); int outNum; MIDITriggerToCVInterface *module; @@ -180,21 +180,24 @@ void TriggerTextField::onTextChange() { }; } -void TriggerTextField::onMouseUpOpaque(int button) { - if (button == 1) { +void TriggerTextField::onMouseUp(EventMouseUp &e) { + if (e.button == 1) { module->trigger[outNum].onFocus = false; + e.consumed = true; } } -void TriggerTextField::onMouseDownOpaque(int button) { - if (button == 1) { +void TriggerTextField::onMouseDown(EventMouseDown &e) { + if (e.button == 1) { module->trigger[outNum].onFocus = true; + e.consumed = true; } } -void TriggerTextField::onMouseLeave() { +void TriggerTextField::onMouseLeave(EventMouseLeave &e) { module->trigger[outNum].onFocus = false; + e.consumed = true; } MIDITriggerToCVWidget::MIDITriggerToCVWidget() { diff --git a/src/core/QuadMidiToCV.cpp b/src/core/QuadMidiToCV.cpp index 39c5787e..6e5162f1 100644 --- a/src/core/QuadMidiToCV.cpp +++ b/src/core/QuadMidiToCV.cpp @@ -254,7 +254,7 @@ struct ModeItem : MenuItem { int mode; QuadMIDIToCVInterface *module; - void onAction() { + void onAction(EventAction &e) { module->setMode(mode); } }; @@ -264,7 +264,7 @@ struct ModeChoice : ChoiceButton { const std::vector modeNames = {"ROTATE", "RESET", "REASSIGN"}; - void onAction() { + void onAction(EventAction &e) { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsoluteOffset(Vec(0, box.size.y)).round(); menu->box.size.x = box.size.x;