Browse Source

Make event callbacks use const

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
e845373ee9
52 changed files with 246 additions and 239 deletions
  1. +4
    -4
      include/app/Knob.hpp
  2. +1
    -1
      include/app/LedDisplay.hpp
  3. +6
    -6
      include/app/ModuleWidget.hpp
  4. +2
    -2
      include/app/MomentarySwitch.hpp
  5. +2
    -2
      include/app/ParamWidget.hpp
  6. +6
    -6
      include/app/PortWidget.hpp
  7. +4
    -4
      include/app/RackWidget.hpp
  8. +2
    -2
      include/app/SVGButton.hpp
  9. +1
    -1
      include/app/SVGKnob.hpp
  10. +1
    -1
      include/app/SVGSlider.hpp
  11. +1
    -1
      include/app/SVGSwitch.hpp
  12. +2
    -2
      include/app/Scene.hpp
  13. +1
    -1
      include/app/ToggleSwitch.hpp
  14. +5
    -5
      include/ui/Button.hpp
  15. +1
    -1
      include/ui/Menu.hpp
  16. +2
    -2
      include/ui/MenuItem.hpp
  17. +2
    -2
      include/ui/MenuOverlay.hpp
  18. +3
    -3
      include/ui/RadioButton.hpp
  19. +6
    -6
      include/ui/ScrollWidget.hpp
  20. +4
    -4
      include/ui/Slider.hpp
  21. +5
    -5
      include/ui/TextField.hpp
  22. +1
    -1
      include/ui/WindowWidget.hpp
  23. +1
    -1
      include/widgets/FramebufferWidget.hpp
  24. +7
    -7
      include/widgets/OpaqueWidget.hpp
  25. +7
    -7
      include/widgets/TransparentWidget.hpp
  26. +24
    -24
      include/widgets/Widget.hpp
  27. +28
    -21
      include/widgets/ZoomWidget.hpp
  28. +3
    -3
      src/Core/Blank.cpp
  29. +4
    -4
      src/Core/MIDICCToCVInterface.cpp
  30. +1
    -1
      src/Core/MIDIToCVInterface.cpp
  31. +3
    -3
      src/Core/MIDITriggerToCVInterface.cpp
  32. +1
    -1
      src/Core/QuadMIDIToCVInterface.cpp
  33. +8
    -8
      src/app/AudioWidget.cpp
  34. +4
    -4
      src/app/Knob.cpp
  35. +1
    -1
      src/app/LedDisplay.cpp
  36. +6
    -6
      src/app/MidiWidget.cpp
  37. +16
    -16
      src/app/ModuleBrowser.cpp
  38. +15
    -15
      src/app/ModuleWidget.cpp
  39. +2
    -2
      src/app/MomentarySwitch.cpp
  40. +2
    -2
      src/app/ParamWidget.cpp
  41. +6
    -6
      src/app/PortWidget.cpp
  42. +4
    -4
      src/app/RackWidget.cpp
  43. +2
    -2
      src/app/SVGButton.cpp
  44. +1
    -1
      src/app/SVGKnob.cpp
  45. +1
    -1
      src/app/SVGSlider.cpp
  46. +1
    -1
      src/app/SVGSwitch.cpp
  47. +2
    -2
      src/app/Scene.cpp
  48. +1
    -1
      src/app/ToggleSwitch.cpp
  49. +25
    -25
      src/app/Toolbar.cpp
  50. +1
    -1
      src/ui/Menu.cpp
  51. +2
    -2
      src/ui/MenuItem.cpp
  52. +5
    -5
      src/ui/TextField.cpp

+ 4
- 4
include/app/Knob.hpp View File

@@ -15,10 +15,10 @@ struct Knob : ParamWidget {
/** Multiplier for mouse movement to adjust knob value */
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;
};




+ 1
- 1
include/app/LedDisplay.hpp View File

@@ -24,7 +24,7 @@ struct LedDisplayChoice : TransparentWidget {
NVGcolor color;
LedDisplayChoice();
void draw(NVGcontext *vg) override;
void onButton(event::Button &e) override;
void onButton(const event::Button &e) override;
};

