diff --git a/include/app/SvgButton.hpp b/include/app/SvgButton.hpp index 45662e4b..122ce36d 100644 --- a/include/app/SvgButton.hpp +++ b/include/app/SvgButton.hpp @@ -18,6 +18,7 @@ struct SvgButton : widget::OpaqueWidget { SvgButton(); void addFrame(std::shared_ptr svg); + void onButton(const ButtonEvent& e) override; void onDragStart(const DragStartEvent& e) override; void onDragEnd(const DragEndEvent& e) override; void onDragDrop(const DragDropEvent& e) override; diff --git a/src/app/SvgButton.cpp b/src/app/SvgButton.cpp index 440315d5..d14e0edc 100644 --- a/src/app/SvgButton.cpp +++ b/src/app/SvgButton.cpp @@ -17,6 +17,19 @@ SvgButton::SvgButton() { fb->addChild(sw); } + +void SvgButton::onButton(const ButtonEvent& e) { + OpaqueWidget::onButton(e); + + // Accept left and right-click dragging. + if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) { + ActionEvent eAction; + onAction(eAction); + e.consume(this); + } +} + + void SvgButton::addFrame(std::shared_ptr svg) { frames.push_back(svg); // If this is our first frame, automatically set SVG and size @@ -30,6 +43,7 @@ void SvgButton::addFrame(std::shared_ptr svg) { } } + void SvgButton::onDragStart(const DragStartEvent& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -40,6 +54,7 @@ void SvgButton::onDragStart(const DragStartEvent& e) { } } + void SvgButton::onDragEnd(const DragEndEvent& e) { if (frames.size() >= 1) { sw->setSvg(frames[0]); @@ -47,6 +62,7 @@ void SvgButton::onDragEnd(const DragEndEvent& e) { } } + void SvgButton::onDragDrop(const DragDropEvent& e) { if (e.origin == this) { ActionEvent eAction; diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index 657387ea..f9598e08 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -544,6 +544,15 @@ struct AudioInterfaceWidget : ModuleWidget { // Adjust deviceChoice position audioWidget->deviceChoice->textOffset = Vec(6, 14); addChild(audioWidget); + + // AudioButton example + // AudioButton* audioButton_ADAT = createWidget(Vec(0, 0)); + // audioButton_ADAT->setAudioPort(module ? &module->port : NULL); + // addChild(audioButton_ADAT); + + // AudioButton* audioButton_USB_B = createWidget(Vec(0, 40)); + // audioButton_USB_B->setAudioPort(module ? &module->port : NULL); + // addChild(audioButton_USB_B); } } diff --git a/src/core/MIDI_CV.cpp b/src/core/MIDI_CV.cpp index bcfdca16..93e8b988 100644 --- a/src/core/MIDI_CV.cpp +++ b/src/core/MIDI_CV.cpp @@ -498,6 +498,11 @@ struct MIDI_CVWidget : ModuleWidget { midiWidget->box.size = mm2px(Vec(33.840, 28)); midiWidget->setMidiPort(module ? &module->midiInput : NULL); addChild(midiWidget); + + // MidiButton example + // MidiButton* midiButton = createWidget(Vec(0, 0)); + // midiButton->setMidiPort(module ? &module->midiInput : NULL); + // addChild(midiButton); } void appendContextMenu(Menu* menu) override {