@@ -18,6 +18,7 @@ struct SvgButton : widget::OpaqueWidget { | |||||
SvgButton(); | SvgButton(); | ||||
void addFrame(std::shared_ptr<Svg> svg); | void addFrame(std::shared_ptr<Svg> svg); | ||||
void onButton(const ButtonEvent& e) override; | |||||
void onDragStart(const DragStartEvent& e) override; | void onDragStart(const DragStartEvent& e) override; | ||||
void onDragEnd(const DragEndEvent& e) override; | void onDragEnd(const DragEndEvent& e) override; | ||||
void onDragDrop(const DragDropEvent& e) override; | void onDragDrop(const DragDropEvent& e) override; | ||||
@@ -17,6 +17,19 @@ SvgButton::SvgButton() { | |||||
fb->addChild(sw); | 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> svg) { | void SvgButton::addFrame(std::shared_ptr<Svg> svg) { | ||||
frames.push_back(svg); | frames.push_back(svg); | ||||
// If this is our first frame, automatically set SVG and size | // If this is our first frame, automatically set SVG and size | ||||
@@ -30,6 +43,7 @@ void SvgButton::addFrame(std::shared_ptr<Svg> svg) { | |||||
} | } | ||||
} | } | ||||
void SvgButton::onDragStart(const DragStartEvent& e) { | void SvgButton::onDragStart(const DragStartEvent& e) { | ||||
if (e.button != GLFW_MOUSE_BUTTON_LEFT) | if (e.button != GLFW_MOUSE_BUTTON_LEFT) | ||||
return; | return; | ||||
@@ -40,6 +54,7 @@ void SvgButton::onDragStart(const DragStartEvent& e) { | |||||
} | } | ||||
} | } | ||||
void SvgButton::onDragEnd(const DragEndEvent& e) { | void SvgButton::onDragEnd(const DragEndEvent& e) { | ||||
if (frames.size() >= 1) { | if (frames.size() >= 1) { | ||||
sw->setSvg(frames[0]); | sw->setSvg(frames[0]); | ||||
@@ -47,6 +62,7 @@ void SvgButton::onDragEnd(const DragEndEvent& e) { | |||||
} | } | ||||
} | } | ||||
void SvgButton::onDragDrop(const DragDropEvent& e) { | void SvgButton::onDragDrop(const DragDropEvent& e) { | ||||
if (e.origin == this) { | if (e.origin == this) { | ||||
ActionEvent eAction; | ActionEvent eAction; | ||||
@@ -544,6 +544,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 example | |||||
// AudioButton* audioButton_ADAT = createWidget<AudioButton_ADAT>(Vec(0, 0)); | |||||
// audioButton_ADAT->setAudioPort(module ? &module->port : NULL); | |||||
// addChild(audioButton_ADAT); | |||||
// AudioButton* audioButton_USB_B = createWidget<AudioButton_USB_B>(Vec(0, 40)); | |||||
// audioButton_USB_B->setAudioPort(module ? &module->port : NULL); | |||||
// addChild(audioButton_USB_B); | |||||
} | } | ||||
} | } | ||||
@@ -498,6 +498,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 example | |||||
// MidiButton* midiButton = createWidget<MidiButton_MIDI_DIN>(Vec(0, 0)); | |||||
// midiButton->setMidiPort(module ? &module->midiInput : NULL); | |||||
// addChild(midiButton); | |||||
} | } | ||||
void appendContextMenu(Menu* menu) override { | void appendContextMenu(Menu* menu) override { | ||||