From f26a402e0ecb32a06d1654a4d31fca15dfcf02e1 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 20 Mar 2018 02:15:15 -0400 Subject: [PATCH] MIDI-4: Add context menu to select polyphony mode --- src/Core/QuadMIDIToCVInterface.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Core/QuadMIDIToCVInterface.cpp b/src/Core/QuadMIDIToCVInterface.cpp index 48e13f09..dca10b66 100644 --- a/src/Core/QuadMIDIToCVInterface.cpp +++ b/src/Core/QuadMIDIToCVInterface.cpp @@ -248,6 +248,28 @@ struct QuadMIDIToCVInterfaceWidget : ModuleWidget { midiWidget->midiIO = &module->midiInput; addChild(midiWidget); } + + void appendContextMenu(Menu *menu) override { + QuadMIDIToCVInterface *module = dynamic_cast(this->module); + + struct PolyphonyItem : MenuItem { + QuadMIDIToCVInterface *module; + QuadMIDIToCVInterface::PolyMode polyMode; + void onAction(EventAction &e) override { + module->polyMode = polyMode; + } + }; + + menu->addChild(MenuEntry::create()); + menu->addChild(MenuLabel::create("Polyphony mode")); + std::vector polyModeNames = {"Rotate", "Reset", "Reassign", "Unison"}; + for (int i = 0; i < QuadMIDIToCVInterface::NUM_MODES; i++) { + PolyphonyItem *item = MenuItem::create(polyModeNames[i], CHECKMARK(module->polyMode == i)); + item->module = module; + item->polyMode = (QuadMIDIToCVInterface::PolyMode) i; + menu->addChild(item); + } + } };