From 0b0170f4635df7239a5fb2ef64d630cc337c3d3b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 8 Nov 2021 13:10:55 -0500 Subject: [PATCH] Rename AudioWidget to AudioDisplay, MidiWidget to MidiDisplay. Move Audio/MidiChoices to header file. Move AudioDeviceMenuChoice to core::Audio and rename to Audio2Display. --- include/app/AudioDisplay.hpp | 74 +++++++ include/app/AudioWidget.hpp | 48 ----- .../app/{MidiWidget.hpp => MidiDisplay.hpp} | 31 ++- include/componentlibrary.hpp | 4 +- include/rack.hpp | 4 +- src/app/{AudioWidget.cpp => AudioDisplay.cpp} | 189 ++++++++---------- src/app/{MidiWidget.cpp => MidiDisplay.cpp} | 84 ++++---- src/core/Audio.cpp | 48 +++-- src/core/CV_MIDI.cpp | 8 +- src/core/CV_MIDICC.cpp | 12 +- src/core/Gate_MIDI.cpp | 12 +- src/core/MIDICC_CV.cpp | 12 +- src/core/MIDIMap.cpp | 14 +- src/core/MIDI_CV.cpp | 8 +- src/core/MIDI_Gate.cpp | 12 +- src/core/plugin.hpp | 2 +- 16 files changed, 302 insertions(+), 260 deletions(-) create mode 100644 include/app/AudioDisplay.hpp delete mode 100644 include/app/AudioWidget.hpp rename include/app/{MidiWidget.hpp => MidiDisplay.hpp} (52%) rename src/app/{AudioWidget.cpp => AudioDisplay.cpp} (74%) rename src/app/{MidiWidget.cpp => MidiDisplay.cpp} (78%) diff --git a/include/app/AudioDisplay.hpp b/include/app/AudioDisplay.hpp new file mode 100644 index 00000000..e00cef49 --- /dev/null +++ b/include/app/AudioDisplay.hpp @@ -0,0 +1,74 @@ +#pragma once +#include +#include +#include +#include +#include + + +namespace rack { +namespace app { + + +struct AudioDriverChoice : LedDisplayChoice { + audio::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct AudioDeviceChoice : LedDisplayChoice { + audio::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct AudioSampleRateChoice : LedDisplayChoice { + audio::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct AudioBlockSizeChoice : LedDisplayChoice { + audio::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct AudioDeviceMenuChoice : AudioDeviceChoice { + void onAction(const ActionEvent& e) override; +}; + + +/** Designed for Audio-8 and Audio-16 module. */ +struct AudioDisplay : LedDisplay { + AudioDriverChoice* driverChoice; + LedDisplaySeparator* driverSeparator; + AudioDeviceChoice* deviceChoice; + LedDisplaySeparator* deviceSeparator; + AudioSampleRateChoice* sampleRateChoice; + LedDisplaySeparator* sampleRateSeparator; + AudioBlockSizeChoice* bufferSizeChoice; + void setAudioPort(audio::Port* port); +}; + + +/** A virtual audio port graphic that displays an audio menu when clicked. */ +struct AudioButton : SvgButton { + audio::Port* port; + void setAudioPort(audio::Port* port); + void onAction(const ActionEvent& e) override; +}; + + +/** Appends menu items to the given menu with driver, device, etc. +Useful alternative to putting an AudioDisplay on your module's panel. +*/ +void appendAudioMenu(ui::Menu* menu, audio::Port* port); + + +} // namespace app +} // namespace rack diff --git a/include/app/AudioWidget.hpp b/include/app/AudioWidget.hpp deleted file mode 100644 index 6bb2fdf4..00000000 --- a/include/app/AudioWidget.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - - -namespace rack { -namespace app { - - -/** Designed for Audio-8 and Audio-16 module. */ -struct AudioWidget : LedDisplay { - LedDisplayChoice* driverChoice; - LedDisplaySeparator* driverSeparator; - LedDisplayChoice* deviceChoice; - LedDisplaySeparator* deviceSeparator; - LedDisplayChoice* sampleRateChoice; - LedDisplaySeparator* sampleRateSeparator; - LedDisplayChoice* bufferSizeChoice; - void setAudioPort(audio::Port* port); -}; - - -/** Designed for Audio-2 module. */ -struct AudioDeviceWidget : LedDisplay { - LedDisplayChoice* deviceChoice; - void setAudioPort(audio::Port* port); -}; - - -/** A virtual audio port graphic that displays an audio menu when clicked. */ -struct AudioButton : SvgButton { - audio::Port* port; - void setAudioPort(audio::Port* port); - void onAction(const ActionEvent& e) override; -}; - - -/** Appends menu items to the given menu with driver, device, etc. -Useful alternative to putting an AudioWidget on your module's panel. -*/ -void appendAudioMenu(ui::Menu* menu, audio::Port* port); - - -} // namespace app -} // namespace rack diff --git a/include/app/MidiWidget.hpp b/include/app/MidiDisplay.hpp similarity index 52% rename from include/app/MidiWidget.hpp rename to include/app/MidiDisplay.hpp index 90b572fc..16a69d04 100644 --- a/include/app/MidiWidget.hpp +++ b/include/app/MidiDisplay.hpp @@ -10,12 +10,33 @@ namespace rack { namespace app { -struct MidiWidget : LedDisplay { - LedDisplayChoice* driverChoice; +struct MidiDriverChoice : LedDisplayChoice { + midi::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct MidiDeviceChoice : LedDisplayChoice { + midi::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct MidiChannelChoice : LedDisplayChoice { + midi::Port* port; + void onAction(const ActionEvent& e) override; + void step() override; +}; + + +struct MidiDisplay : LedDisplay { + MidiDriverChoice* driverChoice; LedDisplaySeparator* driverSeparator; - LedDisplayChoice* deviceChoice; + MidiDeviceChoice* deviceChoice; LedDisplaySeparator* deviceSeparator; - LedDisplayChoice* channelChoice; + MidiChannelChoice* channelChoice; void setMidiPort(midi::Port* port); }; @@ -29,7 +50,7 @@ struct MidiButton : SvgButton { /** Appends menu items to the given menu with driver, device, etc. -Useful alternative to putting a MidiWidget on your module's panel. +Useful alternative to putting a MidiDisplay on your module's panel. */ void appendMidiMenu(ui::Menu* menu, midi::Port* port); diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 264d3405..4c612cba 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include +#include #include diff --git a/include/rack.hpp b/include/rack.hpp index 425ed246..5490291d 100644 --- a/include/rack.hpp +++ b/include/rack.hpp @@ -68,9 +68,9 @@ Directly including Rack headers other than rack.hpp in your plugin is unsupporte #include #include -#include +#include #include -#include +#include #include #include #include diff --git a/src/app/AudioWidget.cpp b/src/app/AudioDisplay.cpp similarity index 74% rename from src/app/AudioWidget.cpp rename to src/app/AudioDisplay.cpp index ec43b56c..8fc3f484 100644 --- a/src/app/AudioWidget.cpp +++ b/src/app/AudioDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -47,29 +47,27 @@ static void appendAudioDriverMenu(ui::Menu* menu, audio::Port* port) { } } -struct AudioDriverChoice : LedDisplayChoice { - audio::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("Audio driver")); - appendAudioDriverMenu(menu, port); +void AudioDriverChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("Audio driver")); + appendAudioDriverMenu(menu, port); +} + +void AudioDriverChoice::step() { + text = ""; + if (box.size.x >= 200.0) + text += "Driver: "; + audio::Driver* driver = port ? port->getDriver() : NULL; + std::string driverName = driver ? driver->getName() : ""; + if (driverName != "") { + text += driverName; + color.a = 1.0; } - void step() override { - text = ""; - if (box.size.x >= 200.0) - text += "Driver: "; - audio::Driver* driver = port ? port->getDriver() : NULL; - std::string driverName = driver ? driver->getName() : ""; - if (driverName != "") { - text += driverName; - color.a = 1.0; - } - else { - text += "(No driver)"; - color.a = 0.5; - } + else { + text += "(No driver)"; + color.a = 0.5; } -}; +} struct AudioDriverItem : ui::MenuItem { audio::Port* port; @@ -132,35 +130,32 @@ static void appendAudioDeviceMenu(ui::Menu* menu, audio::Port* port) { } } -struct AudioDeviceChoice : LedDisplayChoice { - audio::Port* port; +void AudioDeviceChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("Audio device")); + appendAudioDeviceMenu(menu, port); +} - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("Audio device")); - appendAudioDeviceMenu(menu, port); +void AudioDeviceChoice::step() { + text = ""; + if (box.size.x >= 200.0) + text += "Device: "; + std::string detail = ""; + if (port && port->getDevice()) + detail = getDetailTemplate(port->getDevice()->getName(), port->getNumInputs(), port->inputOffset, port->getNumOutputs(), port->outputOffset); + + if (detail != "") { + text += detail; + color.a = 1.0; } - void step() override { - text = ""; - if (box.size.x >= 200.0) - text += "Device: "; - std::string detail = ""; - if (port && port->getDevice()) - detail = getDetailTemplate(port->getDevice()->getName(), port->getNumInputs(), port->inputOffset, port->getNumOutputs(), port->outputOffset); - - if (detail != "") { - text += detail; - color.a = 1.0; - } - else { - if (box.size.x >= 80.0) - text += "(No device)"; - else - text += "No device"; - color.a = 0.5; - } + else { + if (box.size.x >= 80.0) + text += "(No device)"; + else + text += "No device"; + color.a = 0.5; } -}; +} struct AudioDeviceItem : ui::MenuItem { audio::Port* port; @@ -203,29 +198,27 @@ static void appendAudioSampleRateMenu(ui::Menu* menu, audio::Port* port) { } } -struct AudioSampleRateChoice : LedDisplayChoice { - audio::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("Sample rate")); - appendAudioSampleRateMenu(menu, port); +void AudioSampleRateChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("Sample rate")); + appendAudioSampleRateMenu(menu, port); +} + +void AudioSampleRateChoice::step() { + text = ""; + if (box.size.x >= 100.0) + text += "Rate: "; + float sampleRate = port ? port->getSampleRate() : 0; + if (sampleRate > 0) { + text += string::f("%g", sampleRate / 1000.f); + color.a = 1.0; } - void step() override { - text = ""; - if (box.size.x >= 100.0) - text += "Rate: "; - float sampleRate = port ? port->getSampleRate() : 0; - if (sampleRate > 0) { - text += string::f("%g", sampleRate / 1000.f); - color.a = 1.0; - } - else { - text += "---"; - color.a = 0.5; - } - text += " kHz"; + else { + text += "---"; + color.a = 0.5; } -}; + text += " kHz"; +} struct AudioSampleRateItem : ui::MenuItem { audio::Port* port; @@ -269,28 +262,26 @@ static void appendAudioBlockSizeMenu(ui::Menu* menu, audio::Port* port) { } } -struct AudioBlockSizeChoice : LedDisplayChoice { - audio::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("Block size")); - appendAudioBlockSizeMenu(menu, port); +void AudioBlockSizeChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("Block size")); + appendAudioBlockSizeMenu(menu, port); +} + +void AudioBlockSizeChoice::step() { + text = ""; + if (box.size.x >= 100.0) + text += "Block size: "; + int blockSize = port ? port->getBlockSize() : 0; + if (blockSize > 0) { + text += string::f("%d", blockSize); + color.a = 1.0; } - void step() override { - text = ""; - if (box.size.x >= 100.0) - text += "Block size: "; - int blockSize = port ? port->getBlockSize() : 0; - if (blockSize > 0) { - text += string::f("%d", blockSize); - color.a = 1.0; - } - else { - text += "---"; - color.a = 0.5; - } + else { + text += "---"; + color.a = 0.5; } -}; +} struct AudioBlockSizeItem : ui::MenuItem { audio::Port* port; @@ -302,7 +293,7 @@ struct AudioBlockSizeItem : ui::MenuItem { }; -void AudioWidget::setAudioPort(audio::Port* port) { +void AudioDisplay::setAudioPort(audio::Port* port) { clearChildren(); math::Vec pos; @@ -349,21 +340,9 @@ void AudioWidget::setAudioPort(audio::Port* port) { } -struct AudioDeviceMenuChoice : AudioDeviceChoice { - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - appendAudioMenu(menu, port); - } -}; - - -void AudioDeviceWidget::setAudioPort(audio::Port* port) { - AudioDeviceMenuChoice* deviceChoice = createWidget(math::Vec()); - deviceChoice->box.size.x = box.size.x; - deviceChoice->box.size.y = box.size.y; - deviceChoice->port = port; - addChild(deviceChoice); - this->deviceChoice = deviceChoice; +void AudioDeviceMenuChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + appendAudioMenu(menu, port); } diff --git a/src/app/MidiWidget.cpp b/src/app/MidiDisplay.cpp similarity index 78% rename from src/app/MidiWidget.cpp rename to src/app/MidiDisplay.cpp index 29f0645e..22fedd5d 100644 --- a/src/app/MidiWidget.cpp +++ b/src/app/MidiDisplay.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -29,24 +29,22 @@ static void appendMidiDriverMenu(ui::Menu* menu, midi::Port* port) { } } -struct MidiDriverChoice : LedDisplayChoice { - midi::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("MIDI driver")); - appendMidiDriverMenu(menu, port); +void MidiDriverChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("MIDI driver")); + appendMidiDriverMenu(menu, port); +} + +void MidiDriverChoice::step() { + text = (port && port->driver) ? port->getDriver()->getName() : ""; + if (text.empty()) { + text = "(No driver)"; + color.a = 0.5f; } - void step() override { - text = (port && port->driver) ? port->getDriver()->getName() : ""; - if (text.empty()) { - text = "(No driver)"; - color.a = 0.5f; - } - else { - color.a = 1.f; - } + else { + color.a = 1.f; } -}; +} struct MidiDriverItem : ui::MenuItem { midi::Port* port; @@ -89,24 +87,22 @@ static void appendMidiDeviceMenu(ui::Menu* menu, midi::Port* port) { } } -struct MidiDeviceChoice : LedDisplayChoice { - midi::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("MIDI device")); - appendMidiDeviceMenu(menu, port); +void MidiDeviceChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("MIDI device")); + appendMidiDeviceMenu(menu, port); +} + +void MidiDeviceChoice::step() { + text = (port && port->device) ? port->getDevice()->getName() : ""; + if (text.empty()) { + text = "(No device)"; + color.a = 0.5f; } - void step() override { - text = (port && port->device) ? port->getDevice()->getName() : ""; - if (text.empty()) { - text = "(No device)"; - color.a = 0.5f; - } - else { - color.a = 1.f; - } + else { + color.a = 1.f; } -}; +} struct MidiDeviceItem : ui::MenuItem { midi::Port* port; @@ -140,17 +136,15 @@ static void appendMidiChannelMenu(ui::Menu* menu, midi::Port* port) { } } -struct MidiChannelChoice : LedDisplayChoice { - midi::Port* port; - void onAction(const ActionEvent& e) override { - ui::Menu* menu = createMenu(); - menu->addChild(createMenuLabel("MIDI channel")); - appendMidiChannelMenu(menu, port); - } - void step() override { - text = port ? port->getChannelName(port->getChannel()) : "Channel 1"; - } -}; +void MidiChannelChoice::onAction(const ActionEvent& e) { + ui::Menu* menu = createMenu(); + menu->addChild(createMenuLabel("MIDI channel")); + appendMidiChannelMenu(menu, port); +} + +void MidiChannelChoice::step() { + text = port ? port->getChannelName(port->getChannel()) : "Channel 1"; +} struct MidiChannelItem : ui::MenuItem { midi::Port* port; @@ -162,7 +156,7 @@ struct MidiChannelItem : ui::MenuItem { }; -void MidiWidget::setMidiPort(midi::Port* port) { +void MidiDisplay::setMidiPort(midi::Port* port) { clearChildren(); math::Vec pos; diff --git a/src/core/Audio.cpp b/src/core/Audio.cpp index 5e327f0e..843c5bf0 100644 --- a/src/core/Audio.cpp +++ b/src/core/Audio.cpp @@ -397,6 +397,28 @@ struct Audio : Module { }; +/** For Audio-2 module. */ +struct Audio2Display : LedDisplay { + AudioDeviceMenuChoice* deviceChoice; + LedDisplaySeparator* deviceSeparator; + + void setAudioPort(audio::Port* port) { + math::Vec pos; + + deviceChoice = createWidget(math::Vec()); + deviceChoice->box.size.x = box.size.x; + deviceChoice->box.size.y = mm2px(4.0); + deviceChoice->port = port; + addChild(deviceChoice); + pos = deviceChoice->box.getBottomLeft(); + + deviceSeparator = createWidget(pos); + deviceSeparator->box.size.x = box.size.x; + addChild(deviceSeparator); + } +}; + + template struct AudioWidget : ModuleWidget { typedef Audio TAudio; @@ -440,10 +462,10 @@ struct AudioWidget : ModuleWidget { addChild(createLightCentered>(mm2px(Vec(13.54, 107.097)), module, TAudio::OUTPUT_LIGHTS + 2 * 2)); addChild(createLightCentered>(mm2px(Vec(36.638, 107.097)), module, TAudio::OUTPUT_LIGHTS + 2 * 3)); - app::AudioWidget* audioWidget = createWidget(mm2px(Vec(0.0, 13.039))); - audioWidget->box.size = mm2px(Vec(50.8, 29.021)); - audioWidget->setAudioPort(module ? &module->port : NULL); - addChild(audioWidget); + AudioDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(50.8, 29.021)); + display->setAudioPort(module ? &module->port : NULL); + addChild(display); } else if (NUM_AUDIO_INPUTS == 16 && NUM_AUDIO_OUTPUTS == 16) { setPanel(Svg::load(asset::system("res/Core/Audio16.svg"))); @@ -505,10 +527,10 @@ struct AudioWidget : ModuleWidget { addChild(createLightCentered>(mm2px(Vec(59.745, 107.097)), module, TAudio::OUTPUT_LIGHTS + 2 * 6)); addChild(createLightCentered>(mm2px(Vec(82.844, 107.097)), module, TAudio::OUTPUT_LIGHTS + 2 * 7)); - app::AudioWidget* audioWidget = createWidget(mm2px(Vec(0.0, 13.039))); - audioWidget->box.size = mm2px(Vec(96.52, 29.021)); - audioWidget->setAudioPort(module ? &module->port : NULL); - addChild(audioWidget); + AudioDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(96.52, 29.021)); + display->setAudioPort(module ? &module->port : NULL); + addChild(display); } else if (NUM_AUDIO_INPUTS == 2 && NUM_AUDIO_OUTPUTS == 2) { setPanel(Svg::load(asset::system("res/Core/Audio2.svg"))); @@ -539,12 +561,12 @@ struct AudioWidget : ModuleWidget { addChild(createLightCentered>(mm2px(Vec(6.691, 55.386)), module, TAudio::VU_LIGHTS + 6 * 0 + 5)); addChild(createLightCentered>(mm2px(Vec(18.709, 55.386)), module, TAudio::VU_LIGHTS + 6 * 1 + 5)); - app::AudioDeviceWidget* audioWidget = createWidget(mm2px(Vec(0.0, 13.039))); - audioWidget->box.size = mm2px(Vec(25.4, 47.726)); - audioWidget->setAudioPort(module ? &module->port : NULL); + Audio2Display* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(25.4, 47.726)); + display->setAudioPort(module ? &module->port : NULL); // Adjust deviceChoice position - audioWidget->deviceChoice->textOffset = Vec(6, 14); - addChild(audioWidget); + display->deviceChoice->textOffset = Vec(6, 14); + addChild(display); // AudioButton example // AudioButton* audioButton_ADAT = createWidget(Vec(0, 0)); diff --git a/src/core/CV_MIDI.cpp b/src/core/CV_MIDI.cpp index cb1a082e..6d0bf227 100644 --- a/src/core/CV_MIDI.cpp +++ b/src/core/CV_MIDI.cpp @@ -169,10 +169,10 @@ struct CV_MIDIWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(32.591, 112.975)), module, CV_MIDI::CONTINUE_INPUT)); addInput(createInputCentered(mm2px(Vec(20.249, 113.115)), module, CV_MIDI::STOP_INPUT)); - MidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.039))); - midiWidget->box.size = mm2px(Vec(40.64, 29.021)); - midiWidget->setMidiPort(module ? &module->midiOutput : NULL); - addChild(midiWidget); + MidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(40.64, 29.021)); + display->setMidiPort(module ? &module->midiOutput : NULL); + addChild(display); } void appendContextMenu(Menu* menu) override { diff --git a/src/core/CV_MIDICC.cpp b/src/core/CV_MIDICC.cpp index a3065a2d..68065b15 100644 --- a/src/core/CV_MIDICC.cpp +++ b/src/core/CV_MIDICC.cpp @@ -149,12 +149,12 @@ struct CV_MIDICCWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(31.289, 112.984)), module, CV_MIDICC::CC_INPUTS + 14)); addInput(createInputCentered(mm2px(Vec(42.838, 112.984)), module, CV_MIDICC::CC_INPUTS + 15)); - typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.039))); - midiWidget->box.size = mm2px(Vec(50.8, 55.88)); - midiWidget->setMidiPort(module ? &module->midiOutput : NULL); - midiWidget->setModule(module); - addChild(midiWidget); + typedef Grid16MidiDisplay> TMidiDisplay; + TMidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(50.8, 55.88)); + display->setMidiPort(module ? &module->midiOutput : NULL); + display->setModule(module); + addChild(display); } }; diff --git a/src/core/Gate_MIDI.cpp b/src/core/Gate_MIDI.cpp index 7835d809..dd8f80b0 100644 --- a/src/core/Gate_MIDI.cpp +++ b/src/core/Gate_MIDI.cpp @@ -189,12 +189,12 @@ struct Gate_MIDIWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(31.289, 112.984)), module, Gate_MIDI::GATE_INPUTS + 14)); addInput(createInputCentered(mm2px(Vec(42.838, 112.984)), module, Gate_MIDI::GATE_INPUTS + 15)); - typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.039))); - midiWidget->box.size = mm2px(Vec(50.8, 55.88)); - midiWidget->setMidiPort(module ? &module->midiOutput : NULL); - midiWidget->setModule(module); - addChild(midiWidget); + typedef Grid16MidiDisplay> TMidiDisplay; + TMidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(50.8, 55.88)); + display->setMidiPort(module ? &module->midiOutput : NULL); + display->setModule(module); + addChild(display); } void appendContextMenu(Menu* menu) override { diff --git a/src/core/MIDICC_CV.cpp b/src/core/MIDICC_CV.cpp index 917984ec..873fcb01 100644 --- a/src/core/MIDICC_CV.cpp +++ b/src/core/MIDICC_CV.cpp @@ -238,12 +238,12 @@ struct MIDICC_CVWidget : ModuleWidget { addOutput(createOutputCentered(mm2px(Vec(31.289, 112.984)), module, MIDICC_CV::CC_OUTPUT + 14)); addOutput(createOutputCentered(mm2px(Vec(42.839, 112.984)), module, MIDICC_CV::CC_OUTPUT + 15)); - typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.039))); - midiWidget->box.size = mm2px(Vec(50.8, 55.88)); - midiWidget->setMidiPort(module ? &module->midiInput : NULL); - midiWidget->setModule(module); - addChild(midiWidget); + typedef Grid16MidiDisplay> TMidiDisplay; + TMidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(50.8, 55.88)); + display->setMidiPort(module ? &module->midiInput : NULL); + display->setModule(module); + addChild(display); } void appendContextMenu(Menu* menu) override { diff --git a/src/core/MIDIMap.cpp b/src/core/MIDIMap.cpp index 8b8a6a03..21043046 100644 --- a/src/core/MIDIMap.cpp +++ b/src/core/MIDIMap.cpp @@ -420,7 +420,7 @@ struct MIDIMapChoice : LedDisplayChoice { }; -struct MIDIMapDisplay : MidiWidget { +struct MIDIMapDisplay : MidiDisplay { MIDIMap* module; ScrollWidget* scroll; MIDIMapChoice* choices[MAX_CHANNELS]; @@ -469,7 +469,7 @@ struct MIDIMapDisplay : MidiWidget { } } - MidiWidget::step(); + MidiDisplay::step(); } }; @@ -484,11 +484,11 @@ struct MIDIMapWidget : ModuleWidget { addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - MIDIMapDisplay* midiWidget = createWidget(mm2px(Vec(0.0, 12.869))); - midiWidget->box.size = mm2px(Vec(50.8, 105.059)); - midiWidget->setMidiPort(module ? &module->midiInput : NULL); - midiWidget->setModule(module); - addChild(midiWidget); + MIDIMapDisplay* display = createWidget(mm2px(Vec(0.0, 12.869))); + display->box.size = mm2px(Vec(50.8, 105.059)); + display->setMidiPort(module ? &module->midiInput : NULL); + display->setModule(module); + addChild(display); } void appendContextMenu(Menu* menu) override { diff --git a/src/core/MIDI_CV.cpp b/src/core/MIDI_CV.cpp index 6cd81920..f30fe7af 100644 --- a/src/core/MIDI_CV.cpp +++ b/src/core/MIDI_CV.cpp @@ -490,10 +490,10 @@ struct MIDI_CVWidget : ModuleWidget { addOutput(createOutputCentered(mm2px(Vec(32.591, 112.975)), module, MIDI_CV::STOP_OUTPUT)); addOutput(createOutputCentered(mm2px(Vec(20.248, 113.115)), module, MIDI_CV::CONTINUE_OUTPUT)); - MidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.048))); - midiWidget->box.size = mm2px(Vec(40.64, 29.012)); - midiWidget->setMidiPort(module ? &module->midiInput : NULL); - addChild(midiWidget); + MidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.048))); + display->box.size = mm2px(Vec(40.64, 29.012)); + display->setMidiPort(module ? &module->midiInput : NULL); + addChild(display); // MidiButton example // MidiButton* midiButton = createWidget(Vec(0, 0)); diff --git a/src/core/MIDI_Gate.cpp b/src/core/MIDI_Gate.cpp index 022773ec..29c6252f 100644 --- a/src/core/MIDI_Gate.cpp +++ b/src/core/MIDI_Gate.cpp @@ -206,12 +206,12 @@ struct MIDI_GateWidget : ModuleWidget { addOutput(createOutputCentered(mm2px(Vec(31.289, 112.984)), module, MIDI_Gate::GATE_OUTPUTS + 14)); addOutput(createOutputCentered(mm2px(Vec(42.838, 112.984)), module, MIDI_Gate::GATE_OUTPUTS + 15)); - typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget* midiWidget = createWidget(mm2px(Vec(0.0, 13.039))); - midiWidget->box.size = mm2px(Vec(50.8, 55.88)); - midiWidget->setMidiPort(module ? &module->midiInput : NULL); - midiWidget->setModule(module); - addChild(midiWidget); + typedef Grid16MidiDisplay> TMidiDisplay; + TMidiDisplay* display = createWidget(mm2px(Vec(0.0, 13.039))); + display->box.size = mm2px(Vec(50.8, 55.88)); + display->setMidiPort(module ? &module->midiInput : NULL); + display->setModule(module); + addChild(display); } void appendContextMenu(Menu* menu) override { diff --git a/src/core/plugin.hpp b/src/core/plugin.hpp index 080ee1c1..b6285fb0 100644 --- a/src/core/plugin.hpp +++ b/src/core/plugin.hpp @@ -20,7 +20,7 @@ extern Model* modelNotes; template -struct Grid16MidiWidget : MidiWidget { +struct Grid16MidiDisplay : MidiDisplay { LedDisplaySeparator* hSeparators[4]; LedDisplaySeparator* vSeparators[4]; TChoice* choices[4][4];