struct LedDisplayTextField : TextField {


+ 6
- 6
include/app/ModuleWidget.hpp View File

@@ -64,12 +64,12 @@ struct ModuleWidget : OpaqueWidget {
void drawShadow(NVGcontext *vg);

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;
};




+ 2
- 2
include/app/MomentarySwitch.hpp View File

@@ -10,8 +10,8 @@ namespace rack {
Consider using SVGButton if the switch simply changes the state of your Module when clicked.
*/
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;
};




+ 2
- 2
include/app/ParamWidget.hpp View File

@@ -19,8 +19,8 @@ struct ParamWidget : OpaqueWidget {
void step() override;
/** For legacy patch loading */
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;
};




+ 6
- 6
include/app/PortWidget.hpp View File

@@ -23,12 +23,12 @@ struct PortWidget : OpaqueWidget {
~PortWidget();
void step() 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;
};




+ 4
- 4
include/app/RackWidget.hpp View File

@@ -52,10 +52,10 @@ struct RackWidget : OpaqueWidget {
void step() 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;
};




+ 2
- 2
include/app/SVGButton.hpp View File

@@ -18,8 +18,8 @@ struct SVGButton : FramebufferWidget {
SVGButton();
/** 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 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;
};




+ 1
- 1
include/app/SVGKnob.hpp View File

@@ -21,7 +21,7 @@ struct SVGKnob : Knob, FramebufferWidget {
SVGKnob();
void setSVG(std::shared_ptr<SVG> svg);
void step() override;
void onChange(event::Change &e) override;
void onChange(const event::Change &e) override;
};




+ 1
- 1
include/app/SVGSlider.hpp View File

@@ -20,7 +20,7 @@ struct SVGSlider : Knob, FramebufferWidget {
SVGSlider();
void setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG);
void step() override;
void onChange(event::Change &e) override;
void onChange(const event::Change &e) override;
};




+ 1
- 1
include/app/SVGSwitch.hpp View File

@@ -18,7 +18,7 @@ struct SVGSwitch : virtual ParamWidget, FramebufferWidget {
void step() override;
/** Adds an SVG file to represent the next switch position */
void addFrame(std::shared_ptr<SVG> svg);
void onChange(event::Change &e) override;
void onChange(const event::Change &e) override;
};




+ 2
- 2
include/app/Scene.hpp View File

@@ -27,8 +27,8 @@ struct Scene : OpaqueWidget {
Scene();
void step() 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();
};


+ 1
- 1
include/app/ToggleSwitch.hpp View File

@@ -8,7 +8,7 @@ namespace rack {

/** A switch that cycles through each mechanical position */
struct ToggleSwitch : virtual ParamWidget {
void onDragStart(event::DragStart &e) override;
void onDragStart(const event::DragStart &e) override;
};




+ 5
- 5
include/ui/Button.hpp View File

@@ -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());
}

