@@ -15,10 +15,10 @@ struct Knob : ParamWidget { | |||||
/** Multiplier for mouse movement to adjust knob value */ | /** Multiplier for mouse movement to adjust knob value */ | ||||
float speed = 1.0; | float speed = 1.0; | ||||
void onButton(event::Button &e) override; | |||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragEnd(event::DragEnd &e) override; | |||||
void onDragMove(event::DragMove &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragEnd(const event::DragEnd &e) override; | |||||
void onDragMove(const event::DragMove &e) override; | |||||
}; | }; | ||||
@@ -24,7 +24,7 @@ struct LedDisplayChoice : TransparentWidget { | |||||
NVGcolor color; | NVGcolor color; | ||||
LedDisplayChoice(); | LedDisplayChoice(); | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onButton(event::Button &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
}; | }; | ||||
struct LedDisplayTextField : TextField { | struct LedDisplayTextField : TextField { | ||||
@@ -64,12 +64,12 @@ struct ModuleWidget : OpaqueWidget { | |||||
void drawShadow(NVGcontext *vg); | void drawShadow(NVGcontext *vg); | ||||
math::Vec dragPos; | math::Vec dragPos; | ||||
void onHover(event::Hover &e) override; | |||||
void onButton(event::Button &e) override; | |||||
void onHoverKey(event::HoverKey &e) override; | |||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragEnd(event::DragEnd &e) override; | |||||
void onDragMove(event::DragMove &e) override; | |||||
void onHover(const event::Hover &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onHoverKey(const event::HoverKey &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragEnd(const event::DragEnd &e) override; | |||||
void onDragMove(const event::DragMove &e) override; | |||||
}; | }; | ||||
@@ -10,8 +10,8 @@ namespace rack { | |||||
Consider using SVGButton if the switch simply changes the state of your Module when clicked. | Consider using SVGButton if the switch simply changes the state of your Module when clicked. | ||||
*/ | */ | ||||
struct MomentarySwitch : virtual ParamWidget { | struct MomentarySwitch : virtual ParamWidget { | ||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragEnd(event::DragEnd &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragEnd(const event::DragEnd &e) override; | |||||
}; | }; | ||||
@@ -19,8 +19,8 @@ struct ParamWidget : OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
/** For legacy patch loading */ | /** For legacy patch loading */ | ||||
void fromJson(json_t *rootJ); | void fromJson(json_t *rootJ); | ||||
void onButton(event::Button &e) override; | |||||
void onDragMove(event::DragMove &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onDragMove(const event::DragMove &e) override; | |||||
}; | }; | ||||
@@ -23,12 +23,12 @@ struct PortWidget : OpaqueWidget { | |||||
~PortWidget(); | ~PortWidget(); | ||||
void step() override; | void step() override; | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onButton(event::Button &e) override; | |||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragEnd(event::DragEnd &e) override; | |||||
void onDragDrop(event::DragDrop &e) override; | |||||
void onDragEnter(event::DragEnter &e) override; | |||||
void onDragLeave(event::DragLeave &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragEnd(const event::DragEnd &e) override; | |||||
void onDragDrop(const event::DragDrop &e) override; | |||||
void onDragEnter(const event::DragEnter &e) override; | |||||
void onDragLeave(const event::DragLeave &e) override; | |||||
}; | }; | ||||
@@ -52,10 +52,10 @@ struct RackWidget : OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onHover(event::Hover &e) override; | |||||
void onDragHover(event::DragHover &e) override; | |||||
void onButton(event::Button &e) override; | |||||
void onZoom(event::Zoom &e) override; | |||||
void onHover(const event::Hover &e) override; | |||||
void onDragHover(const event::DragHover &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onZoom(const event::Zoom &e) override; | |||||
}; | }; | ||||
@@ -18,8 +18,8 @@ struct SVGButton : FramebufferWidget { | |||||
SVGButton(); | SVGButton(); | ||||
/** If `activeSVG` is NULL, `defaultSVG` is used as the active state instead. */ | /** If `activeSVG` is NULL, `defaultSVG` is used as the active state instead. */ | ||||
void setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> activeSVG); | void setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> activeSVG); | ||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragEnd(event::DragEnd &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragEnd(const event::DragEnd &e) override; | |||||
}; | }; | ||||
@@ -21,7 +21,7 @@ struct SVGKnob : Knob, FramebufferWidget { | |||||
SVGKnob(); | SVGKnob(); | ||||
void setSVG(std::shared_ptr<SVG> svg); | void setSVG(std::shared_ptr<SVG> svg); | ||||
void step() override; | void step() override; | ||||
void onChange(event::Change &e) override; | |||||
void onChange(const event::Change &e) override; | |||||
}; | }; | ||||
@@ -20,7 +20,7 @@ struct SVGSlider : Knob, FramebufferWidget { | |||||
SVGSlider(); | SVGSlider(); | ||||
void setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG); | void setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG); | ||||
void step() override; | void step() override; | ||||
void onChange(event::Change &e) override; | |||||
void onChange(const event::Change &e) override; | |||||
}; | }; | ||||
@@ -18,7 +18,7 @@ struct SVGSwitch : virtual ParamWidget, FramebufferWidget { | |||||
void step() override; | void step() override; | ||||
/** Adds an SVG file to represent the next switch position */ | /** Adds an SVG file to represent the next switch position */ | ||||
void addFrame(std::shared_ptr<SVG> svg); | void addFrame(std::shared_ptr<SVG> svg); | ||||
void onChange(event::Change &e) override; | |||||
void onChange(const event::Change &e) override; | |||||
}; | }; | ||||
@@ -27,8 +27,8 @@ struct Scene : OpaqueWidget { | |||||
Scene(); | Scene(); | ||||
void step() override; | void step() override; | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onHoverKey(event::HoverKey &e) override; | |||||
void onPathDrop(event::PathDrop &e) override; | |||||
void onHoverKey(const event::HoverKey &e) override; | |||||
void onPathDrop(const event::PathDrop &e) override; | |||||
void runCheckVersion(); | void runCheckVersion(); | ||||
}; | }; | ||||
@@ -8,7 +8,7 @@ namespace rack { | |||||
/** A switch that cycles through each mechanical position */ | /** A switch that cycles through each mechanical position */ | ||||
struct ToggleSwitch : virtual ParamWidget { | struct ToggleSwitch : virtual ParamWidget { | ||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
}; | }; | ||||
@@ -26,27 +26,27 @@ struct Button : OpaqueWidget { | |||||
bndToolButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | bndToolButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); | ||||
} | } | ||||
void onEnter(event::Enter &e) override { | |||||
void onEnter(const event::Enter &e) override { | |||||
state = BND_HOVER; | state = BND_HOVER; | ||||
} | } | ||||
void onLeave(event::Leave &e) override { | |||||
void onLeave(const event::Leave &e) override { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
} | } | ||||
void onDragStart(event::DragStart &e) override { | |||||
void onDragStart(const event::DragStart &e) override { | |||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
if (quantity) | if (quantity) | ||||
quantity->setMax(); | quantity->setMax(); | ||||
} | } | ||||
void onDragEnd(event::DragEnd &e) override { | |||||
void onDragEnd(const event::DragEnd &e) override { | |||||
state = BND_HOVER; | state = BND_HOVER; | ||||
if (quantity) | if (quantity) | ||||
quantity->setMin(); | quantity->setMin(); | ||||
} | } | ||||
void onDragDrop(event::DragDrop &e) override { | |||||
void onDragDrop(const event::DragDrop &e) override { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
event::Action eAction; | event::Action eAction; | ||||
onAction(eAction); | onAction(eAction); | ||||
@@ -18,7 +18,7 @@ struct Menu : OpaqueWidget { | |||||
void setChildMenu(Menu *menu); | void setChildMenu(Menu *menu); | ||||
void step() override; | void step() override; | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onHoverScroll(event::HoverScroll &e) override; | |||||
void onHoverScroll(const event::HoverScroll &e) override; | |||||
}; | }; | ||||
@@ -19,8 +19,8 @@ struct MenuItem : MenuEntry { | |||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void step() override; | void step() override; | ||||
void onEnter(event::Enter &e) override; | |||||
void onDragDrop(event::DragDrop &e) override; | |||||
void onEnter(const event::Enter &e) override; | |||||
void onDragDrop(const event::DragDrop &e) override; | |||||
void doAction(); | void doAction(); | ||||
virtual Menu *createChildMenu() {return NULL;} | virtual Menu *createChildMenu() {return NULL;} | ||||
}; | }; | ||||
@@ -20,7 +20,7 @@ struct MenuOverlay : OpaqueWidget { | |||||
Widget::step(); | Widget::step(); | ||||
} | } | ||||
void onButton(event::Button &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getConsumed() == this && e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | if (e.getConsumed() == this && e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
@@ -28,7 +28,7 @@ struct MenuOverlay : OpaqueWidget { | |||||
} | } | ||||
} | } | ||||
void onHoverKey(event::HoverKey &e) override { | |||||
void onHoverKey(const event::HoverKey &e) override { | |||||
OpaqueWidget::onHoverKey(e); | OpaqueWidget::onHoverKey(e); | ||||
if (e.getConsumed() == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) { | if (e.getConsumed() == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) { | ||||
@@ -26,17 +26,17 @@ struct RadioButton : OpaqueWidget { | |||||
bndRadioButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str()); | bndRadioButton(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str()); | ||||
} | } | ||||
void onEnter(event::Enter &e) override { | |||||
void onEnter(const event::Enter &e) override { | |||||
if (state != BND_ACTIVE) | if (state != BND_ACTIVE) | ||||
state = BND_HOVER; | state = BND_HOVER; | ||||
} | } | ||||
void onLeave(event::Leave &e) override { | |||||
void onLeave(const event::Leave &e) override { | |||||
if (state != BND_ACTIVE) | if (state != BND_ACTIVE) | ||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
} | } | ||||
void onDragDrop(event::DragDrop &e) override { | |||||
void onDragDrop(const event::DragDrop &e) override { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
if (state == BND_ACTIVE) { | if (state == BND_ACTIVE) { | ||||
state = BND_HOVER; | state = BND_HOVER; | ||||
@@ -27,14 +27,14 @@ struct ScrollBar : OpaqueWidget { | |||||
bndScrollBar(vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size); | bndScrollBar(vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size); | ||||
} | } | ||||
void onDragStart(event::DragStart &e) override { | |||||
void onDragStart(const event::DragStart &e) override { | |||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
context()->window->cursorLock(); | context()->window->cursorLock(); | ||||
} | } | ||||
void onDragMove(event::DragMove &e) override; | |||||
void onDragMove(const event::DragMove &e) override; | |||||
void onDragEnd(event::DragEnd &e) override { | |||||
void onDragEnd(const event::DragEnd &e) override { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
context()->window->cursorUnlock(); | context()->window->cursorUnlock(); | ||||
} | } | ||||
@@ -110,7 +110,7 @@ struct ScrollWidget : OpaqueWidget { | |||||
verticalScrollBar->box.size.y = horizontalScrollBar->visible ? inner.y : box.size.y; | verticalScrollBar->box.size.y = horizontalScrollBar->visible ? inner.y : box.size.y; | ||||
} | } | ||||
void onHover(event::Hover &e) override { | |||||
void onHover(const event::Hover &e) override { | |||||
// Scroll with arrow keys | // Scroll with arrow keys | ||||
if (!context()->event->selectedWidget) { | if (!context()->event->selectedWidget) { | ||||
float arrowSpeed = 30.0; | float arrowSpeed = 30.0; | ||||
@@ -138,14 +138,14 @@ struct ScrollWidget : OpaqueWidget { | |||||
OpaqueWidget::onHover(e); | OpaqueWidget::onHover(e); | ||||
} | } | ||||
void onHoverScroll(event::HoverScroll &e) override { | |||||
void onHoverScroll(const event::HoverScroll &e) override { | |||||
offset = offset.minus(e.scrollDelta); | offset = offset.minus(e.scrollDelta); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
}; | }; | ||||
inline void ScrollBar::onDragMove(event::DragMove &e) { | |||||
inline void ScrollBar::onDragMove(const event::DragMove &e) { | |||||
ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent); | ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent); | ||||
assert(scrollWidget); | assert(scrollWidget); | ||||
if (orientation == HORIZONTAL) | if (orientation == HORIZONTAL) | ||||
@@ -30,23 +30,23 @@ struct Slider : OpaqueWidget { | |||||
bndSlider(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, text.c_str(), NULL); | bndSlider(vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, text.c_str(), NULL); | ||||
} | } | ||||
void onDragStart(event::DragStart &e) override { | |||||
void onDragStart(const event::DragStart &e) override { | |||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
context()->window->cursorLock(); | context()->window->cursorLock(); | ||||
} | } | ||||
void onDragMove(event::DragMove &e) override { | |||||
void onDragMove(const event::DragMove &e) override { | |||||
if (quantity) { | if (quantity) { | ||||
quantity->moveScaledValue(SLIDER_SENSITIVITY * e.mouseDelta.x); | quantity->moveScaledValue(SLIDER_SENSITIVITY * e.mouseDelta.x); | ||||
} | } | ||||
} | } | ||||
void onDragEnd(event::DragEnd &e) override { | |||||
void onDragEnd(const event::DragEnd &e) override { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
context()->window->cursorUnlock(); | context()->window->cursorUnlock(); | ||||
} | } | ||||
void onButton(event::Button &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | ||||
if (quantity) | if (quantity) | ||||
quantity->reset(); | quantity->reset(); | ||||
@@ -21,11 +21,11 @@ struct TextField : OpaqueWidget { | |||||
TextField(); | TextField(); | ||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
void onButton(event::Button &e) override; | |||||
void onHover(event::Hover &e) override; | |||||
void onEnter(event::Enter &e) override; | |||||
void onSelectText(event::SelectText &e) override; | |||||
void onSelectKey(event::SelectKey &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
void onHover(const event::Hover &e) override; | |||||
void onEnter(const event::Enter &e) override; | |||||
void onSelectText(const event::SelectText &e) override; | |||||
void onSelectKey(const event::SelectKey &e) override; | |||||
/** Inserts text at the cursor, replacing the selection if necessary */ | /** Inserts text at the cursor, replacing the selection if necessary */ | ||||
void insertText(std::string text); | void insertText(std::string text); | ||||
@@ -14,7 +14,7 @@ struct WindowWidget : OpaqueWidget { | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
void onDragMove(event::DragMove &e) override { | |||||
void onDragMove(const event::DragMove &e) override { | |||||
box.pos = box.pos.plus(e.mouseDelta); | box.pos = box.pos.plus(e.mouseDelta); | ||||
} | } | ||||
}; | }; | ||||
@@ -27,7 +27,7 @@ struct FramebufferWidget : virtual Widget { | |||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
int getImageHandle(); | int getImageHandle(); | ||||
void onZoom(event::Zoom &e) override { | |||||
void onZoom(const event::Zoom &e) override { | |||||
dirty = true; | dirty = true; | ||||
Widget::onZoom(e); | Widget::onZoom(e); | ||||
} | } | ||||
@@ -10,37 +10,37 @@ You can of course override the events. | |||||
You may also call OpaqueWidget::on*() from the overridden method to continue recursing/consuming the event. | You may also call OpaqueWidget::on*() from the overridden method to continue recursing/consuming the event. | ||||
*/ | */ | ||||
struct OpaqueWidget : virtual Widget { | struct OpaqueWidget : virtual Widget { | ||||
void onHover(event::Hover &e) override { | |||||
void onHover(const event::Hover &e) override { | |||||
Widget::onHover(e); | Widget::onHover(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onButton(event::Button &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
Widget::onButton(e); | Widget::onButton(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onHoverKey(event::HoverKey &e) override { | |||||
void onHoverKey(const event::HoverKey &e) override { | |||||
Widget::onHoverKey(e); | Widget::onHoverKey(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onHoverText(event::HoverText &e) override { | |||||
void onHoverText(const event::HoverText &e) override { | |||||
Widget::onHoverText(e); | Widget::onHoverText(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onHoverScroll(event::HoverScroll &e) override { | |||||
void onHoverScroll(const event::HoverScroll &e) override { | |||||
Widget::onHoverScroll(e); | Widget::onHoverScroll(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onDragHover(event::DragHover &e) override { | |||||
void onDragHover(const event::DragHover &e) override { | |||||
Widget::onDragHover(e); | Widget::onDragHover(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onPathDrop(event::PathDrop &e) override { | |||||
void onPathDrop(const event::PathDrop &e) override { | |||||
Widget::onPathDrop(e); | Widget::onPathDrop(e); | ||||
if (!e.getConsumed()) | if (!e.getConsumed()) | ||||
e.consume(this); | e.consume(this); | ||||
@@ -8,13 +8,13 @@ namespace rack { | |||||
/** Widget that does not respond to events and does not pass events to children */ | /** Widget that does not respond to events and does not pass events to children */ | ||||
struct TransparentWidget : virtual Widget { | struct TransparentWidget : virtual Widget { | ||||
/** Override behavior to do nothing instead. */ | /** Override behavior to do nothing instead. */ | ||||
void onHover(event::Hover &e) override {} | |||||
void onButton(event::Button &e) override {} | |||||
void onHoverKey(event::HoverKey &e) override {} | |||||
void onHoverText(event::HoverText &e) override {} | |||||
void onHoverScroll(event::HoverScroll &e) override {} | |||||
void onDragHover(event::DragHover &e) override {} | |||||
void onPathDrop(event::PathDrop &e) override {} | |||||
void onHover(const event::Hover &e) override {} | |||||
void onButton(const event::Button &e) override {} | |||||
void onHoverKey(const event::HoverKey &e) override {} | |||||
void onHoverText(const event::HoverText &e) override {} | |||||
void onHoverScroll(const event::HoverScroll &e) override {} | |||||
void onDragHover(const event::DragHover &e) override {} | |||||
void onPathDrop(const event::PathDrop &e) override {} | |||||
}; | }; | ||||
@@ -75,7 +75,7 @@ struct Widget { | |||||
// Events | // Events | ||||
template <typename TMethod, class TEvent> | template <typename TMethod, class TEvent> | ||||
void recurseEvent(TMethod f, TEvent &e) { | |||||
void recurseEvent(TMethod f, const TEvent &e) { | |||||
for (auto it = children.rbegin(); it != children.rend(); it++) { | for (auto it = children.rbegin(); it != children.rend(); it++) { | ||||
Widget *child = *it; | Widget *child = *it; | ||||
// Filter child by visibility | // Filter child by visibility | ||||
@@ -91,7 +91,7 @@ struct Widget { | |||||
} | } | ||||
template <typename TMethod, class TEvent> | template <typename TMethod, class TEvent> | ||||
void recursePositionEvent(TMethod f, TEvent &e) { | |||||
void recursePositionEvent(TMethod f, const TEvent &e) { | |||||
for (auto it = children.rbegin(); it != children.rend(); it++) { | for (auto it = children.rbegin(); it != children.rend(); it++) { | ||||
Widget *child = *it; | Widget *child = *it; | ||||
// Filter child by visibility and position | // Filter child by visibility and position | ||||
@@ -114,28 +114,28 @@ struct Widget { | |||||
/** Override these event callbacks to respond to events. | /** Override these event callbacks to respond to events. | ||||
See events.hpp for a description of each event. | See events.hpp for a description of each event. | ||||
*/ | */ | ||||
virtual void onHover(event::Hover &e) {recursePositionEvent(&Widget::onHover, e);} | |||||
virtual void onButton(event::Button &e) {recursePositionEvent(&Widget::onButton, e);} | |||||
virtual void onHoverKey(event::HoverKey &e) {recursePositionEvent(&Widget::onHoverKey, e);} | |||||
virtual void onHoverText(event::HoverText &e) {recursePositionEvent(&Widget::onHoverText, e);} | |||||
virtual void onHoverScroll(event::HoverScroll &e) {recursePositionEvent(&Widget::onHoverScroll, e);} | |||||
virtual void onEnter(event::Enter &e) {} | |||||
virtual void onLeave(event::Leave &e) {} | |||||
virtual void onSelect(event::Select &e) {} | |||||
virtual void onDeselect(event::Deselect &e) {} | |||||
virtual void onSelectKey(event::SelectKey &e) {} | |||||
virtual void onSelectText(event::SelectText &e) {} | |||||
virtual void onDragStart(event::DragStart &e) {} | |||||
virtual void onDragEnd(event::DragEnd &e) {} | |||||
virtual void onDragMove(event::DragMove &e) {} | |||||
virtual void onDragHover(event::DragHover &e) {recursePositionEvent(&Widget::onDragHover, e);} | |||||
virtual void onDragEnter(event::DragEnter &e) {} | |||||
virtual void onDragLeave(event::DragLeave &e) {} | |||||
virtual void onDragDrop(event::DragDrop &e) {} | |||||
virtual void onPathDrop(event::PathDrop &e) {recursePositionEvent(&Widget::onPathDrop, e);} | |||||
virtual void onAction(event::Action &e) {} | |||||
virtual void onChange(event::Change &e) {} | |||||
virtual void onZoom(event::Zoom &e) {recurseEvent(&Widget::onZoom, e);} | |||||
virtual void onHover(const event::Hover &e) {recursePositionEvent(&Widget::onHover, e);} | |||||
virtual void onButton(const event::Button &e) {recursePositionEvent(&Widget::onButton, e);} | |||||
virtual void onHoverKey(const event::HoverKey &e) {recursePositionEvent(&Widget::onHoverKey, e);} | |||||
virtual void onHoverText(const event::HoverText &e) {recursePositionEvent(&Widget::onHoverText, e);} | |||||
virtual void onHoverScroll(const event::HoverScroll &e) {recursePositionEvent(&Widget::onHoverScroll, e);} | |||||
virtual void onEnter(const event::Enter &e) {} | |||||
virtual void onLeave(const event::Leave &e) {} | |||||
virtual void onSelect(const event::Select &e) {} | |||||
virtual void onDeselect(const event::Deselect &e) {} | |||||
virtual void onSelectKey(const event::SelectKey &e) {} | |||||
virtual void onSelectText(const event::SelectText &e) {} | |||||
virtual void onDragStart(const event::DragStart &e) {} | |||||
virtual void onDragEnd(const event::DragEnd &e) {} | |||||
virtual void onDragMove(const event::DragMove &e) {} | |||||
virtual void onDragHover(const event::DragHover &e) {recursePositionEvent(&Widget::onDragHover, e);} | |||||
virtual void onDragEnter(const event::DragEnter &e) {} | |||||
virtual void onDragLeave(const event::DragLeave &e) {} | |||||
virtual void onDragDrop(const event::DragDrop &e) {} | |||||
virtual void onPathDrop(const event::PathDrop &e) {recursePositionEvent(&Widget::onPathDrop, e);} | |||||
virtual void onAction(const event::Action &e) {} | |||||
virtual void onChange(const event::Change &e) {} | |||||
virtual void onZoom(const event::Zoom &e) {recurseEvent(&Widget::onZoom, e);} | |||||
}; | }; | ||||
@@ -35,33 +35,40 @@ struct ZoomWidget : virtual Widget { | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
void onHover(event::Hover &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onHover(e); | |||||
void onHover(const event::Hover &e) override { | |||||
event::Hover e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onHover(e2); | |||||
} | } | ||||
void onButton(event::Button &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onButton(e); | |||||
void onButton(const event::Button &e) override { | |||||
event::Button e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onButton(e2); | |||||
} | } | ||||
void onHoverKey(event::HoverKey &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onHoverKey(e); | |||||
void onHoverKey(const event::HoverKey &e) override { | |||||
event::HoverKey e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onHoverKey(e2); | |||||
} | } | ||||
void onHoverText(event::HoverText &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onHoverText(e); | |||||
void onHoverText(const event::HoverText &e) override { | |||||
event::HoverText e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onHoverText(e2); | |||||
} | } | ||||
void onHoverScroll(event::HoverScroll &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onHoverScroll(e); | |||||
void onHoverScroll(const event::HoverScroll &e) override { | |||||
event::HoverScroll e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onHoverScroll(e2); | |||||
} | } | ||||
void onDragHover(event::DragHover &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onDragHover(e); | |||||
void onDragHover(const event::DragHover &e) override { | |||||
event::DragHover e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onDragHover(e2); | |||||
} | } | ||||
void onPathDrop(event::PathDrop &e) override { | |||||
e.pos = e.pos.div(zoom); | |||||
Widget::onPathDrop(e); | |||||
void onPathDrop(const event::PathDrop &e) override { | |||||
event::PathDrop e2 = e; | |||||
e2.pos = e.pos.div(zoom); | |||||
Widget::onPathDrop(e2); | |||||
} | } | ||||
}; | }; | ||||
@@ -11,18 +11,18 @@ struct ModuleResizeHandle : virtual Widget { | |||||
ModuleResizeHandle() { | ModuleResizeHandle() { | ||||
box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT); | box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT); | ||||
} | } | ||||
void onHover(event::Hover &e) override { | |||||
void onHover(const event::Hover &e) override { | |||||
// TODO | // TODO | ||||
// if (e.button == 0) { | // if (e.button == 0) { | ||||
// e.target = this; | // e.target = this; | ||||
// } | // } | ||||
} | } | ||||
void onDragStart(event::DragStart &e) override { | |||||
void onDragStart(const event::DragStart &e) override { | |||||
dragX = context()->scene->rackWidget->lastMousePos.x; | dragX = context()->scene->rackWidget->lastMousePos.x; | ||||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ||||
originalBox = m->box; | originalBox = m->box; | ||||
} | } | ||||
void onDragMove(event::DragMove &e) override { | |||||
void onDragMove(const event::DragMove &e) override { | |||||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ||||
float newDragX = context()->scene->rackWidget->lastMousePos.x; | float newDragX = context()->scene->rackWidget->lastMousePos.x; | ||||
@@ -134,20 +134,20 @@ struct MidiCcChoice : GridChoice { | |||||
} | } | ||||
} | } | ||||
void onSelect(event::Select &e) override { | |||||
void onSelect(const event::Select &e) override { | |||||
e.consume(this); | e.consume(this); | ||||
module->learningId = id; | module->learningId = id; | ||||
focusCc = -1; | focusCc = -1; | ||||
} | } | ||||
void onDeselect(event::Deselect &e) override { | |||||
void onDeselect(const event::Deselect &e) override { | |||||
if (0 <= focusCc && focusCc < 128) { | if (0 <= focusCc && focusCc < 128) { | ||||
module->learnedCcs[id] = focusCc; | module->learnedCcs[id] = focusCc; | ||||
} | } | ||||
module->learningId = -1; | module->learningId = -1; | ||||
} | } | ||||
void onSelectText(event::SelectText &e) override { | |||||
void onSelectText(const event::SelectText &e) override { | |||||
char c = e.codepoint; | char c = e.codepoint; | ||||
if ('0' <= c && c <= '9') { | if ('0' <= c && c <= '9') { | ||||
if (focusCc < 0) | if (focusCc < 0) | ||||
@@ -157,7 +157,7 @@ struct MidiCcChoice : GridChoice { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onSelectKey(event::SelectKey &e) override { | |||||
void onSelectKey(const event::SelectKey &e) override { | |||||
if (context()->event->selectedWidget == this) { | if (context()->event->selectedWidget == this) { | ||||
if (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) { | if (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) { | ||||
event::Deselect eDeselect; | event::Deselect eDeselect; | ||||
@@ -294,7 +294,7 @@ struct MIDIToCVInterfaceWidget : ModuleWidget { | |||||
MIDIToCVInterface *module; | MIDIToCVInterface *module; | ||||
int index; | int index; | ||||
int division; | int division; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->divisions[index] = division; | module->divisions[index] = division; | ||||
} | } | ||||
}; | }; | ||||
@@ -178,12 +178,12 @@ struct MidiTrigChoice : GridChoice { | |||||
} | } | ||||
} | } | ||||
void onSelect(event::Select &e) override { | |||||
void onSelect(const event::Select &e) override { | |||||
e.consume(this); | e.consume(this); | ||||
module->learningId = id; | module->learningId = id; | ||||
} | } | ||||
void onDeselect(event::Deselect &e) override { | |||||
void onDeselect(const event::Deselect &e) override { | |||||
module->learningId = -1; | module->learningId = -1; | ||||
} | } | ||||
}; | }; | ||||
@@ -238,7 +238,7 @@ struct MIDITriggerToCVInterfaceWidget : ModuleWidget { | |||||
struct VelocityItem : MenuItem { | struct VelocityItem : MenuItem { | ||||
MIDITriggerToCVInterface *module; | MIDITriggerToCVInterface *module; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->velocity ^= true; | module->velocity ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -339,7 +339,7 @@ struct QuadMIDIToCVInterfaceWidget : ModuleWidget { | |||||
struct PolyphonyItem : MenuItem { | struct PolyphonyItem : MenuItem { | ||||
QuadMIDIToCVInterface *module; | QuadMIDIToCVInterface *module; | ||||
QuadMIDIToCVInterface::PolyMode polyMode; | QuadMIDIToCVInterface::PolyMode polyMode; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->polyMode = polyMode; | module->polyMode = polyMode; | ||||
module->onReset(); | module->onReset(); | ||||
} | } | ||||
@@ -9,14 +9,14 @@ namespace rack { | |||||
struct AudioDriverItem : MenuItem { | struct AudioDriverItem : MenuItem { | ||||
audio::IO *audioIO; | audio::IO *audioIO; | ||||
int driver; | int driver; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
audioIO->setDriver(driver); | audioIO->setDriver(driver); | ||||
} | } | ||||
}; | }; | ||||
struct AudioDriverChoice : LedDisplayChoice { | struct AudioDriverChoice : LedDisplayChoice { | ||||
AudioWidget *audioWidget; | AudioWidget *audioWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("Audio driver")); | menu->addChild(createMenuLabel("Audio driver")); | ||||
for (int driver : audioWidget->audioIO->getDrivers()) { | for (int driver : audioWidget->audioIO->getDrivers()) { | ||||
@@ -38,7 +38,7 @@ struct AudioDeviceItem : MenuItem { | |||||
audio::IO *audioIO; | audio::IO *audioIO; | ||||
int device; | int device; | ||||
int offset; | int offset; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
audioIO->setDevice(device, offset); | audioIO->setDevice(device, offset); | ||||
} | } | ||||
}; | }; | ||||
@@ -48,7 +48,7 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
/** Prevents devices with a ridiculous number of channels from being displayed */ | /** Prevents devices with a ridiculous number of channels from being displayed */ | ||||
int maxTotalChannels = 128; | int maxTotalChannels = 128; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("Audio device")); | menu->addChild(createMenuLabel("Audio device")); | ||||
int deviceCount = audioWidget->audioIO->getDeviceCount(); | int deviceCount = audioWidget->audioIO->getDeviceCount(); | ||||
@@ -89,14 +89,14 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
struct AudioSampleRateItem : MenuItem { | struct AudioSampleRateItem : MenuItem { | ||||
audio::IO *audioIO; | audio::IO *audioIO; | ||||
int sampleRate; | int sampleRate; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
audioIO->setSampleRate(sampleRate); | audioIO->setSampleRate(sampleRate); | ||||
} | } | ||||
}; | }; | ||||
struct AudioSampleRateChoice : LedDisplayChoice { | struct AudioSampleRateChoice : LedDisplayChoice { | ||||
AudioWidget *audioWidget; | AudioWidget *audioWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("Sample rate")); | menu->addChild(createMenuLabel("Sample rate")); | ||||
std::vector<int> sampleRates = audioWidget->audioIO->getSampleRates(); | std::vector<int> sampleRates = audioWidget->audioIO->getSampleRates(); | ||||
@@ -121,14 +121,14 @@ struct AudioSampleRateChoice : LedDisplayChoice { | |||||
struct AudioBlockSizeItem : MenuItem { | struct AudioBlockSizeItem : MenuItem { | ||||
audio::IO *audioIO; | audio::IO *audioIO; | ||||
int blockSize; | int blockSize; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
audioIO->setBlockSize(blockSize); | audioIO->setBlockSize(blockSize); | ||||
} | } | ||||
}; | }; | ||||
struct AudioBlockSizeChoice : LedDisplayChoice { | struct AudioBlockSizeChoice : LedDisplayChoice { | ||||
AudioWidget *audioWidget; | AudioWidget *audioWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("Block size")); | menu->addChild(createMenuLabel("Block size")); | ||||
std::vector<int> blockSizes = audioWidget->audioIO->getBlockSizes(); | std::vector<int> blockSizes = audioWidget->audioIO->getBlockSizes(); | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void Knob::onButton(event::Button &e) { | |||||
void Knob::onButton(const event::Button &e) { | |||||
float r = box.size.x / 2; | float r = box.size.x / 2; | ||||
math::Vec c = box.size.div(2); | math::Vec c = box.size.div(2); | ||||
float dist = e.pos.minus(c).norm(); | float dist = e.pos.minus(c).norm(); | ||||
@@ -13,15 +13,15 @@ void Knob::onButton(event::Button &e) { | |||||
} | } | ||||
} | } | ||||
void Knob::onDragStart(event::DragStart &e) { | |||||
void Knob::onDragStart(const event::DragStart &e) { | |||||
context()->window->cursorLock(); | context()->window->cursorLock(); | ||||
} | } | ||||
void Knob::onDragEnd(event::DragEnd &e) { | |||||
void Knob::onDragEnd(const event::DragEnd &e) { | |||||
context()->window->cursorUnlock(); | context()->window->cursorUnlock(); | ||||
} | } | ||||
void Knob::onDragMove(event::DragMove &e) { | |||||
void Knob::onDragMove(const event::DragMove &e) { | |||||
if (quantity) { | if (quantity) { | ||||
float range; | float range; | ||||
if (quantity->isBounded()) { | if (quantity->isBounded()) { | ||||
@@ -54,7 +54,7 @@ void LedDisplayChoice::draw(NVGcontext *vg) { | |||||
nvgResetScissor(vg); | nvgResetScissor(vg); | ||||
} | } | ||||
void LedDisplayChoice::onButton(event::Button &e) { | |||||
void LedDisplayChoice::onButton(const event::Button &e) { | |||||
if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) { | if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) { | ||||
event::Action eAction; | event::Action eAction; | ||||
onAction(eAction); | onAction(eAction); | ||||
@@ -9,14 +9,14 @@ namespace rack { | |||||
struct MidiDriverItem : MenuItem { | struct MidiDriverItem : MenuItem { | ||||
midi::IO *midiIO; | midi::IO *midiIO; | ||||
int driverId; | int driverId; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
midiIO->setDriverId(driverId); | midiIO->setDriverId(driverId); | ||||
} | } | ||||
}; | }; | ||||
struct MidiDriverChoice : LedDisplayChoice { | struct MidiDriverChoice : LedDisplayChoice { | ||||
MidiWidget *midiWidget; | MidiWidget *midiWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("MIDI driver")); | menu->addChild(createMenuLabel("MIDI driver")); | ||||
for (int driverId : midiWidget->midiIO->getDriverIds()) { | for (int driverId : midiWidget->midiIO->getDriverIds()) { | ||||
@@ -43,14 +43,14 @@ struct MidiDriverChoice : LedDisplayChoice { | |||||
struct MidiDeviceItem : MenuItem { | struct MidiDeviceItem : MenuItem { | ||||
midi::IO *midiIO; | midi::IO *midiIO; | ||||
int deviceId; | int deviceId; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
midiIO->setDeviceId(deviceId); | midiIO->setDeviceId(deviceId); | ||||
} | } | ||||
}; | }; | ||||
struct MidiDeviceChoice : LedDisplayChoice { | struct MidiDeviceChoice : LedDisplayChoice { | ||||
MidiWidget *midiWidget; | MidiWidget *midiWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("MIDI device")); | menu->addChild(createMenuLabel("MIDI device")); | ||||
{ | { | ||||
@@ -85,14 +85,14 @@ struct MidiDeviceChoice : LedDisplayChoice { | |||||
struct MidiChannelItem : MenuItem { | struct MidiChannelItem : MenuItem { | ||||
midi::IO *midiIO; | midi::IO *midiIO; | ||||
int channel; | int channel; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
midiIO->channel = channel; | midiIO->channel = channel; | ||||
} | } | ||||
}; | }; | ||||
struct MidiChannelChoice : LedDisplayChoice { | struct MidiChannelChoice : LedDisplayChoice { | ||||
MidiWidget *midiWidget; | MidiWidget *midiWidget; | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->addChild(createMenuLabel("MIDI channel")); | menu->addChild(createMenuLabel("MIDI channel")); | ||||
for (int channel = -1; channel < 16; channel++) { | for (int channel = -1; channel < 16; channel++) { | ||||
@@ -68,7 +68,7 @@ struct FavoriteRadioButton : RadioButton { | |||||
quantity = new FavoriteQuantity; | quantity = new FavoriteQuantity; | ||||
} | } | ||||
void onAction(event::Action &e) override; | |||||
void onAction(const event::Action &e) override; | |||||
}; | }; | ||||
@@ -101,9 +101,9 @@ struct BrowserListItem : OpaqueWidget { | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
void onDragStart(event::DragStart &e) override; | |||||
void onDragStart(const event::DragStart &e) override; | |||||
void onDragDrop(event::DragDrop &e) override { | |||||
void onDragDrop(const event::DragDrop &e) override { | |||||
if (e.origin != this) | if (e.origin != this) | ||||
return; | return; | ||||
doAction(); | doAction(); | ||||
@@ -159,7 +159,7 @@ struct ModelItem : BrowserListItem { | |||||
pluginLabel->box.size.x = box.size.x - BND_SCROLLBAR_WIDTH; | pluginLabel->box.size.x = box.size.x - BND_SCROLLBAR_WIDTH; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ModuleWidget *moduleWidget = model->createModuleWidget(); | ModuleWidget *moduleWidget = model->createModuleWidget(); | ||||
if (!moduleWidget) | if (!moduleWidget) | ||||
return; | return; | ||||
@@ -185,7 +185,7 @@ struct AuthorItem : BrowserListItem { | |||||
addChild(authorLabel); | addChild(authorLabel); | ||||
} | } | ||||
void onAction(event::Action &e) override; | |||||
void onAction(const event::Action &e) override; | |||||
}; | }; | ||||
@@ -203,7 +203,7 @@ struct TagItem : BrowserListItem { | |||||
addChild(tagLabel); | addChild(tagLabel); | ||||
} | } | ||||
void onAction(event::Action &e) override; | |||||
void onAction(const event::Action &e) override; | |||||
}; | }; | ||||
@@ -214,7 +214,7 @@ struct ClearFilterItem : BrowserListItem { | |||||
addChild(label); | addChild(label); | ||||
} | } | ||||
void onAction(event::Action &e) override; | |||||
void onAction(const event::Action &e) override; | |||||
}; | }; | ||||
@@ -294,8 +294,8 @@ struct ModuleBrowser; | |||||
struct SearchModuleField : TextField { | struct SearchModuleField : TextField { | ||||
ModuleBrowser *moduleBrowser; | ModuleBrowser *moduleBrowser; | ||||
void onChange(event::Change &e) override; | |||||
void onSelectKey(event::SelectKey &e) override; | |||||
void onChange(const event::Change &e) override; | |||||
void onSelectKey(const event::SelectKey &e) override; | |||||
}; | }; | ||||
@@ -459,7 +459,7 @@ struct ModuleBrowser : OpaqueWidget { | |||||
// Implementations of inline methods above | // Implementations of inline methods above | ||||
void AuthorItem::onAction(event::Action &e) { | |||||
void AuthorItem::onAction(const event::Action &e) { | |||||
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ||||
sAuthorFilter = author; | sAuthorFilter = author; | ||||
moduleBrowser->clearSearch(); | moduleBrowser->clearSearch(); | ||||
@@ -467,7 +467,7 @@ void AuthorItem::onAction(event::Action &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void TagItem::onAction(event::Action &e) { | |||||
void TagItem::onAction(const event::Action &e) { | |||||
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ||||
sTagFilter = tag; | sTagFilter = tag; | ||||
moduleBrowser->clearSearch(); | moduleBrowser->clearSearch(); | ||||
@@ -475,7 +475,7 @@ void TagItem::onAction(event::Action &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void ClearFilterItem::onAction(event::Action &e) { | |||||
void ClearFilterItem::onAction(const event::Action &e) { | |||||
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); | ||||
sAuthorFilter = ""; | sAuthorFilter = ""; | ||||
sTagFilter = ""; | sTagFilter = ""; | ||||
@@ -483,7 +483,7 @@ void ClearFilterItem::onAction(event::Action &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void FavoriteRadioButton::onAction(event::Action &e) { | |||||
void FavoriteRadioButton::onAction(const event::Action &e) { | |||||
if (!model) | if (!model) | ||||
return; | return; | ||||
if (quantity->isMax()) { | if (quantity->isMax()) { | ||||
@@ -500,18 +500,18 @@ void FavoriteRadioButton::onAction(event::Action &e) { | |||||
moduleBrowser->refreshSearch(); | moduleBrowser->refreshSearch(); | ||||
} | } | ||||
void BrowserListItem::onDragStart(event::DragStart &e) { | |||||
void BrowserListItem::onDragStart(const event::DragStart &e) { | |||||
BrowserList *list = dynamic_cast<BrowserList*>(parent); | BrowserList *list = dynamic_cast<BrowserList*>(parent); | ||||
if (list) { | if (list) { | ||||
list->selectItem(this); | list->selectItem(this); | ||||
} | } | ||||
} | } | ||||
void SearchModuleField::onChange(event::Change &e) { | |||||
void SearchModuleField::onChange(const event::Change &e) { | |||||
moduleBrowser->refreshSearch(); | moduleBrowser->refreshSearch(); | ||||
} | } | ||||
void SearchModuleField::onSelectKey(event::SelectKey &e) { | |||||
void SearchModuleField::onSelectKey(const event::SelectKey &e) { | |||||
if (e.action == GLFW_PRESS) { | if (e.action == GLFW_PRESS) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_ESCAPE: { | case GLFW_KEY_ESCAPE: { | ||||
@@ -315,7 +315,7 @@ void ModuleWidget::drawShadow(NVGcontext *vg) { | |||||
nvgFill(vg); | nvgFill(vg); | ||||
} | } | ||||
void ModuleWidget::onHover(event::Hover &e) { | |||||
void ModuleWidget::onHover(const event::Hover &e) { | |||||
OpaqueWidget::onHover(e); | OpaqueWidget::onHover(e); | ||||
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | ||||
@@ -327,7 +327,7 @@ void ModuleWidget::onHover(event::Hover &e) { | |||||
} | } | ||||
} | } | ||||
void ModuleWidget::onButton(event::Button &e) { | |||||
void ModuleWidget::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getConsumed() == this) { | if (e.getConsumed() == this) { | ||||
if (e.button == 1) { | if (e.button == 1) { | ||||
@@ -336,7 +336,7 @@ void ModuleWidget::onButton(event::Button &e) { | |||||
} | } | ||||
} | } | ||||
void ModuleWidget::onHoverKey(event::HoverKey &e) { | |||||
void ModuleWidget::onHoverKey(const event::HoverKey &e) { | |||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_I: { | case GLFW_KEY_I: { | ||||
@@ -382,14 +382,14 @@ void ModuleWidget::onHoverKey(event::HoverKey &e) { | |||||
OpaqueWidget::onHoverKey(e); | OpaqueWidget::onHoverKey(e); | ||||
} | } | ||||
void ModuleWidget::onDragStart(event::DragStart &e) { | |||||
void ModuleWidget::onDragStart(const event::DragStart &e) { | |||||
dragPos = context()->scene->rackWidget->lastMousePos.minus(box.pos); | dragPos = context()->scene->rackWidget->lastMousePos.minus(box.pos); | ||||
} | } | ||||
void ModuleWidget::onDragEnd(event::DragEnd &e) { | |||||
void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||||
} | } | ||||
void ModuleWidget::onDragMove(event::DragMove &e) { | |||||
void ModuleWidget::onDragMove(const event::DragMove &e) { | |||||
if (!settings::lockModules) { | if (!settings::lockModules) { | ||||
math::Rect newBox = box; | math::Rect newBox = box; | ||||
newBox.pos = context()->scene->rackWidget->lastMousePos.minus(dragPos); | newBox.pos = context()->scene->rackWidget->lastMousePos.minus(dragPos); | ||||
@@ -404,7 +404,7 @@ struct ModuleDisconnectItem : MenuItem { | |||||
text = "Disconnect cables"; | text = "Disconnect cables"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+U"; | rightText = WINDOW_MOD_KEY_NAME "+U"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->disconnect(); | moduleWidget->disconnect(); | ||||
} | } | ||||
}; | }; | ||||
@@ -415,7 +415,7 @@ struct ModuleResetItem : MenuItem { | |||||
text = "Initialize"; | text = "Initialize"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+I"; | rightText = WINDOW_MOD_KEY_NAME "+I"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->reset(); | moduleWidget->reset(); | ||||
} | } | ||||
}; | }; | ||||
@@ -426,7 +426,7 @@ struct ModuleRandomizeItem : MenuItem { | |||||
text = "Randomize"; | text = "Randomize"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+R"; | rightText = WINDOW_MOD_KEY_NAME "+R"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->randomize(); | moduleWidget->randomize(); | ||||
} | } | ||||
}; | }; | ||||
@@ -437,7 +437,7 @@ struct ModuleCopyItem : MenuItem { | |||||
text = "Copy preset"; | text = "Copy preset"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+C"; | rightText = WINDOW_MOD_KEY_NAME "+C"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->copyClipboard(); | moduleWidget->copyClipboard(); | ||||
} | } | ||||
}; | }; | ||||
@@ -448,7 +448,7 @@ struct ModulePasteItem : MenuItem { | |||||
text = "Paste preset"; | text = "Paste preset"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+V"; | rightText = WINDOW_MOD_KEY_NAME "+V"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->pasteClipboard(); | moduleWidget->pasteClipboard(); | ||||
} | } | ||||
}; | }; | ||||
@@ -458,7 +458,7 @@ struct ModuleSaveItem : MenuItem { | |||||
ModuleSaveItem() { | ModuleSaveItem() { | ||||
text = "Save preset"; | text = "Save preset"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->saveDialog(); | moduleWidget->saveDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -468,7 +468,7 @@ struct ModuleLoadItem : MenuItem { | |||||
ModuleLoadItem() { | ModuleLoadItem() { | ||||
text = "Load preset"; | text = "Load preset"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->loadDialog(); | moduleWidget->loadDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -479,7 +479,7 @@ struct ModuleCloneItem : MenuItem { | |||||
text = "Duplicate"; | text = "Duplicate"; | ||||
rightText = WINDOW_MOD_KEY_NAME "+D"; | rightText = WINDOW_MOD_KEY_NAME "+D"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->cloneModule(moduleWidget); | context()->scene->rackWidget->cloneModule(moduleWidget); | ||||
} | } | ||||
}; | }; | ||||
@@ -490,7 +490,7 @@ struct ModuleDeleteItem : MenuItem { | |||||
text = "Delete"; | text = "Delete"; | ||||
rightText = "Backspace/Delete"; | rightText = "Backspace/Delete"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->deleteModule(moduleWidget); | context()->scene->rackWidget->deleteModule(moduleWidget); | ||||
delete moduleWidget; | delete moduleWidget; | ||||
} | } | ||||
@@ -4,13 +4,13 @@ | |||||
namespace rack { | namespace rack { | ||||
void MomentarySwitch::onDragStart(event::DragStart &e) { | |||||
void MomentarySwitch::onDragStart(const event::DragStart &e) { | |||||
if (quantity) { | if (quantity) { | ||||
quantity->setMax(); | quantity->setMax(); | ||||
} | } | ||||
} | } | ||||
void MomentarySwitch::onDragEnd(event::DragEnd &e) { | |||||
void MomentarySwitch::onDragEnd(const event::DragEnd &e) { | |||||
if (quantity) { | if (quantity) { | ||||
quantity->setMin(); | quantity->setMin(); | ||||
} | } | ||||
@@ -27,7 +27,7 @@ void ParamWidget::fromJson(json_t *rootJ) { | |||||
} | } | ||||
} | } | ||||
void ParamWidget::onButton(event::Button &e) { | |||||
void ParamWidget::onButton(const event::Button &e) { | |||||
// Right click to reset | // Right click to reset | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | ||||
if (quantity) | if (quantity) | ||||
@@ -39,7 +39,7 @@ void ParamWidget::onButton(event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
} | } | ||||
void ParamWidget::onDragMove(event::DragMove &e) { | |||||
void ParamWidget::onDragMove(const event::DragMove &e) { | |||||
if (quantity) { | if (quantity) { | ||||
DEBUG("%s", quantity->getString().c_str()); | DEBUG("%s", quantity->getString().c_str()); | ||||
} | } | ||||
@@ -50,7 +50,7 @@ void PortWidget::draw(NVGcontext *vg) { | |||||
} | } | ||||
} | } | ||||
void PortWidget::onButton(event::Button &e) { | |||||
void PortWidget::onButton(const event::Button &e) { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | ||||
context()->scene->rackWidget->wireContainer->removeTopWire(this); | context()->scene->rackWidget->wireContainer->removeTopWire(this); | ||||
@@ -62,7 +62,7 @@ void PortWidget::onButton(event::Button &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void PortWidget::onDragStart(event::DragStart &e) { | |||||
void PortWidget::onDragStart(const event::DragStart &e) { | |||||
// Try to grab wire on top of stack | // Try to grab wire on top of stack | ||||
WireWidget *wire = NULL; | WireWidget *wire = NULL; | ||||
if (type == INPUT || !context()->window->isModPressed()) { | if (type == INPUT || !context()->window->isModPressed()) { | ||||
@@ -82,13 +82,13 @@ void PortWidget::onDragStart(event::DragStart &e) { | |||||
context()->scene->rackWidget->wireContainer->setActiveWire(wire); | context()->scene->rackWidget->wireContainer->setActiveWire(wire); | ||||
} | } | ||||
void PortWidget::onDragEnd(event::DragEnd &e) { | |||||
void PortWidget::onDragEnd(const event::DragEnd &e) { | |||||
// FIXME | // FIXME | ||||
// If the source PortWidget is deleted, this will be called, removing the cable | // If the source PortWidget is deleted, this will be called, removing the cable | ||||
context()->scene->rackWidget->wireContainer->commitActiveWire(); | context()->scene->rackWidget->wireContainer->commitActiveWire(); | ||||
} | } | ||||
void PortWidget::onDragDrop(event::DragDrop &e) { | |||||
void PortWidget::onDragDrop(const event::DragDrop &e) { | |||||
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | ||||
if (!originPort) | if (!originPort) | ||||
return; | return; | ||||
@@ -99,7 +99,7 @@ void PortWidget::onDragDrop(event::DragDrop &e) { | |||||
onDragEnter(eDragEnter); | onDragEnter(eDragEnter); | ||||
} | } | ||||
void PortWidget::onDragEnter(event::DragEnter &e) { | |||||
void PortWidget::onDragEnter(const event::DragEnter &e) { | |||||
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | ||||
if (!originPort) | if (!originPort) | ||||
return; | return; | ||||
@@ -117,7 +117,7 @@ void PortWidget::onDragEnter(event::DragEnter &e) { | |||||
} | } | ||||
} | } | ||||
void PortWidget::onDragLeave(event::DragLeave &e) { | |||||
void PortWidget::onDragLeave(const event::DragLeave &e) { | |||||
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | ||||
if (!originPort) | if (!originPort) | ||||
return; | return; | ||||
@@ -539,17 +539,17 @@ void RackWidget::draw(NVGcontext *vg) { | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
void RackWidget::onHover(event::Hover &e) { | |||||
void RackWidget::onHover(const event::Hover &e) { | |||||
OpaqueWidget::onHover(e); | OpaqueWidget::onHover(e); | ||||
lastMousePos = e.pos; | lastMousePos = e.pos; | ||||
} | } | ||||
void RackWidget::onDragHover(event::DragHover &e) { | |||||
void RackWidget::onDragHover(const event::DragHover &e) { | |||||
OpaqueWidget::onDragHover(e); | OpaqueWidget::onDragHover(e); | ||||
lastMousePos = e.pos; | lastMousePos = e.pos; | ||||
} | } | ||||
void RackWidget::onButton(event::Button &e) { | |||||
void RackWidget::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getConsumed() == this) { | if (e.getConsumed() == this) { | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | ||||
@@ -558,7 +558,7 @@ void RackWidget::onButton(event::Button &e) { | |||||
} | } | ||||
} | } | ||||
void RackWidget::onZoom(event::Zoom &e) { | |||||
void RackWidget::onZoom(const event::Zoom &e) { | |||||
rails->box.size = math::Vec(); | rails->box.size = math::Vec(); | ||||
OpaqueWidget::onZoom(e); | OpaqueWidget::onZoom(e); | ||||
} | } | ||||
@@ -16,14 +16,14 @@ void SVGButton::setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> ac | |||||
this->activeSVG = activeSVG ? activeSVG : defaultSVG; | this->activeSVG = activeSVG ? activeSVG : defaultSVG; | ||||
} | } | ||||
void SVGButton::onDragStart(event::DragStart &e) { | |||||
void SVGButton::onDragStart(const event::DragStart &e) { | |||||
event::Action eAction; | event::Action eAction; | ||||
onAction(eAction); | onAction(eAction); | ||||
sw->setSVG(activeSVG); | sw->setSVG(activeSVG); | ||||
dirty = true; | dirty = true; | ||||
} | } | ||||
void SVGButton::onDragEnd(event::DragEnd &e) { | |||||
void SVGButton::onDragEnd(const event::DragEnd &e) { | |||||
sw->setSVG(defaultSVG); | sw->setSVG(defaultSVG); | ||||
dirty = true; | dirty = true; | ||||
} | } | ||||
@@ -30,7 +30,7 @@ void SVGKnob::step() { | |||||
FramebufferWidget::step(); | FramebufferWidget::step(); | ||||
} | } | ||||
void SVGKnob::onChange(event::Change &e) { | |||||
void SVGKnob::onChange(const event::Change &e) { | |||||
// Re-transform the TransformWidget | // Re-transform the TransformWidget | ||||
if (quantity) { | if (quantity) { | ||||
float angle; | float angle; | ||||
@@ -27,7 +27,7 @@ void SVGSlider::step() { | |||||
FramebufferWidget::step(); | FramebufferWidget::step(); | ||||
} | } | ||||
void SVGSlider::onChange(event::Change &e) { | |||||
void SVGSlider::onChange(const event::Change &e) { | |||||
if (quantity) { | if (quantity) { | ||||
// Interpolate handle position | // Interpolate handle position | ||||
float v = quantity->getScaledValue(); | float v = quantity->getScaledValue(); | ||||
@@ -23,7 +23,7 @@ void SVGSwitch::addFrame(std::shared_ptr<SVG> svg) { | |||||
} | } | ||||
} | } | ||||
void SVGSwitch::onChange(event::Change &e) { | |||||
void SVGSwitch::onChange(const event::Change &e) { | |||||
assert(frames.size() > 0); | assert(frames.size() > 0); | ||||
if (quantity) { | if (quantity) { | ||||
int index = quantity->getScaledValue() * (frames.size() - 1); | int index = quantity->getScaledValue() * (frames.size() - 1); | ||||
@@ -66,7 +66,7 @@ void Scene::draw(NVGcontext *vg) { | |||||
OpaqueWidget::draw(vg); | OpaqueWidget::draw(vg); | ||||
} | } | ||||
void Scene::onHoverKey(event::HoverKey &e) { | |||||
void Scene::onHoverKey(const event::HoverKey &e) { | |||||
if (e.action == GLFW_PRESS) { | if (e.action == GLFW_PRESS) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_N: { | case GLFW_KEY_N: { | ||||
@@ -123,7 +123,7 @@ void Scene::onHoverKey(event::HoverKey &e) { | |||||
OpaqueWidget::onHoverKey(e); | OpaqueWidget::onHoverKey(e); | ||||
} | } | ||||
void Scene::onPathDrop(event::PathDrop &e) { | |||||
void Scene::onPathDrop(const event::PathDrop &e) { | |||||
if (e.paths.size() >= 1) { | if (e.paths.size() >= 1) { | ||||
const std::string &path = e.paths[0]; | const std::string &path = e.paths[0]; | ||||
if (string::extension(path) == "vcv") { | if (string::extension(path) == "vcv") { | ||||
@@ -4,7 +4,7 @@ | |||||
namespace rack { | namespace rack { | ||||
void ToggleSwitch::onDragStart(event::DragStart &e) { | |||||
void ToggleSwitch::onDragStart(const event::DragStart &e) { | |||||
// Cycle through values | // Cycle through values | ||||
// e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3. | // e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3. | ||||
if (quantity) { | if (quantity) { | ||||
@@ -37,7 +37,7 @@ struct NewItem : MenuItem { | |||||
text = "New"; | text = "New"; | ||||
rightText = "(" WINDOW_MOD_KEY_NAME "+N)"; | rightText = "(" WINDOW_MOD_KEY_NAME "+N)"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->reset(); | context()->scene->rackWidget->reset(); | ||||
} | } | ||||
}; | }; | ||||
@@ -48,7 +48,7 @@ struct OpenItem : MenuItem { | |||||
text = "Open"; | text = "Open"; | ||||
rightText = "(" WINDOW_MOD_KEY_NAME "+O)"; | rightText = "(" WINDOW_MOD_KEY_NAME "+O)"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->loadDialog(); | context()->scene->rackWidget->loadDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -59,7 +59,7 @@ struct SaveItem : MenuItem { | |||||
text = "Save"; | text = "Save"; | ||||
rightText = "(" WINDOW_MOD_KEY_NAME "+S)"; | rightText = "(" WINDOW_MOD_KEY_NAME "+S)"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->saveDialog(); | context()->scene->rackWidget->saveDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -70,7 +70,7 @@ struct SaveAsItem : MenuItem { | |||||
text = "Save as"; | text = "Save as"; | ||||
rightText = "(" WINDOW_MOD_KEY_NAME "+Shift+S)"; | rightText = "(" WINDOW_MOD_KEY_NAME "+Shift+S)"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->saveAsDialog(); | context()->scene->rackWidget->saveAsDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -80,7 +80,7 @@ struct RevertItem : MenuItem { | |||||
RevertItem() { | RevertItem() { | ||||
text = "Revert"; | text = "Revert"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->revert(); | context()->scene->rackWidget->revert(); | ||||
} | } | ||||
}; | }; | ||||
@@ -90,7 +90,7 @@ struct DisconnectCablesItem : MenuItem { | |||||
DisconnectCablesItem() { | DisconnectCablesItem() { | ||||
text = "Disconnect cables"; | text = "Disconnect cables"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->scene->rackWidget->disconnect(); | context()->scene->rackWidget->disconnect(); | ||||
} | } | ||||
}; | }; | ||||
@@ -100,7 +100,7 @@ struct FileButton : MenuButton { | |||||
FileButton() { | FileButton() { | ||||
text = "File"; | text = "File"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -168,7 +168,7 @@ struct PowerMeterItem : MenuItem { | |||||
text = "Power meter"; | text = "Power meter"; | ||||
rightText = CHECKMARK(settings::powerMeter); | rightText = CHECKMARK(settings::powerMeter); | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::powerMeter ^= true; | settings::powerMeter ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -179,7 +179,7 @@ struct LockModulesItem : MenuItem { | |||||
text = "Lock modules"; | text = "Lock modules"; | ||||
rightText = CHECKMARK(settings::lockModules); | rightText = CHECKMARK(settings::lockModules); | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::lockModules ^= true; | settings::lockModules ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -190,7 +190,7 @@ struct EnginePauseItem : MenuItem { | |||||
text = "Pause engine"; | text = "Pause engine"; | ||||
rightText = CHECKMARK(context()->engine->paused); | rightText = CHECKMARK(context()->engine->paused); | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->engine->paused ^= true; | context()->engine->paused ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -203,7 +203,7 @@ struct SampleRateValueItem : MenuItem { | |||||
text = string::f("%.0f Hz", sampleRate); | text = string::f("%.0f Hz", sampleRate); | ||||
rightText = CHECKMARK(context()->engine->getSampleRate() == sampleRate); | rightText = CHECKMARK(context()->engine->getSampleRate() == sampleRate); | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
context()->engine->setSampleRate(sampleRate); | context()->engine->setSampleRate(sampleRate); | ||||
context()->engine->paused = false; | context()->engine->paused = false; | ||||
} | } | ||||
@@ -232,7 +232,7 @@ struct SettingsButton : MenuButton { | |||||
SettingsButton() { | SettingsButton() { | ||||
text = "Settings"; | text = "Settings"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -263,7 +263,7 @@ struct RegisterItem : MenuItem { | |||||
RegisterItem() { | RegisterItem() { | ||||
text = "Register VCV account"; | text = "Register VCV account"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/"); | system::openBrowser("https://vcvrack.com/"); | ||||
}); | }); | ||||
@@ -277,7 +277,7 @@ struct AccountEmailField : TextField { | |||||
AccountEmailField() { | AccountEmailField() { | ||||
placeholder = "Email"; | placeholder = "Email"; | ||||
} | } | ||||
void onSelectKey(event::SelectKey &e) override { | |||||
void onSelectKey(const event::SelectKey &e) override { | |||||
if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) { | if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) { | ||||
context()->event->selectedWidget = passwordField; | context()->event->selectedWidget = passwordField; | ||||
e.consume(this); | e.consume(this); | ||||
@@ -293,7 +293,7 @@ struct AccountPasswordField : PasswordField { | |||||
AccountPasswordField() { | AccountPasswordField() { | ||||
placeholder = "Password"; | placeholder = "Password"; | ||||
} | } | ||||
void onSelectKey(event::SelectKey &e) override { | |||||
void onSelectKey(const event::SelectKey &e) override { | |||||
if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { | if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { | ||||
logInItem->doAction(); | logInItem->doAction(); | ||||
e.consume(this); | e.consume(this); | ||||
@@ -310,7 +310,7 @@ struct LogInItem : MenuItem { | |||||
LogInItem() { | LogInItem() { | ||||
text = "Log in"; | text = "Log in"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::string email = emailField->text; | std::string email = emailField->text; | ||||
std::string password = passwordField->text; | std::string password = passwordField->text; | ||||
std::thread t([&, email, password]() { | std::thread t([&, email, password]() { | ||||
@@ -325,7 +325,7 @@ struct ManageItem : MenuItem { | |||||
ManageItem() { | ManageItem() { | ||||
text = "Manage plugins"; | text = "Manage plugins"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/plugins.html"); | system::openBrowser("https://vcvrack.com/plugins.html"); | ||||
}); | }); | ||||
@@ -339,7 +339,7 @@ struct SyncItem : MenuItem { | |||||
text = "Sync plugins"; | text = "Sync plugins"; | ||||
disabled = true; | disabled = true; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
} | } | ||||
}; | }; | ||||
@@ -369,7 +369,7 @@ struct SyncItem : MenuItem { | |||||
// completed = false; | // completed = false; | ||||
// } | // } | ||||
// } | // } | ||||
// void onAction(event::Action &e) override { | |||||
// void onAction(const event::Action &e) override { | |||||
// available = false; | // available = false; | ||||
// std::thread t([this]() { | // std::thread t([this]() { | ||||
// if (plugin::sync(false)) | // if (plugin::sync(false)) | ||||
@@ -384,7 +384,7 @@ struct LogOutItem : MenuItem { | |||||
LogOutItem() { | LogOutItem() { | ||||
text = "Log out"; | text = "Log out"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
plugin::logOut(); | plugin::logOut(); | ||||
} | } | ||||
}; | }; | ||||
@@ -413,7 +413,7 @@ struct PluginsButton : MenuButton { | |||||
PluginsButton() { | PluginsButton() { | ||||
text = "Plugins"; | text = "Plugins"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -465,7 +465,7 @@ struct ManualItem : MenuItem { | |||||
ManualItem() { | ManualItem() { | ||||
text = "Manual"; | text = "Manual"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/manual/"); | system::openBrowser("https://vcvrack.com/manual/"); | ||||
}); | }); | ||||
@@ -478,7 +478,7 @@ struct WebsiteItem : MenuItem { | |||||
WebsiteItem() { | WebsiteItem() { | ||||
text = "VCVRack.com"; | text = "VCVRack.com"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/"); | system::openBrowser("https://vcvrack.com/"); | ||||
}); | }); | ||||
@@ -492,7 +492,7 @@ struct CheckVersionItem : MenuItem { | |||||
text = "Check version on launch"; | text = "Check version on launch"; | ||||
rightText = CHECKMARK(settings::checkVersion); | rightText = CHECKMARK(settings::checkVersion); | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::checkVersion ^= true; | settings::checkVersion ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -502,7 +502,7 @@ struct HelpButton : MenuButton { | |||||
HelpButton() { | HelpButton() { | ||||
text = "Help"; | text = "Help"; | ||||
} | } | ||||
void onAction(event::Action &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
Menu *menu = createMenu(); | Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -53,7 +53,7 @@ void Menu::draw(NVGcontext *vg) { | |||||
Widget::draw(vg); | Widget::draw(vg); | ||||
} | } | ||||
void Menu::onHoverScroll(event::HoverScroll &e) { | |||||
void Menu::onHoverScroll(const event::HoverScroll &e) { | |||||
if (parent && !parent->box.contains(box)) | if (parent && !parent->box.contains(box)) | ||||
box.pos.y += e.scrollDelta.y; | box.pos.y += e.scrollDelta.y; | ||||
} | } | ||||
@@ -35,7 +35,7 @@ void MenuItem::step() { | |||||
Widget::step(); | Widget::step(); | ||||
} | } | ||||
void MenuItem::onEnter(event::Enter &e) { | |||||
void MenuItem::onEnter(const event::Enter &e) { | |||||
Menu *parentMenu = dynamic_cast<Menu*>(parent); | Menu *parentMenu = dynamic_cast<Menu*>(parent); | ||||
if (!parentMenu) | if (!parentMenu) | ||||
return; | return; | ||||
@@ -51,7 +51,7 @@ void MenuItem::onEnter(event::Enter &e) { | |||||
parentMenu->setChildMenu(childMenu); | parentMenu->setChildMenu(childMenu); | ||||
} | } | ||||
void MenuItem::onDragDrop(event::DragDrop &e) { | |||||
void MenuItem::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin != this) | if (e.origin != this) | ||||
return; | return; | ||||
doAction(); | doAction(); | ||||
@@ -29,14 +29,14 @@ void TextField::draw(NVGcontext *vg) { | |||||
nvgResetScissor(vg); | nvgResetScissor(vg); | ||||
} | } | ||||
void TextField::onButton(event::Button &e) { | |||||
void TextField::onButton(const event::Button &e) { | |||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
cursor = selection = getTextPosition(e.pos); | cursor = selection = getTextPosition(e.pos); | ||||
} | } | ||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
} | } | ||||
void TextField::onHover(event::Hover &e) { | |||||
void TextField::onHover(const event::Hover &e) { | |||||
if (this == context()->event->draggedWidget) { | if (this == context()->event->draggedWidget) { | ||||
int pos = getTextPosition(e.pos); | int pos = getTextPosition(e.pos); | ||||
if (pos != selection) { | if (pos != selection) { | ||||
@@ -46,11 +46,11 @@ void TextField::onHover(event::Hover &e) { | |||||
OpaqueWidget::onHover(e); | OpaqueWidget::onHover(e); | ||||
} | } | ||||
void TextField::onEnter(event::Enter &e) { | |||||
void TextField::onEnter(const event::Enter &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void TextField::onSelectText(event::SelectText &e) { | |||||
void TextField::onSelectText(const event::SelectText &e) { | |||||
if (e.codepoint < 128) { | if (e.codepoint < 128) { | ||||
std::string newText(1, (char) e.codepoint); | std::string newText(1, (char) e.codepoint); | ||||
insertText(newText); | insertText(newText); | ||||
@@ -58,7 +58,7 @@ void TextField::onSelectText(event::SelectText &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void TextField::onSelectKey(event::SelectKey &e) { | |||||
void TextField::onSelectKey(const event::SelectKey &e) { | |||||
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_BACKSPACE: { | case GLFW_KEY_BACKSPACE: { | ||||