| @@ -300,7 +300,7 @@ template <typename T> | |||||
| ui::MenuItem* createIndexPtrSubmenuItem(std::string text, std::vector<std::string> labels, T* ptr) { | ui::MenuItem* createIndexPtrSubmenuItem(std::string text, std::vector<std::string> labels, T* ptr) { | ||||
| return createIndexSubmenuItem(text, labels, | return createIndexSubmenuItem(text, labels, | ||||
| [=]() {return *ptr;}, | [=]() {return *ptr;}, | ||||
| [=](T index) {*ptr = index;} | |||||
| [=](size_t index) {*ptr = T(index);} | |||||
| ); | ); | ||||
| } | } | ||||
| @@ -560,31 +560,12 @@ struct AudioInterfaceWidget : ModuleWidget { | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| struct PrimaryModuleItem : MenuItem { | |||||
| TAudioInterface* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->setPrimary(); | |||||
| } | |||||
| }; | |||||
| PrimaryModuleItem* primaryModuleItem = new PrimaryModuleItem; | |||||
| primaryModuleItem->text = "Primary audio module"; | |||||
| primaryModuleItem->rightText = CHECKMARK(module->isPrimary()); | |||||
| primaryModuleItem->module = module; | |||||
| menu->addChild(primaryModuleItem); | |||||
| struct DCFilterItem : MenuItem { | |||||
| TAudioInterface* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->dcFilterEnabled ^= true; | |||||
| } | |||||
| }; | |||||
| menu->addChild(createCheckMenuItem("Primary audio module", | |||||
| [=]() {return module->isPrimary();}, | |||||
| [=]() {module->setPrimary();} | |||||
| )); | |||||
| DCFilterItem* dcFilterItem = new DCFilterItem; | |||||
| dcFilterItem->text = "DC blocker"; | |||||
| dcFilterItem->rightText = CHECKMARK(module->dcFilterEnabled); | |||||
| dcFilterItem->module = module; | |||||
| menu->addChild(dcFilterItem); | |||||
| menu->addChild(createBoolPtrMenuItem("DC blocker", &module->dcFilterEnabled)); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -162,22 +162,6 @@ struct CV_Gate : Module { | |||||
| }; | }; | ||||
| struct CV_GateVelocityItem : MenuItem { | |||||
| CV_Gate* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->velocityMode ^= true; | |||||
| } | |||||
| }; | |||||
| struct CV_GatePanicItem : MenuItem { | |||||
| CV_Gate* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->midiOutput.panic(); | |||||
| } | |||||
| }; | |||||
| struct CV_GateWidget : ModuleWidget { | struct CV_GateWidget : ModuleWidget { | ||||
| CV_GateWidget(CV_Gate* module) { | CV_GateWidget(CV_Gate* module) { | ||||
| setModule(module); | setModule(module); | ||||
| @@ -217,14 +201,12 @@ struct CV_GateWidget : ModuleWidget { | |||||
| CV_Gate* module = dynamic_cast<CV_Gate*>(this->module); | CV_Gate* module = dynamic_cast<CV_Gate*>(this->module); | ||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| CV_GateVelocityItem* velocityItem = createMenuItem<CV_GateVelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
| velocityItem->module = module; | |||||
| menu->addChild(velocityItem); | |||||
| CV_GatePanicItem* panicItem = new CV_GatePanicItem; | |||||
| panicItem->text = "Panic"; | |||||
| panicItem->module = module; | |||||
| menu->addChild(panicItem); | |||||
| menu->addChild(createBoolPtrMenuItem("Velocity mode", &module->velocityMode)); | |||||
| menu->addChild(createMenuItem("Panic", "", | |||||
| [=]() {module->midiOutput.panic();} | |||||
| )); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -180,10 +180,9 @@ struct CV_MIDIWidget : ModuleWidget { | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| CV_MIDIPanicItem* panicItem = new CV_MIDIPanicItem; | |||||
| panicItem->text = "Panic"; | |||||
| panicItem->module = module; | |||||
| menu->addChild(panicItem); | |||||
| menu->addChild(createMenuItem("Panic", "", | |||||
| [=]() {module->midiOutput.panic();} | |||||
| )); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -255,41 +255,11 @@ struct MIDI_CCWidget : ModuleWidget { | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| struct SmoothItem : MenuItem { | |||||
| MIDI_CC* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->smooth ^= true; | |||||
| } | |||||
| }; | |||||
| SmoothItem* smoothItem = new SmoothItem; | |||||
| smoothItem->text = "Smooth CC"; | |||||
| smoothItem->rightText = CHECKMARK(module->smooth); | |||||
| smoothItem->module = module; | |||||
| menu->addChild(smoothItem); | |||||
| struct MpeModeItem : MenuItem { | |||||
| MIDI_CC* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->mpeMode ^= true; | |||||
| } | |||||
| }; | |||||
| MpeModeItem* mpeModeItem = new MpeModeItem; | |||||
| mpeModeItem->text = "MPE mode"; | |||||
| mpeModeItem->rightText = CHECKMARK(module->mpeMode); | |||||
| mpeModeItem->module = module; | |||||
| menu->addChild(mpeModeItem); | |||||
| struct LsbModeItem : MenuItem { | |||||
| MIDI_CC* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->lsbMode ^= true; | |||||
| } | |||||
| }; | |||||
| LsbModeItem* lsbItem = new LsbModeItem; | |||||
| lsbItem->text = "CC 0-31 controls are 14-bit"; | |||||
| lsbItem->rightText = CHECKMARK(module->lsbMode); | |||||
| lsbItem->module = module; | |||||
| menu->addChild(lsbItem); | |||||
| menu->addChild(createBoolPtrMenuItem("Smooth CC", &module->smooth)); | |||||
| menu->addChild(createBoolPtrMenuItem("MPE mode", &module->mpeMode)); | |||||
| menu->addChild(createBoolPtrMenuItem("CC 0-31 controls are 14-bit", &module->lsbMode)); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -505,38 +505,19 @@ struct MIDI_CVWidget : ModuleWidget { | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| struct SmoothItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->smooth ^= true; | |||||
| } | |||||
| }; | |||||
| SmoothItem* smoothItem = new SmoothItem; | |||||
| smoothItem->text = "Smooth pitch/mod wheel"; | |||||
| smoothItem->rightText = CHECKMARK(module->smooth); | |||||
| smoothItem->module = module; | |||||
| menu->addChild(smoothItem); | |||||
| menu->addChild(createBoolPtrMenuItem("Smooth pitch/mod wheel", &module->smooth)); | |||||
| struct ClockDivisionValueItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| int clockDivision; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->clockDivision = clockDivision; | |||||
| } | |||||
| }; | |||||
| static const std::vector<int> clockDivisions = {24 * 4, 24 * 2, 24, 24 / 2, 24 / 4, 24 / 8, 2, 1}; | |||||
| static const std::vector<std::string> clockDivisionLabels = {"Whole", "Half", "Quarter", "8th", "16th", "32nd", "12 PPQN", "24 PPQN"}; | |||||
| struct ClockDivisionItem : MenuItem { | struct ClockDivisionItem : MenuItem { | ||||
| MIDI_CV* module; | MIDI_CV* module; | ||||
| Menu* createChildMenu() override { | Menu* createChildMenu() override { | ||||
| Menu* menu = new Menu; | Menu* menu = new Menu; | ||||
| std::vector<int> divisions = {24 * 4, 24 * 2, 24, 24 / 2, 24 / 4, 24 / 8, 2, 1}; | |||||
| std::vector<std::string> divisionNames = {"Whole", "Half", "Quarter", "8th", "16th", "32nd", "12 PPQN", "24 PPQN"}; | |||||
| for (size_t i = 0; i < divisions.size(); i++) { | |||||
| ClockDivisionValueItem* item = new ClockDivisionValueItem; | |||||
| item->text = divisionNames[i]; | |||||
| item->rightText = CHECKMARK(module->clockDivision == divisions[i]); | |||||
| item->module = module; | |||||
| item->clockDivision = divisions[i]; | |||||
| menu->addChild(item); | |||||
| for (size_t i = 0; i < clockDivisions.size(); i++) { | |||||
| menu->addChild(createCheckMenuItem(clockDivisionLabels[i], | |||||
| [=]() {return module->clockDivision == clockDivisions[i];}, | |||||
| [=]() {module->clockDivision = clockDivisions[i];} | |||||
| )); | |||||
| } | } | ||||
| return menu; | return menu; | ||||
| } | } | ||||
| @@ -547,82 +528,35 @@ struct MIDI_CVWidget : ModuleWidget { | |||||
| clockDivisionItem->module = module; | clockDivisionItem->module = module; | ||||
| menu->addChild(clockDivisionItem); | menu->addChild(clockDivisionItem); | ||||
| struct ChannelValueItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| int channels; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->setChannels(channels); | |||||
| } | |||||
| }; | |||||
| struct ChannelItem : MenuItem { | struct ChannelItem : MenuItem { | ||||
| MIDI_CV* module; | MIDI_CV* module; | ||||
| Menu* createChildMenu() override { | Menu* createChildMenu() override { | ||||
| Menu* menu = new Menu; | Menu* menu = new Menu; | ||||
| for (int channels = 1; channels <= 16; channels++) { | |||||
| ChannelValueItem* item = new ChannelValueItem; | |||||
| if (channels == 1) | |||||
| item->text = "Monophonic"; | |||||
| else | |||||
| item->text = string::f("%d", channels); | |||||
| item->rightText = CHECKMARK(module->channels == channels); | |||||
| item->module = module; | |||||
| item->channels = channels; | |||||
| menu->addChild(item); | |||||
| for (int c = 1; c <= 16; c++) { | |||||
| menu->addChild(createCheckMenuItem((c == 1) ? "Monophonic" : string::f("%d", c), | |||||
| [=]() {return module->channels == c;}, | |||||
| [=]() {module->setChannels(c);} | |||||
| )); | |||||
| } | } | ||||
| return menu; | return menu; | ||||
| } | } | ||||
| }; | }; | ||||
| ChannelItem* channelItem = new ChannelItem; | ChannelItem* channelItem = new ChannelItem; | ||||
| channelItem->text = "Polyphony channels"; | channelItem->text = "Polyphony channels"; | ||||
| channelItem->rightText = string::f("%d", module->channels) + " " + RIGHT_ARROW; | |||||
| channelItem->rightText = string::f("%d", module->channels) + " " + RIGHT_ARROW; | |||||
| channelItem->module = module; | channelItem->module = module; | ||||
| menu->addChild(channelItem); | menu->addChild(channelItem); | ||||
| struct PolyModeValueItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| MIDI_CV::PolyMode polyMode; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->setPolyMode(polyMode); | |||||
| } | |||||
| }; | |||||
| struct PolyModeItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| Menu* createChildMenu() override { | |||||
| Menu* menu = new Menu; | |||||
| std::vector<std::string> polyModeNames = { | |||||
| "Rotate", | |||||
| "Reuse", | |||||
| "Reset", | |||||
| "MPE", | |||||
| }; | |||||
| for (int i = 0; i < MIDI_CV::NUM_POLY_MODES; i++) { | |||||
| MIDI_CV::PolyMode polyMode = (MIDI_CV::PolyMode) i; | |||||
| PolyModeValueItem* item = new PolyModeValueItem; | |||||
| item->text = polyModeNames[i]; | |||||
| item->rightText = CHECKMARK(module->polyMode == polyMode); | |||||
| item->module = module; | |||||
| item->polyMode = polyMode; | |||||
| menu->addChild(item); | |||||
| } | |||||
| return menu; | |||||
| } | |||||
| }; | |||||
| PolyModeItem* polyModeItem = new PolyModeItem; | |||||
| polyModeItem->text = "Polyphony mode"; | |||||
| polyModeItem->rightText = RIGHT_ARROW; | |||||
| polyModeItem->module = module; | |||||
| menu->addChild(polyModeItem); | |||||
| menu->addChild(createIndexPtrSubmenuItem("Polyphony mode", { | |||||
| "Rotate", | |||||
| "Reuse", | |||||
| "Reset", | |||||
| "MPE", | |||||
| }, &module->polyMode)); | |||||
| struct PanicItem : MenuItem { | |||||
| MIDI_CV* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->panic(); | |||||
| } | |||||
| }; | |||||
| PanicItem* panicItem = new PanicItem; | |||||
| panicItem->text = "Panic"; | |||||
| panicItem->module = module; | |||||
| menu->addChild(panicItem); | |||||
| menu->addChild(createMenuItem("Panic", "", | |||||
| [=]() {module->panic();} | |||||
| )); | |||||
| // Example of using appendMidiMenu() | // Example of using appendMidiMenu() | ||||
| // menu->addChild(new MenuSeparator); | // menu->addChild(new MenuSeparator); | ||||
| @@ -221,39 +221,15 @@ struct MIDI_GateWidget : ModuleWidget { | |||||
| void appendContextMenu(Menu* menu) override { | void appendContextMenu(Menu* menu) override { | ||||
| MIDI_Gate* module = dynamic_cast<MIDI_Gate*>(this->module); | MIDI_Gate* module = dynamic_cast<MIDI_Gate*>(this->module); | ||||
| struct VelocityItem : MenuItem { | |||||
| MIDI_Gate* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->velocityMode ^= true; | |||||
| } | |||||
| }; | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| VelocityItem* velocityItem = createMenuItem<VelocityItem>("Velocity mode", CHECKMARK(module->velocityMode)); | |||||
| velocityItem->module = module; | |||||
| menu->addChild(velocityItem); | |||||
| struct MpeModeItem : MenuItem { | |||||
| MIDI_Gate* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->mpeMode ^= true; | |||||
| } | |||||
| }; | |||||
| MpeModeItem* mpeModeItem = new MpeModeItem; | |||||
| mpeModeItem->text = "MPE mode"; | |||||
| mpeModeItem->rightText = CHECKMARK(module->mpeMode); | |||||
| mpeModeItem->module = module; | |||||
| menu->addChild(mpeModeItem); | |||||
| struct PanicItem : MenuItem { | |||||
| MIDI_Gate* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->panic(); | |||||
| } | |||||
| }; | |||||
| PanicItem* panicItem = new PanicItem; | |||||
| panicItem->text = "Panic"; | |||||
| panicItem->module = module; | |||||
| menu->addChild(panicItem); | |||||
| menu->addChild(createBoolPtrMenuItem("Velocity mode", &module->velocityMode)); | |||||
| menu->addChild(createBoolPtrMenuItem("MPE mode", &module->mpeMode)); | |||||
| menu->addChild(createMenuItem("Panic", "", | |||||
| [=]() {module->panic();} | |||||
| )); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -496,18 +496,7 @@ struct MIDI_MapWidget : ModuleWidget { | |||||
| menu->addChild(new MenuSeparator); | menu->addChild(new MenuSeparator); | ||||
| struct SmoothItem : MenuItem { | |||||
| MIDI_Map* module; | |||||
| void onAction(const ActionEvent& e) override { | |||||
| module->smooth ^= true; | |||||
| } | |||||
| }; | |||||
| SmoothItem* smoothItem = new SmoothItem; | |||||
| smoothItem->text = "Smooth CC"; | |||||
| smoothItem->rightText = CHECKMARK(module->smooth); | |||||
| smoothItem->module = module; | |||||
| menu->addChild(smoothItem); | |||||
| menu->addChild(createBoolPtrMenuItem("Smooth CC", &module->smooth)); | |||||
| } | } | ||||
| }; | }; | ||||