@@ -2,6 +2,7 @@ | |||||
#include <app/common.hpp> | #include <app/common.hpp> | ||||
#include <app/LedDisplay.hpp> | #include <app/LedDisplay.hpp> | ||||
#include <ui/Menu.hpp> | #include <ui/Menu.hpp> | ||||
#include <app/SvgButton.hpp> | |||||
#include <audio.hpp> | #include <audio.hpp> | ||||
@@ -29,6 +30,14 @@ struct AudioDeviceWidget : LedDisplay { | |||||
}; | }; | ||||
/** 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 event::Action& e) override; | |||||
}; | |||||
/** Appends menu items to the given menu with driver, device, etc. | /** Appends menu items to the given menu with driver, device, etc. | ||||
Useful alternative to putting an AudioWidget on your module's panel. | Useful alternative to putting an AudioWidget on your module's panel. | ||||
*/ | */ | ||||
@@ -2,6 +2,7 @@ | |||||
#include <app/common.hpp> | #include <app/common.hpp> | ||||
#include <app/LedDisplay.hpp> | #include <app/LedDisplay.hpp> | ||||
#include <ui/Menu.hpp> | #include <ui/Menu.hpp> | ||||
#include <app/SvgButton.hpp> | |||||
#include <midi.hpp> | #include <midi.hpp> | ||||
@@ -19,6 +20,14 @@ struct MidiWidget : LedDisplay { | |||||
}; | }; | ||||
/** A virtual MIDI port graphic that displays an MIDI menu when clicked. */ | |||||
struct MidiButton : SvgButton { | |||||
midi::Port* port; | |||||
void setMidiPort(midi::Port* port); | |||||
void onAction(const event::Action& e) override; | |||||
}; | |||||
/** Appends menu items to the given menu with driver, device, etc. | /** 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 MidiWidget on your module's panel. | ||||
*/ | */ | ||||
@@ -5,6 +5,8 @@ | |||||
#include <app/ModuleLightWidget.hpp> | #include <app/ModuleLightWidget.hpp> | ||||
#include <app/SvgSwitch.hpp> | #include <app/SvgSwitch.hpp> | ||||
#include <app/SvgScrew.hpp> | #include <app/SvgScrew.hpp> | ||||
#include <app/AudioWidget.hpp> | |||||
#include <app/MidiWidget.hpp> | |||||
#include <asset.hpp> | #include <asset.hpp> | ||||
@@ -804,5 +806,29 @@ struct SegmentDisplay : widget::Widget { | |||||
}; | }; | ||||
struct AudioButton_ADAT : app::AudioButton { | |||||
AudioButton_ADAT() { | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/ADAT.svg"))); | |||||
shadow->opacity = 0.0; | |||||
} | |||||
}; | |||||
struct AudioButton_USB_B : app::AudioButton { | |||||
AudioButton_USB_B() { | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/USB-B.svg"))); | |||||
shadow->opacity = 0.0; | |||||
} | |||||
}; | |||||
struct MidiButton_MIDI_DIN : app::MidiButton { | |||||
MidiButton_MIDI_DIN() { | |||||
addFrame(APP->window->loadSvg(asset::system("res/ComponentLibrary/MIDI_DIN.svg"))); | |||||
shadow->opacity = 0.0; | |||||
} | |||||
}; | |||||
} // namespace componentlibrary | } // namespace componentlibrary | ||||
} // namespace rack | } // namespace rack |
@@ -317,9 +317,9 @@ struct Module { | |||||
/** DEPRECATED. Override `onSampleRateChange(e)` instead. */ | /** DEPRECATED. Override `onSampleRateChange(e)` instead. */ | ||||
virtual void onSampleRateChange() {} | virtual void onSampleRateChange() {} | ||||
/** private */ | |||||
/** Unstable API, do not use in plugins. */ | |||||
float& cpuTime(); | float& cpuTime(); | ||||
/** private */ | |||||
/** Unstable API, do not use in plugins. */ | |||||
bool& bypass(); | bool& bypass(); | ||||
}; | }; | ||||
@@ -337,6 +337,17 @@ void AudioDeviceWidget::setAudioPort(audio::Port* port) { | |||||
} | } | ||||
void AudioButton::setAudioPort(audio::Port* port) { | |||||
this->port = port; | |||||
} | |||||
void AudioButton::onAction(const event::Action& e) { | |||||
ui::Menu* menu = createMenu(); | |||||
appendAudioMenu(menu, port); | |||||
} | |||||
void appendAudioMenu(ui::Menu* menu, audio::Port* port) { | void appendAudioMenu(ui::Menu* menu, audio::Port* port) { | ||||
menu->addChild(createMenuLabel("Audio driver")); | menu->addChild(createMenuLabel("Audio driver")); | ||||
appendAudioDriverMenu(menu, port); | appendAudioDriverMenu(menu, port); | ||||
@@ -197,6 +197,17 @@ void MidiWidget::setMidiPort(midi::Port* port) { | |||||
} | } | ||||
void MidiButton::setMidiPort(midi::Port* port) { | |||||
this->port = port; | |||||
} | |||||
void MidiButton::onAction(const event::Action& e) { | |||||
ui::Menu* menu = createMenu(); | |||||
appendMidiMenu(menu, port); | |||||
} | |||||
void appendMidiMenu(ui::Menu* menu, midi::Port* port) { | void appendMidiMenu(ui::Menu* menu, midi::Port* port) { | ||||
menu->addChild(createMenuLabel("MIDI driver")); | menu->addChild(createMenuLabel("MIDI driver")); | ||||
appendMidiDriverMenu(menu, port); | appendMidiDriverMenu(menu, port); | ||||
@@ -446,6 +446,15 @@ struct AudioInterfaceWidget : ModuleWidget { | |||||
// Adjust deviceChoice position | // Adjust deviceChoice position | ||||
audioWidget->deviceChoice->textOffset = Vec(6, 14); | audioWidget->deviceChoice->textOffset = Vec(6, 14); | ||||
addChild(audioWidget); | addChild(audioWidget); | ||||
AudioButton* m = createWidget<AudioButton_USB_B>(Vec()); | |||||
m->setAudioPort(module); | |||||
addChild(m); | |||||
AudioButton* m2 = createWidget<AudioButton_ADAT>(Vec(0, 50)); | |||||
m2->setAudioPort(module); | |||||
addChild(m2); | |||||
} | } | ||||
} | } | ||||
@@ -506,6 +506,11 @@ struct MIDI_CVWidget : ModuleWidget { | |||||
midiWidget->box.size = mm2px(Vec(33.840, 28)); | midiWidget->box.size = mm2px(Vec(33.840, 28)); | ||||
midiWidget->setMidiPort(module ? &module->midiInput : NULL); | midiWidget->setMidiPort(module ? &module->midiInput : NULL); | ||||
addChild(midiWidget); | addChild(midiWidget); | ||||
MidiButton* m = createWidget<MidiButton_MIDI_DIN>(Vec()); | |||||
m->setMidiPort(module ? &module->midiInput : NULL); | |||||
addChild(m); | |||||
} | } | ||||
void appendContextMenu(Menu* menu) override { | void appendContextMenu(Menu* menu) override { | ||||