void onEnter(event::Enter &e) override {
void onEnter(const event::Enter &e) override {
state = BND_HOVER;
}

void onLeave(event::Leave &e) override {
void onLeave(const event::Leave &e) override {
state = BND_DEFAULT;
}

void onDragStart(event::DragStart &e) override {
void onDragStart(const event::DragStart &e) override {
state = BND_ACTIVE;
if (quantity)
quantity->setMax();
}

void onDragEnd(event::DragEnd &e) override {
void onDragEnd(const event::DragEnd &e) override {
state = BND_HOVER;
if (quantity)
quantity->setMin();
}

void onDragDrop(event::DragDrop &e) override {
void onDragDrop(const event::DragDrop &e) override {
if (e.origin == this) {
event::Action eAction;
onAction(eAction);


+ 1
- 1
include/ui/Menu.hpp View File

@@ -18,7 +18,7 @@ struct Menu : OpaqueWidget {
void setChildMenu(Menu *menu);
void step() override;
void draw(NVGcontext *vg) override;
void onHoverScroll(event::HoverScroll &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
};




+ 2
- 2
include/ui/MenuItem.hpp View File

@@ -19,8 +19,8 @@ struct MenuItem : MenuEntry {

void draw(NVGcontext *vg) 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();
virtual Menu *createChildMenu() {return NULL;}
};


+ 2
- 2
include/ui/MenuOverlay.hpp View File

@@ -20,7 +20,7 @@ struct MenuOverlay : OpaqueWidget {
Widget::step();
}

void onButton(event::Button &e) override {
void onButton(const event::Button &e) override {
OpaqueWidget::onButton(e);

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);

if (e.getConsumed() == this && e.action == GLFW_PRESS && e.key == GLFW_KEY_ESCAPE) {


+ 3
- 3
include/ui/RadioButton.hpp View File

@@ -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());
}

void onEnter(event::Enter &e) override {
void onEnter(const event::Enter &e) override {
if (state != BND_ACTIVE)
state = BND_HOVER;
}

void onLeave(event::Leave &e) override {
void onLeave(const event::Leave &e) override {
if (state != BND_ACTIVE)
state = BND_DEFAULT;
}

void onDragDrop(event::DragDrop &e) override {
void onDragDrop(const event::DragDrop &e) override {
if (e.origin == this) {
if (state == BND_ACTIVE) {
state = BND_HOVER;


+ 6
- 6
include/ui/ScrollWidget.hpp View File

@@ -27,14 +27,14 @@ struct ScrollBar : OpaqueWidget {
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;
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;
context()->window->cursorUnlock();
}
@@ -110,7 +110,7 @@ struct ScrollWidget : OpaqueWidget {
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
if (!context()->event->selectedWidget) {
float arrowSpeed = 30.0;
@@ -138,14 +138,14 @@ struct ScrollWidget : OpaqueWidget {
OpaqueWidget::onHover(e);
}

void onHoverScroll(event::HoverScroll &e) override {
void onHoverScroll(const event::HoverScroll &e) override {
offset = offset.minus(e.scrollDelta);
e.consume(this);
}
};


inline void ScrollBar::onDragMove(event::DragMove &e) {
inline void ScrollBar::onDragMove(const event::DragMove &e) {
ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent);
assert(scrollWidget);
if (orientation == HORIZONTAL)


+ 4
- 4
include/ui/Slider.hpp View File

@@ -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);
}

void onDragStart(event::DragStart &e) override {
void onDragStart(const event::DragStart &e) override {
state = BND_ACTIVE;
context()->window->cursorLock();
}

void onDragMove(event::DragMove &e) override {
void onDragMove(const event::DragMove &e) override {
if (quantity) {
quantity->moveScaledValue(SLIDER_SENSITIVITY * e.mouseDelta.x);
}
}

void onDragEnd(event::DragEnd &e) override {
void onDragEnd(const event::DragEnd &e) override {
state = BND_DEFAULT;
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 (quantity)
quantity->reset();


+ 5
- 5
include/ui/TextField.hpp View File

@@ -21,11 +21,11 @@ struct TextField : OpaqueWidget {

TextField();
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 */
void insertText(std::string text);


+ 1
- 1
include/ui/WindowWidget.hpp View File

@@ -14,7 +14,7 @@ struct WindowWidget : OpaqueWidget {
Widget::draw(vg);
}

void onDragMove(event::DragMove &e) override {
void onDragMove(const event::DragMove &e) override {
box.pos = box.pos.plus(e.mouseDelta);
}
};


+ 1
- 1
include/widgets/FramebufferWidget.hpp View File

@@ -27,7 +27,7 @@ struct FramebufferWidget : virtual Widget {
void draw(NVGcontext *vg) override;
int getImageHandle();

void onZoom(event::Zoom &e) override {
void onZoom(const event::Zoom &e) override {
dirty = true;
Widget::onZoom(e);
}


+ 7
- 7
include/widgets/OpaqueWidget.hpp View File

@@ -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.
*/
struct OpaqueWidget : virtual Widget {
void onHover(event::Hover &e) override {
void onHover(const event::Hover &e) override {
Widget::onHover(e);
if (!e.getConsumed())
e.consume(this);
}
void onButton(event::Button &e) override {
void onButton(const event::Button &e) override {
Widget::onButton(e);
if (!e.getConsumed())
e.consume(this);
}
void onHoverKey(event::HoverKey &e) override {
void onHoverKey(const event::HoverKey &e) override {
Widget::onHoverKey(e);
if (!e.getConsumed())
e.consume(this);
}
void onHoverText(event::HoverText &e) override {
void onHoverText(const event::HoverText &e) override {
Widget::onHoverText(e);
if (!e.getConsumed())
e.consume(this);
}
void onHoverScroll(event::HoverScroll &e) override {
void onHoverScroll(const event::HoverScroll &e) override {
Widget::onHoverScroll(e);
if (!e.getConsumed())
e.consume(this);
}
void onDragHover(event::DragHover &e) override {
void onDragHover(const event::DragHover &e) override {
Widget::onDragHover(e);
if (!e.getConsumed())
e.consume(this);
}
void onPathDrop(event::PathDrop &e) override {
void onPathDrop(const event::PathDrop &e) override {
Widget::onPathDrop(e);
if (!e.getConsumed())
e.consume(this);


+ 7
- 7
include/widgets/TransparentWidget.hpp View File

@@ -8,13 +8,13 @@ namespace rack {
/** Widget that does not respond to events and does not pass events to children */
struct TransparentWidget : virtual Widget {
/** 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 {}
};




+ 24
- 24
include/widgets/Widget.hpp View File

@@ -75,7 +75,7 @@ struct Widget {
// Events

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++) {
Widget *child = *it;
// Filter child by visibility
@@ -91,7 +91,7 @@ struct Widget {
}

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++) {
Widget *child = *it;
// Filter child by visibility and position
@@ -114,28 +114,28 @@ struct Widget {
/** Override these event callbacks to respond to events.
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);}
};




+ 28
- 21
include/widgets/ZoomWidget.hpp View File

@@ -35,33 +35,40 @@ struct ZoomWidget : virtual Widget {
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);
}
};



+ 3
- 3
src/Core/Blank.cpp View File

@@ -11,18 +11,18 @@ struct ModuleResizeHandle : virtual Widget {
ModuleResizeHandle() {
box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT);
}
void onHover(event::Hover &e) override {
void onHover(const event::Hover &e) override {
// TODO
// if (e.button == 0) {
// e.target = this;
// }
}
void onDragStart(event::DragStart &e) override {
void onDragStart(const event::DragStart &e) override {
dragX = context()->scene->rackWidget->lastMousePos.x;
ModuleWidget *m = getAncestorOfType<ModuleWidget>();
originalBox = m->box;
}
void onDragMove(event::DragMove &e) override {
void onDragMove(const event::DragMove &e) override {
ModuleWidget *m = getAncestorOfType<ModuleWidget>();

float newDragX = context()->scene->rackWidget->lastMousePos.x;


+ 4
- 4
src/Core/MIDICCToCVInterface.cpp View File

@@ -134,20 +134,20 @@ struct MidiCcChoice : GridChoice {
}
}

void onSelect(event::Select &e) override {
void onSelect(const event::Select &e) override {
e.consume(this);
module->learningId = id;
focusCc = -1;
}

void onDeselect(event::Deselect &e) override {
void onDeselect(const event::Deselect &e) override {
if (0 <= focusCc && focusCc < 128) {
module->learnedCcs[id] = focusCc;
}
module->learningId = -1;
}

void onSelectText(event::SelectText &e) override {
void onSelectText(const event::SelectText &e) override {
char c = e.codepoint;
if ('0' <= c && c <= '9') {
if (focusCc < 0)
@@ -157,7 +157,7 @@ struct MidiCcChoice : GridChoice {
e.consume(this);
}

void onSelectKey(event::SelectKey &e) override {
void onSelectKey(const event::SelectKey &e) override {
if (context()->event->selectedWidget == this) {
if (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) {
event::Deselect eDeselect;


+ 1
- 1
src/Core/MIDIToCVInterface.cpp View File

@@ -294,7 +294,7 @@ struct MIDIToCVInterfaceWidget : ModuleWidget {
MIDIToCVInterface *module;
int index;
int division;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
module->divisions[index] = division;
}
};


+ 3
- 3
src/Core/MIDITriggerToCVInterface.cpp View File

@@ -178,12 +178,12 @@ struct MidiTrigChoice : GridChoice {
}
}

void onSelect(event::Select &e) override {
void onSelect(const event::Select &e) override {
e.consume(this);
module->learningId = id;
}

void onDeselect(event::Deselect &e) override {
void onDeselect(const event::Deselect &e) override {
module->learningId = -1;
}
};
@@ -238,7 +238,7 @@ struct MIDITriggerToCVInterfaceWidget : ModuleWidget {

struct VelocityItem : MenuItem {
MIDITriggerToCVInterface *module;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
module->velocity ^= true;
}
};


+ 1
- 1
src/Core/QuadMIDIToCVInterface.cpp View File

@@ -339,7 +339,7 @@ struct QuadMIDIToCVInterfaceWidget : ModuleWidget {
struct PolyphonyItem : MenuItem {
QuadMIDIToCVInterface *module;
QuadMIDIToCVInterface::PolyMode polyMode;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
module->polyMode = polyMode;
module->onReset();
}


+ 8
- 8
src/app/AudioWidget.cpp View File

@@ -9,14 +9,14 @@ namespace rack {
struct AudioDriverItem : MenuItem {
audio::IO *audioIO;
int driver;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
audioIO->setDriver(driver);
}
};

struct AudioDriverChoice : LedDisplayChoice {
AudioWidget *audioWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("Audio driver"));
for (int driver : audioWidget->audioIO->getDrivers()) {
@@ -38,7 +38,7 @@ struct AudioDeviceItem : MenuItem {
audio::IO *audioIO;
int device;
int offset;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
audioIO->setDevice(device, offset);
}
};
@@ -48,7 +48,7 @@ struct AudioDeviceChoice : LedDisplayChoice {
/** Prevents devices with a ridiculous number of channels from being displayed */
int maxTotalChannels = 128;

void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("Audio device"));
int deviceCount = audioWidget->audioIO->getDeviceCount();
@@ -89,14 +89,14 @@ struct AudioDeviceChoice : LedDisplayChoice {
struct AudioSampleRateItem : MenuItem {
audio::IO *audioIO;
int sampleRate;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
audioIO->setSampleRate(sampleRate);
}
};

struct AudioSampleRateChoice : LedDisplayChoice {
AudioWidget *audioWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("Sample rate"));
std::vector<int> sampleRates = audioWidget->audioIO->getSampleRates();
@@ -121,14 +121,14 @@ struct AudioSampleRateChoice : LedDisplayChoice {
struct AudioBlockSizeItem : MenuItem {
audio::IO *audioIO;
int blockSize;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
audioIO->setBlockSize(blockSize);
}
};

struct AudioBlockSizeChoice : LedDisplayChoice {
AudioWidget *audioWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("Block size"));
std::vector<int> blockSizes = audioWidget->audioIO->getBlockSizes();


+ 4
- 4
src/app/Knob.cpp View File

@@ -4,7 +4,7 @@
namespace rack {


void Knob::onButton(event::Button &e) {
void Knob::onButton(const event::Button &e) {
float r = box.size.x / 2;
math::Vec c = box.size.div(2);
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();
}

void Knob::onDragEnd(event::DragEnd &e) {
void Knob::onDragEnd(const event::DragEnd &e) {
context()->window->cursorUnlock();
}

void Knob::onDragMove(event::DragMove &e) {
void Knob::onDragMove(const event::DragMove &e) {
if (quantity) {
float range;
if (quantity->isBounded()) {


+ 1
- 1
src/app/LedDisplay.cpp View File

@@ -54,7 +54,7 @@ void LedDisplayChoice::draw(NVGcontext *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)) {
event::Action eAction;
onAction(eAction);


+ 6
- 6
src/app/MidiWidget.cpp View File

@@ -9,14 +9,14 @@ namespace rack {
struct MidiDriverItem : MenuItem {
midi::IO *midiIO;
int driverId;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
midiIO->setDriverId(driverId);
}
};

struct MidiDriverChoice : LedDisplayChoice {
MidiWidget *midiWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("MIDI driver"));
for (int driverId : midiWidget->midiIO->getDriverIds()) {
@@ -43,14 +43,14 @@ struct MidiDriverChoice : LedDisplayChoice {
struct MidiDeviceItem : MenuItem {
midi::IO *midiIO;
int deviceId;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
midiIO->setDeviceId(deviceId);
}
};

struct MidiDeviceChoice : LedDisplayChoice {
MidiWidget *midiWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("MIDI device"));
{
@@ -85,14 +85,14 @@ struct MidiDeviceChoice : LedDisplayChoice {
struct MidiChannelItem : MenuItem {
midi::IO *midiIO;
int channel;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
midiIO->channel = channel;
}
};

struct MidiChannelChoice : LedDisplayChoice {
MidiWidget *midiWidget;
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->addChild(createMenuLabel("MIDI channel"));
for (int channel = -1; channel < 16; channel++) {


+ 16
- 16
src/app/ModuleBrowser.cpp View File

@@ -68,7 +68,7 @@ struct FavoriteRadioButton : RadioButton {
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);
}

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)
return;
doAction();
@@ -159,7 +159,7 @@ struct ModelItem : BrowserListItem {
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();
if (!moduleWidget)
return;
@@ -185,7 +185,7 @@ struct AuthorItem : BrowserListItem {
addChild(authorLabel);
}

void onAction(event::Action &e) override;
void onAction(const event::Action &e) override;
};


@@ -203,7 +203,7 @@ struct TagItem : BrowserListItem {
addChild(tagLabel);
}

void onAction(event::Action &e) override;
void onAction(const event::Action &e) override;
};


@@ -214,7 +214,7 @@ struct ClearFilterItem : BrowserListItem {
addChild(label);
}

void onAction(event::Action &e) override;
void onAction(const event::Action &e) override;
};


@@ -294,8 +294,8 @@ struct ModuleBrowser;

struct SearchModuleField : TextField {
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

void AuthorItem::onAction(event::Action &e) {
void AuthorItem::onAction(const event::Action &e) {
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>();
sAuthorFilter = author;
moduleBrowser->clearSearch();
@@ -467,7 +467,7 @@ void AuthorItem::onAction(event::Action &e) {
e.consume(this);
}

void TagItem::onAction(event::Action &e) {
void TagItem::onAction(const event::Action &e) {
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>();
sTagFilter = tag;
moduleBrowser->clearSearch();
@@ -475,7 +475,7 @@ void TagItem::onAction(event::Action &e) {
e.consume(this);
}

void ClearFilterItem::onAction(event::Action &e) {
void ClearFilterItem::onAction(const event::Action &e) {
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>();
sAuthorFilter = "";
sTagFilter = "";
@@ -483,7 +483,7 @@ void ClearFilterItem::onAction(event::Action &e) {
e.consume(this);
}

void FavoriteRadioButton::onAction(event::Action &e) {
void FavoriteRadioButton::onAction(const event::Action &e) {
if (!model)
return;
if (quantity->isMax()) {
@@ -500,18 +500,18 @@ void FavoriteRadioButton::onAction(event::Action &e) {
moduleBrowser->refreshSearch();
}

void BrowserListItem::onDragStart(event::DragStart &e) {
void BrowserListItem::onDragStart(const event::DragStart &e) {
BrowserList *list = dynamic_cast<BrowserList*>(parent);
if (list) {
list->selectItem(this);
}
}

void SearchModuleField::onChange(event::Change &e) {
void SearchModuleField::onChange(const event::Change &e) {
moduleBrowser->refreshSearch();
}

void SearchModuleField::onSelectKey(event::SelectKey &e) {
void SearchModuleField::onSelectKey(const event::SelectKey &e) {
if (e.action == GLFW_PRESS) {
switch (e.key) {
case GLFW_KEY_ESCAPE: {


+ 15
- 15
src/app/ModuleWidget.cpp View File

@@ -315,7 +315,7 @@ void ModuleWidget::drawShadow(NVGcontext *vg) {
nvgFill(vg);
}

void ModuleWidget::onHover(event::Hover &e) {
void ModuleWidget::onHover(const event::Hover &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.
@@ -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);
if (e.getConsumed() == this) {
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) {
switch (e.key) {
case GLFW_KEY_I: {
@@ -382,14 +382,14 @@ void ModuleWidget::onHoverKey(event::HoverKey &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);
}

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) {
math::Rect newBox = box;
newBox.pos = context()->scene->rackWidget->lastMousePos.minus(dragPos);
@@ -404,7 +404,7 @@ struct ModuleDisconnectItem : MenuItem {
text = "Disconnect cables";
rightText = WINDOW_MOD_KEY_NAME "+U";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->disconnect();
}
};
@@ -415,7 +415,7 @@ struct ModuleResetItem : MenuItem {
text = "Initialize";
rightText = WINDOW_MOD_KEY_NAME "+I";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->reset();
}
};
@@ -426,7 +426,7 @@ struct ModuleRandomizeItem : MenuItem {
text = "Randomize";
rightText = WINDOW_MOD_KEY_NAME "+R";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->randomize();
}
};
@@ -437,7 +437,7 @@ struct ModuleCopyItem : MenuItem {
text = "Copy preset";
rightText = WINDOW_MOD_KEY_NAME "+C";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->copyClipboard();
}
};
@@ -448,7 +448,7 @@ struct ModulePasteItem : MenuItem {
text = "Paste preset";
rightText = WINDOW_MOD_KEY_NAME "+V";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->pasteClipboard();
}
};
@@ -458,7 +458,7 @@ struct ModuleSaveItem : MenuItem {
ModuleSaveItem() {
text = "Save preset";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->saveDialog();
}
};
@@ -468,7 +468,7 @@ struct ModuleLoadItem : MenuItem {
ModuleLoadItem() {
text = "Load preset";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
moduleWidget->loadDialog();
}
};
@@ -479,7 +479,7 @@ struct ModuleCloneItem : MenuItem {
text = "Duplicate";
rightText = WINDOW_MOD_KEY_NAME "+D";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->cloneModule(moduleWidget);
}
};
@@ -490,7 +490,7 @@ struct ModuleDeleteItem : MenuItem {
text = "Delete";
rightText = "Backspace/Delete";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->deleteModule(moduleWidget);
delete moduleWidget;
}


+ 2
- 2
src/app/MomentarySwitch.cpp View File

@@ -4,13 +4,13 @@
namespace rack {


void MomentarySwitch::onDragStart(event::DragStart &e) {
void MomentarySwitch::onDragStart(const event::DragStart &e) {
if (quantity) {
quantity->setMax();
}
}

void MomentarySwitch::onDragEnd(event::DragEnd &e) {
void MomentarySwitch::onDragEnd(const event::DragEnd &e) {
if (quantity) {
quantity->setMin();
}


+ 2
- 2
src/app/ParamWidget.cpp View File

@@ -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
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
if (quantity)
@@ -39,7 +39,7 @@ void ParamWidget::onButton(event::Button &e) {
OpaqueWidget::onButton(e);
}

void ParamWidget::onDragMove(event::DragMove &e) {
void ParamWidget::onDragMove(const event::DragMove &e) {
if (quantity) {
DEBUG("%s", quantity->getString().c_str());
}


+ 6
- 6
src/app/PortWidget.cpp View File

@@ -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) {
context()->scene->rackWidget->wireContainer->removeTopWire(this);

@@ -62,7 +62,7 @@ void PortWidget::onButton(event::Button &e) {
e.consume(this);
}

void PortWidget::onDragStart(event::DragStart &e) {
void PortWidget::onDragStart(const event::DragStart &e) {
// Try to grab wire on top of stack
WireWidget *wire = NULL;
if (type == INPUT || !context()->window->isModPressed()) {
@@ -82,13 +82,13 @@ void PortWidget::onDragStart(event::DragStart &e) {
context()->scene->rackWidget->wireContainer->setActiveWire(wire);
}

void PortWidget::onDragEnd(event::DragEnd &e) {
void PortWidget::onDragEnd(const event::DragEnd &e) {
// FIXME
// If the source PortWidget is deleted, this will be called, removing the cable
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);
if (!originPort)
return;
@@ -99,7 +99,7 @@ void PortWidget::onDragDrop(event::DragDrop &e) {
onDragEnter(eDragEnter);
}

void PortWidget::onDragEnter(event::DragEnter &e) {
void PortWidget::onDragEnter(const event::DragEnter &e) {
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin);
if (!originPort)
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);
if (!originPort)
return;


+ 4
- 4
src/app/RackWidget.cpp View File

@@ -539,17 +539,17 @@ void RackWidget::draw(NVGcontext *vg) {
Widget::draw(vg);
}

void RackWidget::onHover(event::Hover &e) {
void RackWidget::onHover(const event::Hover &e) {
OpaqueWidget::onHover(e);
lastMousePos = e.pos;
}

void RackWidget::onDragHover(event::DragHover &e) {
void RackWidget::onDragHover(const event::DragHover &e) {
OpaqueWidget::onDragHover(e);
lastMousePos = e.pos;
}

void RackWidget::onButton(event::Button &e) {
void RackWidget::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);
if (e.getConsumed() == this) {
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();
OpaqueWidget::onZoom(e);
}


+ 2
- 2
src/app/SVGButton.cpp View File

@@ -16,14 +16,14 @@ void SVGButton::setSVGs(std::shared_ptr<SVG> defaultSVG, std::shared_ptr<SVG> ac
this->activeSVG = activeSVG ? activeSVG : defaultSVG;
}

void SVGButton::onDragStart(event::DragStart &e) {
void SVGButton::onDragStart(const event::DragStart &e) {
event::Action eAction;
onAction(eAction);
sw->setSVG(activeSVG);
dirty = true;
}

void SVGButton::onDragEnd(event::DragEnd &e) {
void SVGButton::onDragEnd(const event::DragEnd &e) {
sw->setSVG(defaultSVG);
dirty = true;
}


+ 1
- 1
src/app/SVGKnob.cpp View File

@@ -30,7 +30,7 @@ void SVGKnob::step() {
FramebufferWidget::step();
}

void SVGKnob::onChange(event::Change &e) {
void SVGKnob::onChange(const event::Change &e) {
// Re-transform the TransformWidget
if (quantity) {
float angle;


+ 1
- 1
src/app/SVGSlider.cpp View File

@@ -27,7 +27,7 @@ void SVGSlider::step() {
FramebufferWidget::step();
}

void SVGSlider::onChange(event::Change &e) {
void SVGSlider::onChange(const event::Change &e) {
if (quantity) {
// Interpolate handle position
float v = quantity->getScaledValue();


+ 1
- 1
src/app/SVGSwitch.cpp View File

@@ -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);
if (quantity) {
int index = quantity->getScaledValue() * (frames.size() - 1);


+ 2
- 2
src/app/Scene.cpp View File

@@ -66,7 +66,7 @@ void Scene::draw(NVGcontext *vg) {
OpaqueWidget::draw(vg);
}

void Scene::onHoverKey(event::HoverKey &e) {
void Scene::onHoverKey(const event::HoverKey &e) {
if (e.action == GLFW_PRESS) {
switch (e.key) {
case GLFW_KEY_N: {
@@ -123,7 +123,7 @@ void Scene::onHoverKey(event::HoverKey &e) {
OpaqueWidget::onHoverKey(e);
}

void Scene::onPathDrop(event::PathDrop &e) {
void Scene::onPathDrop(const event::PathDrop &e) {
if (e.paths.size() >= 1) {
const std::string &path = e.paths[0];
if (string::extension(path) == "vcv") {


+ 1
- 1
src/app/ToggleSwitch.cpp View File

@@ -4,7 +4,7 @@
namespace rack {


void ToggleSwitch::onDragStart(event::DragStart &e) {
void ToggleSwitch::onDragStart(const event::DragStart &e) {
// Cycle through values
// e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3.
if (quantity) {


+ 25
- 25
src/app/Toolbar.cpp View File

@@ -37,7 +37,7 @@ struct NewItem : MenuItem {
text = "New";
rightText = "(" WINDOW_MOD_KEY_NAME "+N)";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->reset();
}
};
@@ -48,7 +48,7 @@ struct OpenItem : MenuItem {
text = "Open";
rightText = "(" WINDOW_MOD_KEY_NAME "+O)";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->loadDialog();
}
};
@@ -59,7 +59,7 @@ struct SaveItem : MenuItem {
text = "Save";
rightText = "(" WINDOW_MOD_KEY_NAME "+S)";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->saveDialog();
}
};
@@ -70,7 +70,7 @@ struct SaveAsItem : MenuItem {
text = "Save as";
rightText = "(" WINDOW_MOD_KEY_NAME "+Shift+S)";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->saveAsDialog();
}
};
@@ -80,7 +80,7 @@ struct RevertItem : MenuItem {
RevertItem() {
text = "Revert";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->revert();
}
};
@@ -90,7 +90,7 @@ struct DisconnectCablesItem : MenuItem {
DisconnectCablesItem() {
text = "Disconnect cables";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->scene->rackWidget->disconnect();
}
};
@@ -100,7 +100,7 @@ struct FileButton : MenuButton {
FileButton() {
text = "File";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -168,7 +168,7 @@ struct PowerMeterItem : MenuItem {
text = "Power meter";
rightText = CHECKMARK(settings::powerMeter);
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
settings::powerMeter ^= true;
}
};
@@ -179,7 +179,7 @@ struct LockModulesItem : MenuItem {
text = "Lock modules";
rightText = CHECKMARK(settings::lockModules);
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
settings::lockModules ^= true;
}
};
@@ -190,7 +190,7 @@ struct EnginePauseItem : MenuItem {
text = "Pause engine";
rightText = CHECKMARK(context()->engine->paused);
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
context()->engine->paused ^= true;
}
};
@@ -203,7 +203,7 @@ struct SampleRateValueItem : MenuItem {
text = string::f("%.0f Hz", 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->paused = false;
}
@@ -232,7 +232,7 @@ struct SettingsButton : MenuButton {
SettingsButton() {
text = "Settings";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -263,7 +263,7 @@ struct RegisterItem : MenuItem {
RegisterItem() {
text = "Register VCV account";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/");
});
@@ -277,7 +277,7 @@ struct AccountEmailField : TextField {
AccountEmailField() {
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) {
context()->event->selectedWidget = passwordField;
e.consume(this);
@@ -293,7 +293,7 @@ struct AccountPasswordField : PasswordField {
AccountPasswordField() {
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)) {
logInItem->doAction();
e.consume(this);
@@ -310,7 +310,7 @@ struct LogInItem : MenuItem {
LogInItem() {
text = "Log in";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
std::string email = emailField->text;
std::string password = passwordField->text;
std::thread t([&, email, password]() {
@@ -325,7 +325,7 @@ struct ManageItem : MenuItem {
ManageItem() {
text = "Manage plugins";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/plugins.html");
});
@@ -339,7 +339,7 @@ struct SyncItem : MenuItem {
text = "Sync plugins";
disabled = true;
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
}
};

@@ -369,7 +369,7 @@ struct SyncItem : MenuItem {
// completed = false;
// }
// }
// void onAction(event::Action &e) override {
// void onAction(const event::Action &e) override {
// available = false;
// std::thread t([this]() {
// if (plugin::sync(false))
@@ -384,7 +384,7 @@ struct LogOutItem : MenuItem {
LogOutItem() {
text = "Log out";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
plugin::logOut();
}
};
@@ -413,7 +413,7 @@ struct PluginsButton : MenuButton {
PluginsButton() {
text = "Plugins";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -465,7 +465,7 @@ struct ManualItem : MenuItem {
ManualItem() {
text = "Manual";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/manual/");
});
@@ -478,7 +478,7 @@ struct WebsiteItem : MenuItem {
WebsiteItem() {
text = "VCVRack.com";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/");
});
@@ -492,7 +492,7 @@ struct CheckVersionItem : MenuItem {
text = "Check version on launch";
rightText = CHECKMARK(settings::checkVersion);
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
settings::checkVersion ^= true;
}
};
@@ -502,7 +502,7 @@ struct HelpButton : MenuButton {
HelpButton() {
text = "Help";
}
void onAction(event::Action &e) override {
void onAction(const event::Action &e) override {
Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;


+ 1
- 1
src/ui/Menu.cpp View File

@@ -53,7 +53,7 @@ void Menu::draw(NVGcontext *vg) {
Widget::draw(vg);
}

void Menu::onHoverScroll(event::HoverScroll &e) {
void Menu::onHoverScroll(const event::HoverScroll &e) {
if (parent && !parent->box.contains(box))
box.pos.y += e.scrollDelta.y;
}


+ 2
- 2
src/ui/MenuItem.cpp View File

@@ -35,7 +35,7 @@ void MenuItem::step() {
Widget::step();
}

void MenuItem::onEnter(event::Enter &e) {
void MenuItem::onEnter(const event::Enter &e) {
Menu *parentMenu = dynamic_cast<Menu*>(parent);
if (!parentMenu)
return;
@@ -51,7 +51,7 @@ void MenuItem::onEnter(event::Enter &e) {
parentMenu->setChildMenu(childMenu);
}

void MenuItem::onDragDrop(event::DragDrop &e) {
void MenuItem::onDragDrop(const event::DragDrop &e) {
if (e.origin != this)
return;
doAction();


+ 5
- 5
src/ui/TextField.cpp View File

@@ -29,14 +29,14 @@ void TextField::draw(NVGcontext *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) {
cursor = selection = getTextPosition(e.pos);
}
OpaqueWidget::onButton(e);
}

void TextField::onHover(event::Hover &e) {
void TextField::onHover(const event::Hover &e) {
if (this == context()->event->draggedWidget) {
int pos = getTextPosition(e.pos);
if (pos != selection) {
@@ -46,11 +46,11 @@ void TextField::onHover(event::Hover &e) {
OpaqueWidget::onHover(e);
}

void TextField::onEnter(event::Enter &e) {
void TextField::onEnter(const event::Enter &e) {
e.consume(this);
}

void TextField::onSelectText(event::SelectText &e) {
void TextField::onSelectText(const event::SelectText &e) {
if (e.codepoint < 128) {
std::string newText(1, (char) e.codepoint);
insertText(newText);
@@ -58,7 +58,7 @@ void TextField::onSelectText(event::SelectText &e) {
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) {
switch (e.key) {
case GLFW_KEY_BACKSPACE: {


Loading…
Cancel
Save