Browse Source

Rename `widget::*Event` to `event::*`.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
9d609fee2b
68 changed files with 482 additions and 487 deletions
  1. +4
    -4
      include/app.hpp
  2. +5
    -5
      include/app/Knob.hpp
  3. +1
    -1
      include/app/LedDisplay.hpp
  4. +6
    -6
      include/app/ModuleWidget.hpp
  5. +4
    -4
      include/app/ParamWidget.hpp
  6. +8
    -8
      include/app/PortWidget.hpp
  7. +2
    -2
      include/app/RackScrollWidget.hpp
  8. +5
    -5
      include/app/RackWidget.hpp
  9. +2
    -2
      include/app/Scene.hpp
  10. +2
    -2
      include/app/SliderKnob.hpp
  11. +3
    -3
      include/app/SvgButton.hpp
  12. +1
    -1
      include/app/SvgKnob.hpp
  13. +1
    -1
      include/app/SvgSlider.hpp
  14. +1
    -1
      include/app/SvgSwitch.hpp
  15. +3
    -3
      include/app/Switch.hpp
  16. +66
    -65
      include/event.hpp
  17. +5
    -5
      include/ui/Button.hpp
  18. +1
    -1
      include/ui/Menu.hpp
  19. +3
    -3
      include/ui/MenuItem.hpp
  20. +2
    -2
      include/ui/MenuOverlay.hpp
  21. +4
    -4
      include/ui/RadioButton.hpp
  22. +3
    -3
      include/ui/ScrollBar.hpp
  23. +2
    -2
      include/ui/ScrollWidget.hpp
  24. +4
    -4
      include/ui/Slider.hpp
  25. +6
    -7
      include/ui/TextField.hpp
  26. +7
    -7
      include/widget/OpaqueWidget.hpp
  27. +7
    -7
      include/widget/TransparentWidget.hpp
  28. +30
    -30
      include/widget/Widget.hpp
  29. +14
    -14
      include/widget/ZoomWidget.hpp
  30. +3
    -3
      src/Core/Blank.cpp
  31. +2
    -2
      src/Core/CV_Gate.cpp
  32. +1
    -1
      src/Core/CV_MIDI.cpp
  33. +4
    -4
      src/Core/MIDI_CV.cpp
  34. +2
    -2
      src/Core/MIDI_Gate.cpp
  35. +3
    -3
      src/Core/MIDI_Map.cpp
  36. +7
    -7
      src/Core/plugin.hpp
  37. +1
    -2
      src/app.cpp
  38. +8
    -8
      src/app/AudioWidget.cpp
  39. +0
    -1
      src/app/CableWidget.cpp
  40. +5
    -5
      src/app/Knob.cpp
  41. +2
    -3
      src/app/LedDisplay.cpp
  42. +6
    -6
      src/app/MidiWidget.cpp
  43. +14
    -14
      src/app/ModuleBrowser.cpp
  44. +19
    -19
      src/app/ModuleWidget.cpp
  45. +8
    -8
      src/app/ParamWidget.cpp
  46. +8
    -8
      src/app/PortWidget.cpp
  47. +2
    -2
      src/app/RackScrollWidget.cpp
  48. +5
    -5
      src/app/RackWidget.cpp
  49. +2
    -2
      src/app/Scene.cpp
  50. +4
    -4
      src/app/SvgButton.cpp
  51. +1
    -1
      src/app/SvgKnob.cpp
  52. +1
    -1
      src/app/SvgSlider.cpp
  53. +1
    -1
      src/app/SvgSwitch.cpp
  54. +3
    -3
      src/app/Switch.cpp
  55. +34
    -34
      src/app/Toolbar.cpp
  56. +73
    -73
      src/event.cpp
  57. +6
    -6
      src/ui/Button.cpp
  58. +1
    -1
      src/ui/Menu.cpp
  59. +5
    -5
      src/ui/MenuItem.cpp
  60. +2
    -2
      src/ui/MenuOverlay.cpp
  61. +5
    -5
      src/ui/RadioButton.cpp
  62. +3
    -3
      src/ui/ScrollBar.cpp
  63. +2
    -3
      src/ui/ScrollWidget.cpp
  64. +4
    -4
      src/ui/Slider.cpp
  65. +14
    -14
      src/ui/TextField.cpp
  66. +16
    -17
      src/widget/Widget.cpp
  67. +2
    -2
      src/widget/ZoomWidget.cpp
  68. +1
    -1
      src/window.cpp

+ 4
- 4
include/app.hpp View File

@@ -23,9 +23,9 @@ struct Window;
struct PatchManager;


namespace widget {
struct EventState;
};
namespace event {
struct State;
} // namespace event


namespace app {
@@ -35,7 +35,7 @@ namespace app {

/** Contains the application state */
struct App {
widget::EventState *event = NULL;
event::State *event = NULL;
app::Scene *scene = NULL;
engine::Engine *engine = NULL;
Window *window = NULL;


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

@@ -20,11 +20,11 @@ struct Knob : ParamWidget {
/** Drag horizontally instead of vertically */
bool horizontal = false;

void onHover(const widget::HoverEvent &e) override;
void onButton(const widget::ButtonEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragMove(const widget::DragMoveEvent &e) override;
void onHover(const event::Hover &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;
void reset() override;
void randomize() override;
};


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

@@ -26,7 +26,7 @@ struct LedDisplayChoice : widget::TransparentWidget {
NVGcolor bgColor;
LedDisplayChoice();
void draw(const DrawArgs &args) override;
void onButton(const widget::ButtonEvent &e) override;
void onButton(const event::Button &e) override;
};

struct LedDisplayTextField : ui::TextField {


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

@@ -37,12 +37,12 @@ struct ModuleWidget : widget::OpaqueWidget {
void draw(const DrawArgs &args) override;
void drawShadow(const DrawArgs &args);

void onHover(const widget::HoverEvent &e) override;
void onButton(const widget::ButtonEvent &e) override;
void onHoverKey(const widget::HoverKeyEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragMove(const widget::DragMoveEvent &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;

/** Associates this ModuleWidget with the Module
Transfers ownership


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

@@ -19,10 +19,10 @@ struct ParamWidget : widget::OpaqueWidget {
void step() override;
void draw(const DrawArgs &args) override;

void onButton(const widget::ButtonEvent &e) override;
void onDoubleClick(const widget::DoubleClickEvent &e) override;
void onEnter(const widget::EnterEvent &e) override;
void onLeave(const widget::LeaveEvent &e) override;
void onButton(const event::Button &e) override;
void onDoubleClick(const event::DoubleClick &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &e) override;

/** For legacy patch loading */
void fromJson(json_t *rootJ);


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

@@ -28,14 +28,14 @@ struct PortWidget : widget::OpaqueWidget {
void step() override;
void draw(const DrawArgs &args) override;

void onButton(const widget::ButtonEvent &e) override;
void onEnter(const widget::EnterEvent &e) override;
void onLeave(const widget::LeaveEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragDrop(const widget::DragDropEvent &e) override;
void onDragEnter(const widget::DragEnterEvent &e) override;
void onDragLeave(const widget::DragLeaveEvent &e) override;
void onButton(const event::Button &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &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;
};




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

@@ -18,8 +18,8 @@ struct RackScrollWidget : ui::ScrollWidget {
RackScrollWidget();
void step() override;
void draw(const DrawArgs &args) override;
void onHover(const widget::HoverEvent &e) override;
void onHoverScroll(const widget::HoverScrollEvent &e) override;
void onHover(const event::Hover &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
void reset();
};



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

@@ -28,11 +28,11 @@ struct RackWidget : widget::OpaqueWidget {
void step() override;
void draw(const DrawArgs &args) override;

void onHover(const widget::HoverEvent &e) override;
void onHoverKey(const widget::HoverKeyEvent &e) override;
void onDragHover(const widget::DragHoverEvent &e) override;
void onButton(const widget::ButtonEvent &e) override;
void onZoom(const widget::ZoomEvent &e) override;
void onHover(const event::Hover &e) override;
void onHoverKey(const event::HoverKey &e) override;
void onDragHover(const event::DragHover &e) override;
void onButton(const event::Button &e) override;
void onZoom(const event::Zoom &e) override;

/** Completely clear the rack's modules and cables */
void clear();


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

@@ -28,8 +28,8 @@ struct Scene : widget::OpaqueWidget {
~Scene();
void step() override;
void draw(const DrawArgs &args) override;
void onHoverKey(const widget::HoverKeyEvent &e) override;
void onPathDrop(const widget::PathDropEvent &e) override;
void onHoverKey(const event::HoverKey &e) override;
void onPathDrop(const event::PathDrop &e) override;

void runCheckVersion();
};


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

@@ -9,10 +9,10 @@ namespace app {

struct SliderKnob : Knob {
// Bypass Knob's circular hitbox detection
void onHover(const widget::HoverEvent &e) override {
void onHover(const event::Hover &e) override {
ParamWidget::onHover(e);
}
void onButton(const widget::ButtonEvent &e) override {
void onButton(const event::Button &e) override {
ParamWidget::onButton(e);
}
};


+ 3
- 3
include/app/SvgButton.hpp View File

@@ -18,9 +18,9 @@ struct SvgButton : widget::OpaqueWidget {

SvgButton();
void addFrame(std::shared_ptr<Svg> svg);
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragDrop(const widget::DragDropEvent &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
};




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

@@ -23,7 +23,7 @@ struct SvgKnob : Knob {
SvgKnob();
void setSvg(std::shared_ptr<Svg> svg);
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);}
void onChange(const widget::ChangeEvent &e) override;
void onChange(const event::Change &e) override;
};




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

@@ -22,7 +22,7 @@ struct SvgSlider : app::SliderKnob {
SvgSlider();
void setBackgroundSvg(std::shared_ptr<Svg> svg);
void setHandleSvg(std::shared_ptr<Svg> svg);
void onChange(const widget::ChangeEvent &e) override;
void onChange(const event::Change &e) override;

DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);}
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);}


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

@@ -20,7 +20,7 @@ struct SvgSwitch : Switch {
SvgSwitch();
/** Adds an SVG file to represent the next switch position */
void addFrame(std::shared_ptr<Svg> svg);
void onChange(const widget::ChangeEvent &e) override;
void onChange(const event::Change &e) override;
};




+ 3
- 3
include/app/Switch.hpp View File

@@ -16,9 +16,9 @@ struct Switch : ParamWidget {
bool momentaryReleased = false;

void step() override;
void onDoubleClick(const widget::DoubleClickEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDoubleClick(const event::DoubleClick &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void reset() override;
void randomize() override;
};


include/widget/event.hpp → include/event.hpp View File

@@ -5,24 +5,28 @@


namespace rack {


namespace widget {
struct Widget;
}


struct Widget;
namespace event {


/** A per-event state shared and writable by all widgets that recursively handle an event. */
struct EventContext {
Widget *target = NULL;
struct Context {
widget::Widget *target = NULL;
bool propagating = true;
};


/** Base class for all events. */
struct Event {
EventContext *context = NULL;
struct Base {
Context *context = NULL;

/** Prevents the Event from being handled by more Widgets.
/** Prevents the event from being handled by more Widgets.
*/
void stopPropagating() const {
if (context)
@@ -36,32 +40,32 @@ struct Event {
/** Tells the event handler that a particular Widget consumed the event.
You usually want to stop propagation as well, so call consume() instead.
*/
void setTarget(Widget *w) const {
void setTarget(widget::Widget *w) const {
if (context)
context->target = w;
}
Widget *getTarget() const {
widget::Widget *getTarget() const {
if (context)
return context->target;
return NULL;
}
/** Sets the target Widget and stops propagation. */
void consume(Widget *w) const {
void consume(widget::Widget *w) const {
setTarget(w);
stopPropagating();
}
};


/** An Event prototype with a vector position. */
struct PositionEvent {
/** An event prototype with a vector position. */
struct PositionBase {
/** The pixel coordinate where the event occurred, relative to the Widget it is called on. */
math::Vec pos;
};


/** An Event prototype with a GLFW key. */
struct KeyEvent {
/** An event prototype with a GLFW key. */
struct KeyBase {
/** GLFW_KEY_* */
int key;
/** GLFW_KEY_*. You should usually use `key` instead. */
@@ -73,21 +77,18 @@ struct KeyEvent {
};


/** An Event prototype with a Unicode character. */
struct TextEvent {
/** An event prototype with a Unicode character. */
struct TextBase {
/** Unicode code point of the character */
int codepoint;
};


// Concrete events


/** Occurs every frame when the mouse is hovering over a Widget.
Recurses until consumed.
If `target` is set, other events may occur on that Widget.
*/
struct HoverEvent : Event, PositionEvent {
struct Hover : Base, PositionBase {
/** Change in mouse position since the last frame. Can be zero. */
math::Vec mouseDelta;
};
@@ -97,7 +98,7 @@ struct HoverEvent : Event, PositionEvent {
Recurses until consumed.
If `target` is set, other events may occur on that Widget.
*/
struct ButtonEvent : Event, PositionEvent {
struct Button : Base, PositionBase {
/** GLFW_MOUSE_BUTTON_LEFT, GLFW_MOUSE_BUTTON_RIGHT, GLFW_MOUSE_BUTTON_MIDDLE, etc. */
int button;
/** GLFW_PRESS or GLFW_RELEASE */
@@ -109,28 +110,28 @@ struct ButtonEvent : Event, PositionEvent {

/** Occurs when the left mouse button is pressed the second time within a time and position window.
*/
struct DoubleClickEvent : Event {
struct DoubleClick : Base {
};


/** Occurs when a key is pressed, released, or repeated while the mouse is hovering a Widget.
Recurses until consumed.
*/
struct HoverKeyEvent : Event, PositionEvent, KeyEvent {
struct HoverKey : Base, PositionBase, KeyBase {
};


/** Occurs when a character is typed while the mouse is hovering a Widget.
Recurses until consumed.
*/
struct HoverTextEvent : Event, PositionEvent, TextEvent {
struct HoverText : Base, PositionBase, TextBase {
};


/** Occurs when the mouse scroll wheel is moved while the mouse is hovering a Widget.
Recurses until consumed.
*/
struct HoverScrollEvent : Event, PositionEvent {
struct HoverScroll : Base, PositionBase {
/** Change of scroll wheel position. */
math::Vec scrollDelta;
};
@@ -139,59 +140,59 @@ struct HoverScrollEvent : Event, PositionEvent {
/** Occurs when a Widget begins consuming the Hover event.
Must consume to set the widget as hovered.
*/
struct EnterEvent : Event {
struct Enter : Base {
};


/** Occurs when a different Widget is entered.
*/
struct LeaveEvent : Event {
struct Leave : Base {
};


/** Occurs when a Widget begins consuming the Button press event.
Must consume to set the widget as selected.
*/
struct SelectEvent : Event {
struct Select : Base {
};


/** Occurs when a different Widget is selected.
*/
struct DeselectEvent : Event {
struct Deselect : Base {
};


/** Occurs when a key is pressed, released, or repeated while a Widget is selected.
If consumed, a HoverKey event will not be triggered.
*/
struct SelectKeyEvent : Event, KeyEvent {
struct SelectKey : Base, KeyBase {
};


/** Occurs when text is typed while a Widget is selected.
If consumed, a HoverText event will not be triggered.
*/
struct SelectTextEvent : Event, TextEvent {
struct SelectText : Base, TextBase {
};


/** Occurs when a Widget begins being dragged.
Must consume to set the widget as dragged.
*/
struct DragStartEvent : Event {
struct DragStart : Base {
};


/** Occurs when a Widget stops being dragged by releasing the mouse button.
*/
struct DragEndEvent : Event {
struct DragEnd : Base {
};


/** Occurs every frame on the dragged Widget.
*/
struct DragMoveEvent : Event {
struct DragMove : Base {
/** Change in mouse position since the last frame. Can be zero. */
math::Vec mouseDelta;
};
@@ -200,9 +201,9 @@ struct DragMoveEvent : Event {
/** Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same one) is being dragged.
Recurses until consumed.
*/
struct DragHoverEvent : Event, PositionEvent {
struct DragHover : Base, PositionBase {
/** The dragged widget */
Widget *origin = NULL;
widget::Widget *origin = NULL;
/** Change in mouse position since the last frame. Can be zero. */
math::Vec mouseDelta;
};
@@ -210,33 +211,33 @@ struct DragHoverEvent : Event, PositionEvent {
/** Occurs when the mouse enters a Widget while dragging.
Must consume to set the widget as drag-hovered.
*/
struct DragEnterEvent : Event {
struct DragEnter : Base {
/** The dragged widget */
Widget *origin = NULL;
widget::Widget *origin = NULL;
};


/** Occurs when the mouse leaves a Widget while dragging.
*/
struct DragLeaveEvent : Event {
struct DragLeave : Base {
/** The dragged widget */
Widget *origin = NULL;
widget::Widget *origin = NULL;
};


/** Occurs when the mouse button is released over a Widget while dragging.
*/
struct DragDropEvent : Event {
struct DragDrop : Base {
/** The dragged widget */
Widget *origin = NULL;
widget::Widget *origin = NULL;
};


/** Occurs when a selection of files from the operating system is dropped onto a Widget.
Recurses until consumed.
*/
struct PathDropEvent : Event, PositionEvent {
PathDropEvent(const std::vector<std::string> &paths) : paths(paths) {}
struct PathDrop : Base, PositionBase {
PathDrop(const std::vector<std::string> &paths) : paths(paths) {}

/** List of file paths in the dropped selection */
const std::vector<std::string> &paths;
@@ -246,79 +247,79 @@ struct PathDropEvent : Event, PositionEvent {
/** Occurs after a certain action is triggered on a Widget.
The concept of an "action" is dependent on the type of Widget.
*/
struct ActionEvent : Event {
struct Action : Base {
};


/** Occurs after the value of a Widget changes.
The concept of a "value" is dependent on the type of Widget.
*/
struct ChangeEvent : Event {
struct Change : Base {
};


/** Occurs after the zoom level of a Widget is changed.
Recurses until consumed.
*/
struct ZoomEvent : Event {
struct Zoom : Base {
};


/** Occurs after a Widget's position is set by Widget::setPos().
*/
struct RepositionEvent : Event {
struct Reposition : Base {
};


/** Occurs after a Widget's size is set by Widget::setSize().
*/
struct ResizeEvent : Event {
struct Resize : Base {
};


/** Occurs after a Widget is added to a parent.
*/
struct AddEvent : Event {
struct Add : Base {
};


/** Occurs before a Widget is removed from its parent.
*/
struct RemoveEvent : Event {
struct Remove : Base {
};


/** Occurs after a Widget is shown with Widget::show().
*/
struct ShowEvent : Event {
struct Show : Base {
};


/** Occurs after a Widget is hidden with Widget::hide().
*/
struct HideEvent : Event {
struct Hide : Base {
};


struct EventState {
Widget *rootWidget = NULL;
struct State {
widget::Widget *rootWidget = NULL;
/** State widgets
Don't set these directly unless you know what you're doing. Use the set*() methods instead.
*/
Widget *hoveredWidget = NULL;
Widget *draggedWidget = NULL;
Widget *dragHoveredWidget = NULL;
Widget *selectedWidget = NULL;
widget::Widget *hoveredWidget = NULL;
widget::Widget *draggedWidget = NULL;
widget::Widget *dragHoveredWidget = NULL;
widget::Widget *selectedWidget = NULL;
/** For double-clicking */
double lastClickTime = -INFINITY;
Widget *lastClickedWidget = NULL;
widget::Widget *lastClickedWidget = NULL;

void setHovered(Widget *w);
void setDragged(Widget *w);
void setDragHovered(Widget *w);
void setSelected(Widget *w);
void setHovered(widget::Widget *w);
void setDragged(widget::Widget *w);
void setDragHovered(widget::Widget *w);
void setSelected(widget::Widget *w);
/** Prepares a widget for deletion */
void finalizeWidget(Widget *w);
void finalizeWidget(widget::Widget *w);

void handleButton(math::Vec pos, int button, int action, int mods);
void handleHover(math::Vec pos, math::Vec mouseDelta);
@@ -331,5 +332,5 @@ struct EventState {
};


} // namespace widget
} // namespace event
} // namespace rack

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

@@ -16,11 +16,11 @@ struct Button : widget::OpaqueWidget {

Button();
void draw(const DrawArgs &args) override;
void onEnter(const widget::EnterEvent &e) override;
void onLeave(const widget::LeaveEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragDrop(const widget::DragDropEvent &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDragDrop(const event::DragDrop &e) override;
};




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

@@ -19,7 +19,7 @@ struct Menu : widget::OpaqueWidget {
void setChildMenu(Menu *menu);
void step() override;
void draw(const DrawArgs &args) override;
void onHoverScroll(const widget::HoverScrollEvent &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
};




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

@@ -16,9 +16,9 @@ struct MenuItem : MenuEntry {

void draw(const DrawArgs &args) override;
void step() override;
void onEnter(const widget::EnterEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragDrop(const widget::DragDropEvent &e) override;
void onEnter(const event::Enter &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragDrop(const event::DragDrop &e) override;
void doAction();
virtual Menu *createChildMenu() {return NULL;}
};


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

@@ -10,8 +10,8 @@ namespace ui {
/** Deletes itself from parent when clicked */
struct MenuOverlay : widget::OpaqueWidget {
void step() override;
void onButton(const widget::ButtonEvent &e) override;
void onHoverKey(const widget::HoverKeyEvent &e) override;
void onButton(const event::Button &e) override;
void onHoverKey(const event::HoverKey &e) override;
};




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

@@ -15,10 +15,10 @@ struct RadioButton : widget::OpaqueWidget {

RadioButton();
void draw(const DrawArgs &args) override;
void onEnter(const widget::EnterEvent &e) override;
void onLeave(const widget::LeaveEvent &e) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragDrop(const widget::DragDropEvent &e) override;
void onEnter(const event::Enter &e) override;
void onLeave(const event::Leave &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragDrop(const event::DragDrop &e) override;
};




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

@@ -20,9 +20,9 @@ struct ScrollBar : widget::OpaqueWidget {

ScrollBar();
void draw(const DrawArgs &args) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragMove(const widget::DragMoveEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragMove(const event::DragMove &e) override;
void onDragEnd(const event::DragEnd &e) override;
};




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

@@ -19,8 +19,8 @@ struct ScrollWidget : widget::Widget {
void scrollTo(math::Rect r);
void draw(const DrawArgs &args) override;
void step() override;
void onHover(const widget::HoverEvent &e) override;
void onHoverScroll(const widget::HoverScrollEvent &e) override;
void onHover(const event::Hover &e) override;
void onHoverScroll(const event::HoverScroll &e) override;
};




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

@@ -16,10 +16,10 @@ struct Slider : widget::OpaqueWidget {

Slider();
void draw(const DrawArgs &args) override;
void onDragStart(const widget::DragStartEvent &e) override;
void onDragMove(const widget::DragMoveEvent &e) override;
void onDragEnd(const widget::DragEndEvent &e) override;
void onDoubleClick(const widget::DoubleClickEvent &e) override;
void onDragStart(const event::DragStart &e) override;
void onDragMove(const event::DragMove &e) override;
void onDragEnd(const event::DragEnd &e) override;
void onDoubleClick(const event::DoubleClick &e) override;
};




+ 6
- 7
include/ui/TextField.hpp View File

@@ -1,7 +1,6 @@
#pragma once
#include "widget/OpaqueWidget.hpp"
#include "ui/common.hpp"
#include "widget/event.hpp"
#include "app.hpp"


@@ -22,12 +21,12 @@ struct TextField : widget::OpaqueWidget {

TextField();
void draw(const DrawArgs &args) override;
void onHover(const widget::HoverEvent &e) override;
void onButton(const widget::ButtonEvent &e) override;
void onEnter(const widget::EnterEvent &e) override;
void onSelect(const widget::SelectEvent &e) override;
void onSelectText(const widget::SelectTextEvent &e) override;
void onSelectKey(const widget::SelectKeyEvent &e) override;
void onHover(const event::Hover &e) override;
void onButton(const event::Button &e) override;
void onEnter(const event::Enter &e) override;
void onSelect(const event::Select &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);


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

@@ -10,37 +10,37 @@ namespace widget {
Remember to call these methods in your subclass if you wish to preserve default OpaqueWidget behavior.
*/
struct OpaqueWidget : Widget {
void onHover(const HoverEvent &e) override {
void onHover(const event::Hover &e) override {
Widget::onHover(e);
e.stopPropagating();
// Consume if not consumed by child
if (!e.getTarget())
e.setTarget(this);
}
void onButton(const ButtonEvent &e) override {
void onButton(const event::Button &e) override {
Widget::onButton(e);
e.stopPropagating();
// Consume if not consumed by child
if (!e.getTarget())
e.setTarget(this);
}
void onHoverKey(const HoverKeyEvent &e) override {
void onHoverKey(const event::HoverKey &e) override {
Widget::onHoverKey(e);
e.stopPropagating();
}
void onHoverText(const HoverTextEvent &e) override {
void onHoverText(const event::HoverText &e) override {
Widget::onHoverText(e);
e.stopPropagating();
}
void onHoverScroll(const HoverScrollEvent &e) override {
void onHoverScroll(const event::HoverScroll &e) override {
Widget::onHoverScroll(e);
e.stopPropagating();
}
void onDragHover(const DragHoverEvent &e) override {
void onDragHover(const event::DragHover &e) override {
Widget::onDragHover(e);
e.stopPropagating();
}
void onPathDrop(const PathDropEvent &e) override {
void onPathDrop(const event::PathDrop &e) override {
Widget::onPathDrop(e);
e.stopPropagating();
}


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

@@ -9,13 +9,13 @@ namespace widget {
/** A Widget that does not respond to events and does not pass events to children */
struct TransparentWidget : Widget {
/** Override behavior to do nothing instead. */
void onHover(const HoverEvent &e) override {}
void onButton(const ButtonEvent &e) override {}
void onHoverKey(const HoverKeyEvent &e) override {}
void onHoverText(const HoverTextEvent &e) override {}
void onHoverScroll(const HoverScrollEvent &e) override {}
void onDragHover(const DragHoverEvent &e) override {}
void onPathDrop(const PathDropEvent &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 {}
};




+ 30
- 30
include/widget/Widget.hpp View File

@@ -3,7 +3,7 @@
#include "math.hpp"
#include "window.hpp"
#include "color.hpp"
#include "widget/event.hpp"
#include "event.hpp"
#include <list>


@@ -138,35 +138,35 @@ struct Widget {
/** Override these event callbacks to respond to events.
See events.hpp for a description of each event.
*/
virtual void onHover(const HoverEvent &e) {recursePositionEvent(&Widget::onHover, e);}
virtual void onButton(const ButtonEvent &e) {recursePositionEvent(&Widget::onButton, e);}
virtual void onDoubleClick(const DoubleClickEvent &e) {}
virtual void onHoverKey(const HoverKeyEvent &e) {recursePositionEvent(&Widget::onHoverKey, e);}
virtual void onHoverText(const HoverTextEvent &e) {recursePositionEvent(&Widget::onHoverText, e);}
virtual void onHoverScroll(const HoverScrollEvent &e) {recursePositionEvent(&Widget::onHoverScroll, e);}
virtual void onEnter(const EnterEvent &e) {}
virtual void onLeave(const LeaveEvent &e) {}
virtual void onSelect(const SelectEvent &e) {}
virtual void onDeselect(const DeselectEvent &e) {}
virtual void onSelectKey(const SelectKeyEvent &e) {}
virtual void onSelectText(const SelectTextEvent &e) {}
virtual void onDragStart(const DragStartEvent &e) {}
virtual void onDragEnd(const DragEndEvent &e) {}
virtual void onDragMove(const DragMoveEvent &e) {}
virtual void onDragHover(const DragHoverEvent &e) {recursePositionEvent(&Widget::onDragHover, e);}
virtual void onDragEnter(const DragEnterEvent &e) {}
virtual void onDragLeave(const DragLeaveEvent &e) {}
virtual void onDragDrop(const DragDropEvent &e) {}
virtual void onPathDrop(const PathDropEvent &e) {recursePositionEvent(&Widget::onPathDrop, e);}
virtual void onAction(const ActionEvent &e) {}
virtual void onChange(const ChangeEvent &e) {}
virtual void onZoom(const ZoomEvent &e) {recurseEvent(&Widget::onZoom, e);}
virtual void onReposition(const RepositionEvent &e) {}
virtual void onResize(const ResizeEvent &e) {}
virtual void onAdd(const AddEvent &e) {}
virtual void onRemove(const RemoveEvent &e) {}
virtual void onShow(const ShowEvent &e) {recurseEvent(&Widget::onShow, e);}
virtual void onHide(const HideEvent &e) {recurseEvent(&Widget::onHide, 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 onDoubleClick(const event::DoubleClick &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);}
virtual void onReposition(const event::Reposition &e) {}
virtual void onResize(const event::Resize &e) {}
virtual void onAdd(const event::Add &e) {}
virtual void onRemove(const event::Remove &e) {}
virtual void onShow(const event::Show &e) {recurseEvent(&Widget::onShow, e);}
virtual void onHide(const event::Hide &e) {recurseEvent(&Widget::onHide, e);}
};




+ 14
- 14
include/widget/ZoomWidget.hpp View File

@@ -15,38 +15,38 @@ struct ZoomWidget : Widget {
void setZoom(float zoom);
void draw(const DrawArgs &args) override;

void onHover(const HoverEvent &e) override {
HoverEvent e2 = e;
void onHover(const event::Hover &e) override {
event::Hover e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHover(e2);
}
void onButton(const ButtonEvent &e) override {
ButtonEvent e2 = e;
void onButton(const event::Button &e) override {
event::Button e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onButton(e2);
}
void onHoverKey(const HoverKeyEvent &e) override {
HoverKeyEvent e2 = e;
void onHoverKey(const event::HoverKey &e) override {
event::HoverKey e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverKey(e2);
}
void onHoverText(const HoverTextEvent &e) override {
HoverTextEvent e2 = e;
void onHoverText(const event::HoverText &e) override {
event::HoverText e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverText(e2);
}
void onHoverScroll(const HoverScrollEvent &e) override {
HoverScrollEvent e2 = e;
void onHoverScroll(const event::HoverScroll &e) override {
event::HoverScroll e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onHoverScroll(e2);
}
void onDragHover(const DragHoverEvent &e) override {
DragHoverEvent e2 = e;
void onDragHover(const event::DragHover &e) override {
event::DragHover e2 = e;
e2.pos = e.pos.div(zoom);
Widget::onDragHover(e2);
}
void onPathDrop(const PathDropEvent &e) override {
PathDropEvent e2 = 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

@@ -36,20 +36,20 @@ struct ModuleResizeHandle : OpaqueWidget {
box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT);
}

void onButton(const widget::ButtonEvent &e) override {
void onButton(const event::Button &e) override {
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
e.consume(this);
}
}

void onDragStart(const widget::DragStartEvent &e) override {
void onDragStart(const event::DragStart &e) override {
dragX = APP->scene->rack->mousePos.x;
ModuleWidget *m = getAncestorOfType<ModuleWidget>();
originalBox = m->box;
e.consume(this);
}

void onDragMove(const widget::DragMoveEvent &e) override {
void onDragMove(const event::DragMove &e) override {
ModuleWidget *m = getAncestorOfType<ModuleWidget>();

float newDragX = APP->scene->rack->mousePos.x;


+ 2
- 2
src/Core/CV_Gate.cpp View File

@@ -145,7 +145,7 @@ struct CV_Gate : Module {

struct CV_GateVelocityItem : MenuItem {
CV_Gate *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};
@@ -153,7 +153,7 @@ struct CV_GateVelocityItem : MenuItem {

struct CV_GatePanicItem : MenuItem {
CV_Gate *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->midiOutput.panic();
}
};


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

@@ -319,7 +319,7 @@ struct CV_MIDI : Module {

struct CV_MIDIPanicItem : MenuItem {
CV_MIDI *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->midiOutput.panic();
}
};


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

@@ -419,7 +419,7 @@ struct MIDI_CV : Module {
struct ClockDivisionValueItem : MenuItem {
MIDI_CV *module;
int clockDivision;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->clockDivision = clockDivision;
}
};
@@ -447,7 +447,7 @@ struct ClockDivisionItem : MenuItem {
struct ChannelValueItem : MenuItem {
MIDI_CV *module;
int channels;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->setChannels(channels);
}
};
@@ -476,7 +476,7 @@ struct ChannelItem : MenuItem {
struct PolyModeValueItem : MenuItem {
MIDI_CV *module;
MIDI_CV::PolyMode polyMode;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->setPolyMode(polyMode);
}
};
@@ -508,7 +508,7 @@ struct PolyModeItem : MenuItem {

struct MIDI_CVPanicItem : MenuItem {
MIDI_CV *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->panic();
}
};


+ 2
- 2
src/Core/MIDI_Gate.cpp View File

@@ -151,7 +151,7 @@ struct MIDI_Gate : Module {

struct MIDI_GateVelocityItem : MenuItem {
MIDI_Gate *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};
@@ -159,7 +159,7 @@ struct MIDI_GateVelocityItem : MenuItem {

struct MIDI_GatePanicItem : MenuItem {
MIDI_Gate *module;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
module->panic();
}
};


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

@@ -246,7 +246,7 @@ struct MIDI_MapChoice : LedDisplayChoice {
this->module = module;
}

void onButton(const widget::ButtonEvent &e) override {
void onButton(const event::Button &e) override {
if (!module)
return;

@@ -260,7 +260,7 @@ struct MIDI_MapChoice : LedDisplayChoice {
}
}

void onSelect(const widget::SelectEvent &e) override {
void onSelect(const event::Select &e) override {
if (!module)
return;

@@ -273,7 +273,7 @@ struct MIDI_MapChoice : LedDisplayChoice {
e.consume(this);
}

void onDeselect(const widget::DeselectEvent &e) override {
void onDeselect(const event::Deselect &e) override {
if (!module)
return;
// Check if a ParamWidget was touched


+ 7
- 7
src/Core/plugin.hpp View File

@@ -95,7 +95,7 @@ struct CcChoice : LedDisplayChoice {
}
}

void onSelect(const widget::SelectEvent &e) override {
void onSelect(const event::Select &e) override {
if (!module)
return;
module->learningId = id;
@@ -103,7 +103,7 @@ struct CcChoice : LedDisplayChoice {
e.consume(this);
}

void onDeselect(const widget::DeselectEvent &e) override {
void onDeselect(const event::Deselect &e) override {
if (!module)
return;
if (module->learningId == id) {
@@ -114,7 +114,7 @@ struct CcChoice : LedDisplayChoice {
}
}

void onSelectText(const widget::SelectTextEvent &e) override {
void onSelectText(const event::SelectText &e) override {
int c = e.codepoint - '0';
if (0 <= c && c <= 9) {
if (focusCc < 0)
@@ -126,9 +126,9 @@ struct CcChoice : LedDisplayChoice {
e.consume(this);
}

void onSelectKey(const widget::SelectKeyEvent &e) override {
void onSelectKey(const event::SelectKey &e) override {
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & WINDOW_MOD_MASK) == 0) {
widget::DeselectEvent eDeselect;
event::Deselect eDeselect;
onDeselect(eDeselect);
APP->event->selectedWidget = NULL;
e.consume(this);
@@ -181,14 +181,14 @@ struct NoteChoice : LedDisplayChoice {
}
}

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

void onDeselect(const widget::DeselectEvent &e) override {
void onDeselect(const event::Deselect &e) override {
if (!module)
return;
if (module->learningId == id) {


+ 1
- 2
src/app.cpp View File

@@ -1,5 +1,4 @@
#include "app.hpp"
#include "widget/event.hpp"
#include "window.hpp"
#include "patch.hpp"
#include "engine/Engine.hpp"
@@ -14,7 +13,7 @@ namespace rack {
void App::init() {
engine = new engine::Engine;
if (!settings::headless) {
event = new widget::EventState;
event = new event::State;
history = new history::State;
window = new Window;
patch = new PatchManager;


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

@@ -10,14 +10,14 @@ namespace app {
struct AudioDriverItem : ui::MenuItem {
audio::Port *port;
int driver;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setDriver(driver);
}
};

struct AudioDriverChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;

@@ -45,7 +45,7 @@ struct AudioDeviceItem : ui::MenuItem {
audio::Port *port;
int device;
int offset;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setDevice(device, offset);
}
};
@@ -55,7 +55,7 @@ struct AudioDeviceChoice : LedDisplayChoice {
/** Prevents devices with a ridiculous number of channels from being displayed */
int maxTotalChannels = 128;

void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;

@@ -103,14 +103,14 @@ struct AudioDeviceChoice : LedDisplayChoice {
struct AudioSampleRateItem : ui::MenuItem {
audio::Port *port;
int sampleRate;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setSampleRate(sampleRate);
}
};

struct AudioSampleRateChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;

@@ -141,14 +141,14 @@ struct AudioSampleRateChoice : LedDisplayChoice {
struct AudioBlockSizeItem : ui::MenuItem {
audio::Port *port;
int blockSize;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setBlockSize(blockSize);
}
};

struct AudioBlockSizeChoice : LedDisplayChoice {
audio::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;



+ 0
- 1
src/app/CableWidget.cpp View File

@@ -1,7 +1,6 @@
#include "app/CableWidget.hpp"
#include "app/Scene.hpp"
#include "window.hpp"
#include "widget/event.hpp"
#include "app.hpp"
#include "patch.hpp"
#include "settings.hpp"


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

@@ -12,7 +12,7 @@ namespace app {
static const float KNOB_SENSITIVITY = 0.0015f;


void Knob::onHover(const widget::HoverEvent &e) {
void Knob::onHover(const event::Hover &e) {
math::Vec c = box.size.div(2);
float dist = e.pos.minus(c).norm();
if (dist <= c.x) {
@@ -20,7 +20,7 @@ void Knob::onHover(const widget::HoverEvent &e) {
}
}

void Knob::onButton(const widget::ButtonEvent &e) {
void Knob::onButton(const event::Button &e) {
math::Vec c = box.size.div(2);
float dist = e.pos.minus(c).norm();
if (dist <= c.x) {
@@ -28,7 +28,7 @@ void Knob::onButton(const widget::ButtonEvent &e) {
}
}

void Knob::onDragStart(const widget::DragStartEvent &e) {
void Knob::onDragStart(const event::DragStart &e) {
if (paramQuantity) {
oldValue = paramQuantity->getSmoothValue();
if (snap) {
@@ -40,7 +40,7 @@ void Knob::onDragStart(const widget::DragStartEvent &e) {
e.consume(this);
}

void Knob::onDragEnd(const widget::DragEndEvent &e) {
void Knob::onDragEnd(const event::DragEnd &e) {
APP->window->cursorUnlock();

if (paramQuantity) {
@@ -58,7 +58,7 @@ void Knob::onDragEnd(const widget::DragEndEvent &e) {
}
}

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


+ 2
- 3
src/app/LedDisplay.cpp View File

@@ -1,7 +1,6 @@
#include "app/LedDisplay.hpp"
#include "asset.hpp"
#include "window.hpp"
#include "widget/event.hpp"
#include "app.hpp"


@@ -62,9 +61,9 @@ void LedDisplayChoice::draw(const DrawArgs &args) {
}
}

void LedDisplayChoice::onButton(const widget::ButtonEvent &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)) {
widget::ActionEvent eAction;
event::Action eAction;
onAction(eAction);
e.consume(this);
}


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

@@ -10,14 +10,14 @@ namespace app {
struct MidiDriverItem : ui::MenuItem {
midi::Port *port;
int driverId;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setDriverId(driverId);
}
};

struct MidiDriverChoice : LedDisplayChoice {
midi::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;

@@ -51,14 +51,14 @@ struct MidiDriverChoice : LedDisplayChoice {
struct MidiDeviceItem : ui::MenuItem {
midi::Port *port;
int deviceId;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->setDeviceId(deviceId);
}
};

struct MidiDeviceChoice : LedDisplayChoice {
midi::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;

@@ -100,14 +100,14 @@ struct MidiDeviceChoice : LedDisplayChoice {
struct MidiChannelItem : ui::MenuItem {
midi::Port *port;
int channel;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
port->channel = channel;
}
};

struct MidiChannelChoice : LedDisplayChoice {
midi::Port *port;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
if (!port)
return;



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

@@ -60,7 +60,7 @@ struct BrowserOverlay : widget::OpaqueWidget {
OpaqueWidget::step();
}

void onButton(const widget::ButtonEvent &e) override {
void onButton(const event::Button &e) override {
OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -252,26 +252,26 @@ struct ModelBox : widget::OpaqueWidget {
OpaqueWidget::draw(args);
}

void onButton(const widget::ButtonEvent &e) override;
void onButton(const event::Button &e) override;

void onEnter(const widget::EnterEvent &e) override {
void onEnter(const event::Enter &e) override {
e.consume(this);
infoBox->show();
}

void onLeave(const widget::LeaveEvent &e) override {
void onLeave(const event::Leave &e) override {
infoBox->hide();
}
};


struct AuthorItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override;
void onAction(const event::Action &e) override;
};


struct TagItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override;
void onAction(const event::Action &e) override;
};


@@ -282,7 +282,7 @@ struct BrowserSearchField : ui::TextField {
TextField::step();
}

void onSelectKey(const widget::SelectKeyEvent &e) override {
void onSelectKey(const event::SelectKey &e) override {
if (e.action == GLFW_PRESS) {
if (e.key == GLFW_KEY_ESCAPE) {
BrowserOverlay *overlay = getAncestorOfType<BrowserOverlay>();
@@ -295,14 +295,14 @@ struct BrowserSearchField : ui::TextField {
ui::TextField::onSelectKey(e);
}

void onChange(const widget::ChangeEvent &e) override;
void onChange(const event::Change &e) override;

void onHide(const widget::HideEvent &e) override {
void onHide(const event::Hide &e) override {
APP->event->setSelected(NULL);
ui::TextField::onHide(e);
}

void onShow(const widget::ShowEvent &e) override {
void onShow(const event::Show &e) override {
selectAll();
TextField::onShow(e);
}
@@ -613,7 +613,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
// Implementations to resolve dependencies


inline void ModelBox::onButton(const widget::ButtonEvent &e) {
inline void ModelBox::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -640,7 +640,7 @@ inline void ModelBox::onButton(const widget::ButtonEvent &e) {
}


inline void AuthorItem::onAction(const widget::ActionEvent &e) {
inline void AuthorItem::onAction(const event::Action &e) {
ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>();
if (browser->author == text)
browser->author = "";
@@ -650,7 +650,7 @@ inline void AuthorItem::onAction(const widget::ActionEvent &e) {
}


inline void TagItem::onAction(const widget::ActionEvent &e) {
inline void TagItem::onAction(const event::Action &e) {
ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>();
if (browser->tag == text)
browser->tag = "";
@@ -660,7 +660,7 @@ inline void TagItem::onAction(const widget::ActionEvent &e) {
}


inline void BrowserSearchField::onChange(const widget::ChangeEvent &e) {
inline void BrowserSearchField::onChange(const event::Change &e) {
ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>();
browser->search = string::trim(text);
browser->refresh();


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

@@ -23,7 +23,7 @@ static const char PRESET_FILTERS[] = "VCV Rack module preset (.vcvm):vcvm";

struct ModuleUrlItem : ui::MenuItem {
std::string url;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t(system::openBrowser, url);
t.detach();
}
@@ -32,7 +32,7 @@ struct ModuleUrlItem : ui::MenuItem {

struct ModuleFolderItem : ui::MenuItem {
std::string path;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t(system::openFolder, path);
t.detach();
}
@@ -108,7 +108,7 @@ struct ModulePluginItem : ui::MenuItem {

struct ModuleDisconnectItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->disconnectAction();
}
};
@@ -116,7 +116,7 @@ struct ModuleDisconnectItem : ui::MenuItem {

struct ModuleResetItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->resetAction();
}
};
@@ -124,7 +124,7 @@ struct ModuleResetItem : ui::MenuItem {

struct ModuleRandomizeItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->randomizeAction();
}
};
@@ -132,7 +132,7 @@ struct ModuleRandomizeItem : ui::MenuItem {

struct ModuleCopyItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->copyClipboard();
}
};
@@ -140,7 +140,7 @@ struct ModuleCopyItem : ui::MenuItem {

struct ModulePasteItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->pasteClipboardAction();
}
};
@@ -148,7 +148,7 @@ struct ModulePasteItem : ui::MenuItem {

struct ModuleSaveItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->saveDialog();
}
};
@@ -156,7 +156,7 @@ struct ModuleSaveItem : ui::MenuItem {

struct ModuleLoadItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->loadDialog();
}
};
@@ -165,7 +165,7 @@ struct ModuleLoadItem : ui::MenuItem {
struct ModulePresetPathItem : ui::MenuItem {
ModuleWidget *moduleWidget;
std::string presetPath;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->loadAction(presetPath);
}
};
@@ -219,7 +219,7 @@ struct ModulePresetItem : ui::MenuItem {

struct ModuleCloneItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->cloneAction();
}
};
@@ -227,7 +227,7 @@ struct ModuleCloneItem : ui::MenuItem {

struct ModuleBypassItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->bypassAction();
}
};
@@ -235,7 +235,7 @@ struct ModuleBypassItem : ui::MenuItem {

struct ModuleDeleteItem : ui::MenuItem {
ModuleWidget *moduleWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
moduleWidget->removeAction();
}
};
@@ -304,7 +304,7 @@ void ModuleWidget::drawShadow(const DrawArgs &args) {
nvgFill(args.vg);
}

void ModuleWidget::onHover(const widget::HoverEvent &e) {
void ModuleWidget::onHover(const event::Hover &e) {
widget::OpaqueWidget::onHover(e);

if (!APP->event->selectedWidget) {
@@ -319,7 +319,7 @@ void ModuleWidget::onHover(const widget::HoverEvent &e) {
}
}

void ModuleWidget::onButton(const widget::ButtonEvent &e) {
void ModuleWidget::onButton(const event::Button &e) {
widget::OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -330,7 +330,7 @@ void ModuleWidget::onButton(const widget::ButtonEvent &e) {
}
}

void ModuleWidget::onHoverKey(const widget::HoverKeyEvent &e) {
void ModuleWidget::onHoverKey(const event::HoverKey &e) {
widget::OpaqueWidget::onHoverKey(e);
if (e.getTarget() != this)
return;
@@ -383,13 +383,13 @@ void ModuleWidget::onHoverKey(const widget::HoverKeyEvent &e) {
}
}

void ModuleWidget::onDragStart(const widget::DragStartEvent &e) {
void ModuleWidget::onDragStart(const event::DragStart &e) {
oldPos = box.pos;
dragPos = APP->scene->rack->mousePos.minus(box.pos);
e.consume(this);
}

void ModuleWidget::onDragEnd(const widget::DragEndEvent &e) {
void ModuleWidget::onDragEnd(const event::DragEnd &e) {
if (!box.pos.isEqual(oldPos)) {
// history::ModuleMove
history::ModuleMove *h = new history::ModuleMove;
@@ -400,7 +400,7 @@ void ModuleWidget::onDragEnd(const widget::DragEndEvent &e) {
}
}

void ModuleWidget::onDragMove(const widget::DragMoveEvent &e) {
void ModuleWidget::onDragMove(const event::DragMove &e) {
if (!settings::lockModules) {
math::Rect newBox = box;
newBox.pos = APP->scene->rack->mousePos.minus(dragPos);


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

@@ -29,7 +29,7 @@ struct ParamField : ui::TextField {
selectAll();
}

void onSelectKey(const widget::SelectKeyEvent &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)) {
float oldValue = paramWidget->paramQuantity->getValue();
if (paramWidget->paramQuantity)
@@ -87,7 +87,7 @@ struct ParamLabel : ui::MenuLabel {

struct ParamResetItem : ui::MenuItem {
ParamWidget *paramWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
paramWidget->resetAction();
}
};
@@ -99,7 +99,7 @@ struct ParamFineItem : ui::MenuItem {

struct ParamUnmapItem : ui::MenuItem {
ParamWidget *paramWidget;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
engine::ParamHandle *paramHandle = APP->engine->getParamHandle(paramWidget->paramQuantity->module, paramWidget->paramQuantity->paramId);
if (paramHandle) {
APP->engine->updateParamHandle(paramHandle, -1, 0);
@@ -114,7 +114,7 @@ void ParamWidget::step() {
// Trigger change event when paramQuantity value changes
if (value != dirtyValue) {
dirtyValue = value;
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
}
}
@@ -139,7 +139,7 @@ void ParamWidget::draw(const DrawArgs &args) {
}
}

void ParamWidget::onButton(const widget::ButtonEvent &e) {
void ParamWidget::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -158,11 +158,11 @@ void ParamWidget::onButton(const widget::ButtonEvent &e) {
}
}

void ParamWidget::onDoubleClick(const widget::DoubleClickEvent &e) {
void ParamWidget::onDoubleClick(const event::DoubleClick &e) {
resetAction();
}

void ParamWidget::onEnter(const widget::EnterEvent &e) {
void ParamWidget::onEnter(const event::Enter &e) {
if (settings::paramTooltip && !tooltip && paramQuantity) {
ParamTooltip *paramTooltip = new ParamTooltip;
paramTooltip->paramWidget = this;
@@ -172,7 +172,7 @@ void ParamWidget::onEnter(const widget::EnterEvent &e) {
}
}

void ParamWidget::onLeave(const widget::LeaveEvent &e) {
void ParamWidget::onLeave(const event::Leave &e) {
if (tooltip) {
APP->scene->removeChild(tooltip);
delete tooltip;


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

@@ -59,7 +59,7 @@ void PortWidget::draw(const DrawArgs &args) {
Widget::draw(args);
}

void PortWidget::onButton(const widget::ButtonEvent &e) {
void PortWidget::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);

if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
@@ -76,16 +76,16 @@ void PortWidget::onButton(const widget::ButtonEvent &e) {
}
}

void PortWidget::onEnter(const widget::EnterEvent &e) {
void PortWidget::onEnter(const event::Enter &e) {
hovered = true;
e.consume(this);
}

void PortWidget::onLeave(const widget::LeaveEvent &e) {
void PortWidget::onLeave(const event::Leave &e) {
hovered = false;
}

void PortWidget::onDragStart(const widget::DragStartEvent &e) {
void PortWidget::onDragStart(const event::DragStart &e) {
CableWidget *cw = NULL;
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) {
if (type == OUTPUT) {
@@ -131,7 +131,7 @@ void PortWidget::onDragStart(const widget::DragStartEvent &e) {
e.consume(this);
}

void PortWidget::onDragEnd(const widget::DragEndEvent &e) {
void PortWidget::onDragEnd(const event::DragEnd &e) {
CableWidget *cw = APP->scene->rack->releaseIncompleteCable();
if (cw->isComplete()) {
APP->scene->rack->addCable(cw);
@@ -146,7 +146,7 @@ void PortWidget::onDragEnd(const widget::DragEndEvent &e) {
}
}

void PortWidget::onDragDrop(const widget::DragDropEvent &e) {
void PortWidget::onDragDrop(const event::DragDrop &e) {
// Reject ports if this is an input port and something is already plugged into it
if (type == INPUT) {
if (APP->scene->rack->getTopCable(this))
@@ -163,7 +163,7 @@ void PortWidget::onDragDrop(const widget::DragDropEvent &e) {
}
}

void PortWidget::onDragEnter(const widget::DragEnterEvent &e) {
void PortWidget::onDragEnter(const event::DragEnter &e) {
// Reject ports if this is an input port and something is already plugged into it
if (type == INPUT) {
if (APP->scene->rack->getTopCable(this))
@@ -180,7 +180,7 @@ void PortWidget::onDragEnter(const widget::DragEnterEvent &e) {
e.consume(this);
}

void PortWidget::onDragLeave(const widget::DragLeaveEvent &e) {
void PortWidget::onDragLeave(const event::DragLeave &e) {
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin);
if (!originPort)
return;


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

@@ -71,7 +71,7 @@ void RackScrollWidget::draw(const DrawArgs &args) {
ScrollWidget::draw(args);
}

void RackScrollWidget::onHover(const widget::HoverEvent &e) {
void RackScrollWidget::onHover(const event::Hover &e) {
if (!APP->event->selectedWidget) {
// Scroll with arrow keys
float arrowSpeed = 30.0;
@@ -95,7 +95,7 @@ void RackScrollWidget::onHover(const widget::HoverEvent &e) {
ScrollWidget::onHover(e);
}

void RackScrollWidget::onHoverScroll(const widget::HoverScrollEvent &e) {
void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) {
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) {
// Increase zoom
float zoomDelta = e.scrollDelta.y / 50 / 4;


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

@@ -116,12 +116,12 @@ void RackWidget::draw(const DrawArgs &args) {
OpaqueWidget::draw(args);
}

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

void RackWidget::onHoverKey(const widget::HoverKeyEvent &e) {
void RackWidget::onHoverKey(const event::HoverKey &e) {
OpaqueWidget::onHoverKey(e);
if (e.getTarget() != this)
return;
@@ -138,12 +138,12 @@ void RackWidget::onHoverKey(const widget::HoverKeyEvent &e) {
}
}

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

void RackWidget::onButton(const widget::ButtonEvent &e) {
void RackWidget::onButton(const event::Button &e) {
OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -154,7 +154,7 @@ void RackWidget::onButton(const widget::ButtonEvent &e) {
}
}

void RackWidget::onZoom(const widget::ZoomEvent &e) {
void RackWidget::onZoom(const event::Zoom &e) {
OpaqueWidget::onZoom(e);
}



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

@@ -71,7 +71,7 @@ void Scene::draw(const DrawArgs &args) {
OpaqueWidget::draw(args);
}

void Scene::onHoverKey(const widget::HoverKeyEvent &e) {
void Scene::onHoverKey(const event::HoverKey &e) {
OpaqueWidget::onHoverKey(e);
if (e.getTarget() != this)
return;
@@ -133,7 +133,7 @@ void Scene::onHoverKey(const widget::HoverKeyEvent &e) {
}
}

void Scene::onPathDrop(const widget::PathDropEvent &e) {
void Scene::onPathDrop(const event::PathDrop &e) {
OpaqueWidget::onPathDrop(e);
if (e.getTarget() != this)
return;


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

@@ -30,7 +30,7 @@ void SvgButton::addFrame(std::shared_ptr<Svg> svg) {
}
}

void SvgButton::onDragStart(const widget::DragStartEvent &e) {
void SvgButton::onDragStart(const event::DragStart &e) {
if (frames.size() >= 2) {
sw->setSvg(frames[1]);
fb->dirty = true;
@@ -38,16 +38,16 @@ void SvgButton::onDragStart(const widget::DragStartEvent &e) {
e.consume(this);
}

void SvgButton::onDragEnd(const widget::DragEndEvent &e) {
void SvgButton::onDragEnd(const event::DragEnd &e) {
if (frames.size() >= 1) {
sw->setSvg(frames[0]);
fb->dirty = true;
}
}

void SvgButton::onDragDrop(const widget::DragDropEvent &e) {
void SvgButton::onDragDrop(const event::DragDrop &e) {
if (e.origin == this) {
widget::ActionEvent eAction;
event::Action eAction;
onAction(eAction);
}
}


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

@@ -31,7 +31,7 @@ void SvgKnob::setSvg(std::shared_ptr<Svg> svg) {
// shadow->box = shadow->box.grow(math::Vec(2, 2));
}

void SvgKnob::onChange(const widget::ChangeEvent &e) {
void SvgKnob::onChange(const event::Change &e) {
// Re-transform the widget::TransformWidget
if (paramQuantity) {
float angle;


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

@@ -30,7 +30,7 @@ void SvgSlider::setHandleSvg(std::shared_ptr<Svg> svg) {
fb->dirty = true;
}

void SvgSlider::onChange(const widget::ChangeEvent &e) {
void SvgSlider::onChange(const event::Change &e) {
if (paramQuantity) {
// Interpolate handle position
float v = paramQuantity->getScaledValue();


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

@@ -30,7 +30,7 @@ void SvgSwitch::addFrame(std::shared_ptr<Svg> svg) {
}
}

void SvgSwitch::onChange(const widget::ChangeEvent &e) {
void SvgSwitch::onChange(const event::Change &e) {
if (!frames.empty() && paramQuantity) {
int index = (int) std::round(paramQuantity->getValue());
index = math::clamp(index, 0, (int) frames.size() - 1);


+ 3
- 3
src/app/Switch.cpp View File

@@ -24,11 +24,11 @@ void Switch::step() {
ParamWidget::step();
}

void Switch::onDoubleClick(const widget::DoubleClickEvent &e) {
void Switch::onDoubleClick(const event::DoubleClick &e) {
// Don't reset parameter on double-click
}

void Switch::onDragStart(const widget::DragStartEvent &e) {
void Switch::onDragStart(const event::DragStart &e) {
if (momentary) {
if (paramQuantity) {
// Set to maximum value
@@ -64,7 +64,7 @@ void Switch::onDragStart(const widget::DragStartEvent &e) {
e.consume(this);
}

void Switch::onDragEnd(const widget::DragEndEvent &e) {
void Switch::onDragEnd(const event::DragEnd &e) {
if (momentary) {
momentaryReleased = true;
}


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

@@ -34,63 +34,63 @@ struct MenuButton : ui::Button {


struct NewItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->resetDialog();
}
};


struct OpenItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->loadDialog();
}
};


struct SaveItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->saveDialog();
}
};


struct SaveAsItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->saveAsDialog();
}
};


struct SaveTemplateItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->saveTemplateDialog();
}
};


struct RevertItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->revertDialog();
}
};


struct DisconnectCablesItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->patch->disconnectDialog();
}
};


struct QuitItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->window->close();
}
};


struct FileButton : MenuButton {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
ui::Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -136,21 +136,21 @@ struct FileButton : MenuButton {


struct UndoItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->history->undo();
}
};


struct RedoItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->history->redo();
}
};


struct EditButton : MenuButton {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
ui::Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -247,28 +247,28 @@ struct CableTensionSlider : ui::Slider {


struct CpuMeterItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
settings::cpuMeter ^= true;
}
};


struct ParamTooltipItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
settings::paramTooltip ^= true;
}
};


struct LockModulesItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
settings::lockModules ^= true;
}
};


struct EnginePauseItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->engine->setPaused(!APP->engine->isPaused());
}
};
@@ -276,7 +276,7 @@ struct EnginePauseItem : ui::MenuItem {

struct SampleRateValueItem : ui::MenuItem {
float sampleRate;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->engine->setSampleRate(sampleRate);
APP->engine->setPaused(false);
}
@@ -324,7 +324,7 @@ struct ThreadCountValueItem : ui::MenuItem {
text += " (lowest CPU usage)";
rightText = CHECKMARK(APP->engine->getThreadCount() == threadCount);
}
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->engine->setThreadCount(threadCount);
}
};
@@ -346,14 +346,14 @@ struct ThreadCount : ui::MenuItem {


struct FullscreenItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
APP->window->setFullScreen(!APP->window->isFullScreen());
}
};


struct SettingsButton : MenuButton {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
ui::Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -406,7 +406,7 @@ struct SettingsButton : MenuButton {


struct RegisterItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/");
});
@@ -417,7 +417,7 @@ struct RegisterItem : ui::MenuItem {

struct AccountEmailField : ui::TextField {
ui::TextField *passwordField;
void onSelectKey(const widget::SelectKeyEvent &e) override {
void onSelectKey(const event::SelectKey &e) override {
if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) {
APP->event->selectedWidget = passwordField;
e.consume(this);
@@ -431,7 +431,7 @@ struct AccountEmailField : ui::TextField {

struct AccountPasswordField : ui::PasswordField {
ui::MenuItem *logInItem;
void onSelectKey(const widget::SelectKeyEvent &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);
@@ -446,7 +446,7 @@ struct AccountPasswordField : ui::PasswordField {
struct LogInItem : ui::MenuItem {
ui::TextField *emailField;
ui::TextField *passwordField;
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::string email = emailField->text;
std::string password = passwordField->text;
std::thread t([&, email, password]() {
@@ -460,7 +460,7 @@ struct LogInItem : ui::MenuItem {
struct ManageItem : ui::MenuItem {
ManageItem() {
}
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t([&]() {
system::openBrowser("https://vcvrack.com/plugins.html");
});
@@ -470,7 +470,7 @@ struct ManageItem : ui::MenuItem {


struct SyncItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
}
};

@@ -500,7 +500,7 @@ struct SyncItem : ui::MenuItem {
// completed = false;
// }
// }
// void onAction(const widget::ActionEvent &e) override {
// void onAction(const event::Action &e) override {
// available = false;
// std::thread t([this]() {
// if (plugin::sync(false))
@@ -512,7 +512,7 @@ struct SyncItem : ui::MenuItem {


struct LogOutItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
plugin::logOut();
}
};
@@ -538,7 +538,7 @@ struct DownloadQuantity : Quantity {


struct PluginsButton : MenuButton {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
ui::Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;
@@ -604,7 +604,7 @@ struct PluginsButton : MenuButton {


struct ManualItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t(system::openBrowser, "https://vcvrack.com/manual/");
t.detach();
}
@@ -612,7 +612,7 @@ struct ManualItem : ui::MenuItem {


struct WebsiteItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t(system::openBrowser, "https://vcvrack.com/");
t.detach();
}
@@ -620,14 +620,14 @@ struct WebsiteItem : ui::MenuItem {


struct CheckVersionItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
settings::checkVersion ^= true;
}
};


struct UserFolderItem : ui::MenuItem {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
std::thread t(system::openFolder, asset::user(""));
t.detach();
}
@@ -635,7 +635,7 @@ struct UserFolderItem : ui::MenuItem {


struct HelpButton : MenuButton {
void onAction(const widget::ActionEvent &e) override {
void onAction(const event::Action &e) override {
ui::Menu *menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;


src/widget/event.cpp → src/event.cpp View File

@@ -1,69 +1,69 @@
#include "widget/event.hpp"
#include "event.hpp"
#include "widget/Widget.hpp"


namespace rack {
namespace widget {
namespace event {


void EventState::setHovered(Widget *w) {
void State::setHovered(widget::Widget *w) {
if (w == hoveredWidget)
return;

if (hoveredWidget) {
// LeaveEvent
LeaveEvent eLeave;
// Leave
Leave eLeave;
hoveredWidget->onLeave(eLeave);
hoveredWidget = NULL;
}

if (w) {
// EnterEvent
EventContext cEnter;
EnterEvent eEnter;
// Enter
Context cEnter;
Enter eEnter;
eEnter.context = &cEnter;
w->onEnter(eEnter);
hoveredWidget = cEnter.target;
}
}

void EventState::setDragged(Widget *w) {
void State::setDragged(widget::Widget *w) {
if (w == draggedWidget)
return;

if (draggedWidget) {
// DragEndEvent
DragEndEvent eDragEnd;
// DragEnd
DragEnd eDragEnd;
draggedWidget->onDragEnd(eDragEnd);
draggedWidget = NULL;
}

if (w) {
// DragStartEvent
EventContext cDragStart;
DragStartEvent eDragStart;
// DragStart
Context cDragStart;
DragStart eDragStart;
eDragStart.context = &cDragStart;
w->onDragStart(eDragStart);
draggedWidget = cDragStart.target;
}
}

void EventState::setDragHovered(Widget *w) {
void State::setDragHovered(widget::Widget *w) {
if (w == dragHoveredWidget)
return;

if (dragHoveredWidget) {
// DragLeaveEvent
DragLeaveEvent eDragLeave;
// DragLeave
DragLeave eDragLeave;
eDragLeave.origin = draggedWidget;
dragHoveredWidget->onDragLeave(eDragLeave);
dragHoveredWidget = NULL;
}

if (w) {
// DragEnterEvent
EventContext cDragEnter;
DragEnterEvent eDragEnter;
// DragEnter
Context cDragEnter;
DragEnter eDragEnter;
eDragEnter.context = &cDragEnter;
eDragEnter.origin = draggedWidget;
w->onDragEnter(eDragEnter);
@@ -71,28 +71,28 @@ void EventState::setDragHovered(Widget *w) {
}
}

void EventState::setSelected(Widget *w) {
void State::setSelected(widget::Widget *w) {
if (w == selectedWidget)
return;

if (selectedWidget) {
// DeselectEvent
DeselectEvent eDeselect;
// Deselect
Deselect eDeselect;
selectedWidget->onDeselect(eDeselect);
selectedWidget = NULL;
}

if (w) {
// SelectEvent
EventContext cSelect;
SelectEvent eSelect;
// Select
Context cSelect;
Select eSelect;
eSelect.context = &cSelect;
w->onSelect(eSelect);
selectedWidget = cSelect.target;
}
}

void EventState::finalizeWidget(Widget *w) {
void State::finalizeWidget(widget::Widget *w) {
if (hoveredWidget == w) setHovered(NULL);
if (draggedWidget == w) setDragged(NULL);
if (dragHoveredWidget == w) setDragHovered(NULL);
@@ -100,17 +100,17 @@ void EventState::finalizeWidget(Widget *w) {
if (lastClickedWidget == w) lastClickedWidget = NULL;
}

void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
// ButtonEvent
EventContext cButton;
ButtonEvent eButton;
void State::handleButton(math::Vec pos, int button, int action, int mods) {
// Button
Context cButton;
Button eButton;
eButton.context = &cButton;
eButton.pos = pos;
eButton.button = button;
eButton.action = action;
eButton.mods = mods;
rootWidget->onButton(eButton);
Widget *clickedWidget = cButton.target;
widget::Widget *clickedWidget = cButton.target;

if (button == GLFW_MOUSE_BUTTON_LEFT) {
if (action == GLFW_PRESS) {
@@ -121,8 +121,8 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
setDragHovered(NULL);

if (clickedWidget && draggedWidget) {
// DragDropEvent
DragDropEvent eDragDrop;
// DragDrop
DragDrop eDragDrop;
eDragDrop.origin = draggedWidget;
clickedWidget->onDragDrop(eDragDrop);
}
@@ -140,8 +140,8 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
if (clickedWidget
&& clickTime - lastClickTime <= doubleClickDuration
&& lastClickedWidget == clickedWidget) {
// DoubleClickEvent
DoubleClickEvent eDoubleClick;
// DoubleClick
DoubleClick eDoubleClick;
clickedWidget->onDoubleClick(eDoubleClick);
// Reset double click
lastClickTime = -INFINITY;
@@ -155,16 +155,16 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) {
}
}

void EventState::handleHover(math::Vec pos, math::Vec mouseDelta) {
void State::handleHover(math::Vec pos, math::Vec mouseDelta) {
if (draggedWidget) {
// DragMoveEvent
DragMoveEvent eDragMove;
// DragMove
DragMove eDragMove;
eDragMove.mouseDelta = mouseDelta;
draggedWidget->onDragMove(eDragMove);

// DragHoverEvent
EventContext cDragHover;
DragHoverEvent eDragHover;
// DragHover
Context cDragHover;
DragHover eDragHover;
eDragHover.context = &cDragHover;
eDragHover.pos = pos;
eDragHover.mouseDelta = mouseDelta;
@@ -176,9 +176,9 @@ void EventState::handleHover(math::Vec pos, math::Vec mouseDelta) {
return;
}

// HoverEvent
EventContext cHover;
HoverEvent eHover;
// Hover
Context cHover;
Hover eHover;
eHover.context = &cHover;
eHover.pos = pos;
eHover.mouseDelta = mouseDelta;
@@ -187,35 +187,35 @@ void EventState::handleHover(math::Vec pos, math::Vec mouseDelta) {
setHovered(cHover.target);
}

void EventState::handleLeave() {
void State::handleLeave() {
setDragHovered(NULL);
setHovered(NULL);
}

void EventState::handleScroll(math::Vec pos, math::Vec scrollDelta) {
// HoverScrollEvent
EventContext cHoverScroll;
HoverScrollEvent eHoverScroll;
void State::handleScroll(math::Vec pos, math::Vec scrollDelta) {
// HoverScroll
Context cHoverScroll;
HoverScroll eHoverScroll;
eHoverScroll.context = &cHoverScroll;
eHoverScroll.pos = pos;
eHoverScroll.scrollDelta = scrollDelta;
rootWidget->onHoverScroll(eHoverScroll);
}

void EventState::handleDrop(math::Vec pos, const std::vector<std::string> &paths) {
// PathDropEvent
EventContext cPathDrop;
PathDropEvent ePathDrop(paths);
void State::handleDrop(math::Vec pos, const std::vector<std::string> &paths) {
// PathDrop
Context cPathDrop;
PathDrop ePathDrop(paths);
ePathDrop.context = &cPathDrop;
ePathDrop.pos = pos;
rootWidget->onPathDrop(ePathDrop);
}

void EventState::handleText(math::Vec pos, int codepoint) {
void State::handleText(math::Vec pos, int codepoint) {
if (selectedWidget) {
// SelectTextEvent
EventContext cSelectText;
SelectTextEvent eSelectText;
// SelectText
Context cSelectText;
SelectText eSelectText;
eSelectText.context = &cSelectText;
eSelectText.codepoint = codepoint;
selectedWidget->onSelectText(eSelectText);
@@ -223,20 +223,20 @@ void EventState::handleText(math::Vec pos, int codepoint) {
return;
}

// HoverTextEvent
EventContext cHoverText;
HoverTextEvent eHoverText;
// HoverText
Context cHoverText;
HoverText eHoverText;
eHoverText.context = &cHoverText;
eHoverText.pos = pos;
eHoverText.codepoint = codepoint;
rootWidget->onHoverText(eHoverText);
}

void EventState::handleKey(math::Vec pos, int key, int scancode, int action, int mods) {
void State::handleKey(math::Vec pos, int key, int scancode, int action, int mods) {
if (selectedWidget) {
// SelectKeyEvent
EventContext cSelectKey;
SelectKeyEvent eSelectKey;
// SelectKey
Context cSelectKey;
SelectKey eSelectKey;
eSelectKey.context = &cSelectKey;
eSelectKey.key = key;
eSelectKey.scancode = scancode;
@@ -247,9 +247,9 @@ void EventState::handleKey(math::Vec pos, int key, int scancode, int action, int
return;
}

// HoverKeyEvent
EventContext cHoverKey;
HoverKeyEvent eHoverKey;
// HoverKey
Context cHoverKey;
HoverKey eHoverKey;
eHoverKey.context = &cHoverKey;
eHoverKey.pos = pos;
eHoverKey.key = key;
@@ -259,14 +259,14 @@ void EventState::handleKey(math::Vec pos, int key, int scancode, int action, int
rootWidget->onHoverKey(eHoverKey);
}

void EventState::handleZoom() {
// ZoomEvent
EventContext cZoom;
ZoomEvent eZoom;
void State::handleZoom() {
// Zoom
Context cZoom;
Zoom eZoom;
eZoom.context = &cZoom;
rootWidget->onZoom(eZoom);
}


} // namespace widget
} // namespace event
} // namespace rack

+ 6
- 6
src/ui/Button.cpp View File

@@ -13,31 +13,31 @@ void Button::draw(const DrawArgs &args) {
bndToolButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str());
}

void Button::onEnter(const widget::EnterEvent &e) {
void Button::onEnter(const event::Enter &e) {
state = BND_HOVER;
e.consume(this);
}

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

void Button::onDragStart(const widget::DragStartEvent &e) {
void Button::onDragStart(const event::DragStart &e) {
state = BND_ACTIVE;
if (quantity)
quantity->setMax();
e.consume(this);
}

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

void Button::onDragDrop(const widget::DragDropEvent &e) {
void Button::onDragDrop(const event::DragDrop &e) {
if (e.origin == this) {
widget::ActionEvent eAction;
event::Action eAction;
onAction(eAction);
}
}


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

@@ -54,7 +54,7 @@ void Menu::draw(const DrawArgs &args) {
Widget::draw(args);
}

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


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

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

void MenuItem::onEnter(const widget::EnterEvent &e) {
void MenuItem::onEnter(const event::Enter &e) {
e.consume(this);
Menu *parentMenu = dynamic_cast<Menu*>(parent);
if (!parentMenu)
@@ -58,11 +58,11 @@ void MenuItem::onEnter(const widget::EnterEvent &e) {
parentMenu->setChildMenu(childMenu);
}

void MenuItem::onDragStart(const widget::DragStartEvent &e) {
void MenuItem::onDragStart(const event::DragStart &e) {
e.consume(this);
}

void MenuItem::onDragDrop(const widget::DragDropEvent &e) {
void MenuItem::onDragDrop(const event::DragDrop &e) {
if (e.origin != this)
return;
doAction();
@@ -72,8 +72,8 @@ void MenuItem::doAction() {
if (disabled)
return;

widget::EventContext cAction;
widget::ActionEvent eAction;
event::Context cAction;
event::Action eAction;
eAction.context = &cAction;
// Consume event by default, but allow action to un-consume it to prevent the menu from being removed.
eAction.consume(this);


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

@@ -17,7 +17,7 @@ void MenuOverlay::step() {
Widget::step();
}

void MenuOverlay::onButton(const widget::ButtonEvent &e) {
void MenuOverlay::onButton(const event::Button &e) {
widget::OpaqueWidget::onButton(e);
if (e.getTarget() != this)
return;
@@ -27,7 +27,7 @@ void MenuOverlay::onButton(const widget::ButtonEvent &e) {
}
}

void MenuOverlay::onHoverKey(const widget::HoverKeyEvent &e) {
void MenuOverlay::onHoverKey(const event::HoverKey &e) {
widget::OpaqueWidget::onHoverKey(e);
if (e.getTarget() != this)
return;


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

@@ -20,20 +20,20 @@ void RadioButton::draw(const DrawArgs &args) {
bndRadioButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str());
}

void RadioButton::onEnter(const widget::EnterEvent &e) {
void RadioButton::onEnter(const event::Enter &e) {
state = BND_HOVER;
e.consume(this);
}

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

void RadioButton::onDragStart(const widget::DragStartEvent &e) {
void RadioButton::onDragStart(const event::DragStart &e) {
e.consume(this);
}

void RadioButton::onDragDrop(const widget::DragDropEvent &e) {
void RadioButton::onDragDrop(const event::DragDrop &e) {
if (e.origin == this) {
if (quantity) {
if (quantity->isMax())
@@ -42,7 +42,7 @@ void RadioButton::onDragDrop(const widget::DragDropEvent &e) {
quantity->setMax();
}

widget::ActionEvent eAction;
event::Action eAction;
onAction(eAction);
}
}


+ 3
- 3
src/ui/ScrollBar.cpp View File

@@ -16,13 +16,13 @@ void ScrollBar::draw(const DrawArgs &args) {
bndScrollBar(args.vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size);
}

void ScrollBar::onDragStart(const widget::DragStartEvent &e) {
void ScrollBar::onDragStart(const event::DragStart &e) {
state = BND_ACTIVE;
APP->window->cursorLock();
e.consume(this);
}

void ScrollBar::onDragMove(const widget::DragMoveEvent &e) {
void ScrollBar::onDragMove(const event::DragMove &e) {
const float sensitivity = 1.f;

ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent);
@@ -33,7 +33,7 @@ void ScrollBar::onDragMove(const widget::DragMoveEvent &e) {
scrollWidget->offset.y += sensitivity * e.mouseDelta.y;
}

void ScrollBar::onDragEnd(const widget::DragEndEvent &e) {
void ScrollBar::onDragEnd(const event::DragEnd &e) {
state = BND_DEFAULT;
APP->window->cursorUnlock();
}


+ 2
- 3
src/ui/ScrollWidget.cpp View File

@@ -1,6 +1,5 @@
#include "ui/ScrollWidget.hpp"
#include "app.hpp"
#include "widget/event.hpp"


namespace rack {
@@ -64,11 +63,11 @@ void ScrollWidget::step() {
verticalScrollBar->box.size.y = horizontalScrollBar->visible ? inner.y : box.size.y;
}

void ScrollWidget::onHover(const widget::HoverEvent &e) {
void ScrollWidget::onHover(const event::Hover &e) {
widget::Widget::onHover(e);
}

void ScrollWidget::onHoverScroll(const widget::HoverScrollEvent &e) {
void ScrollWidget::onHoverScroll(const event::HoverScroll &e) {
widget::Widget::onHoverScroll(e);
if (e.getTarget() != this)
return;


+ 4
- 4
src/ui/Slider.cpp View File

@@ -18,24 +18,24 @@ void Slider::draw(const DrawArgs &args) {
bndSlider(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, text.c_str(), NULL);
}

void Slider::onDragStart(const widget::DragStartEvent &e) {
void Slider::onDragStart(const event::DragStart &e) {
state = BND_ACTIVE;
APP->window->cursorLock();
e.consume(this);
}

void Slider::onDragMove(const widget::DragMoveEvent &e) {
void Slider::onDragMove(const event::DragMove &e) {
if (quantity) {
quantity->moveScaledValue(SENSITIVITY * e.mouseDelta.x);
}
}

void Slider::onDragEnd(const widget::DragEndEvent &e) {
void Slider::onDragEnd(const event::DragEnd &e) {
state = BND_DEFAULT;
APP->window->cursorUnlock();
}

void Slider::onDoubleClick(const widget::DoubleClickEvent &e) {
void Slider::onDoubleClick(const event::DoubleClick &e) {
if (quantity)
quantity->reset();
}


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

@@ -30,7 +30,7 @@ void TextField::draw(const DrawArgs &args) {
nvgResetScissor(args.vg);
}

void TextField::onHover(const widget::HoverEvent &e) {
void TextField::onHover(const event::Hover &e) {
widget::OpaqueWidget::onHover(e);

if (this == APP->event->draggedWidget) {
@@ -41,7 +41,7 @@ void TextField::onHover(const widget::HoverEvent &e) {
}
}

void TextField::onButton(const widget::ButtonEvent &e) {
void TextField::onButton(const event::Button &e) {
widget::OpaqueWidget::onButton(e);

if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) {
@@ -49,15 +49,15 @@ void TextField::onButton(const widget::ButtonEvent &e) {
}
}

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

void TextField::onSelect(const widget::SelectEvent &e) {
void TextField::onSelect(const event::Select &e) {
e.consume(this);
}

void TextField::onSelectText(const widget::SelectTextEvent &e) {
void TextField::onSelectText(const event::SelectText &e) {
if (e.codepoint < 128) {
std::string newText(1, (char) e.codepoint);
insertText(newText);
@@ -65,7 +65,7 @@ void TextField::onSelectText(const widget::SelectTextEvent &e) {
e.consume(this);
}

void TextField::onSelectKey(const widget::SelectKeyEvent &e) {
void TextField::onSelectKey(const event::SelectKey &e) {
if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) {
switch (e.key) {
case GLFW_KEY_BACKSPACE: {
@@ -73,7 +73,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) {
cursor--;
if (cursor >= 0) {
text.erase(cursor, 1);
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
}
selection = cursor;
@@ -81,7 +81,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) {
else {
int begin = std::min(cursor, selection);
text.erase(begin, std::abs(selection - cursor));
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
cursor = selection = begin;
}
@@ -89,13 +89,13 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) {
case GLFW_KEY_DELETE: {
if (cursor == selection) {
text.erase(cursor, 1);
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
}
else {
int begin = std::min(cursor, selection);
text.erase(begin, std::abs(selection - cursor));
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
cursor = selection = begin;
}
@@ -170,7 +170,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) {
insertText("\n");
}
else {
widget::ActionEvent eAction;
event::Action eAction;
onAction(eAction);
}
} break;
@@ -191,7 +191,7 @@ void TextField::insertText(std::string text) {
this->text.insert(cursor, text);
cursor += text.size();
selection = cursor;
widget::ChangeEvent eChange;
event::Change eChange;
onChange(eChange);
}

@@ -200,8 +200,8 @@ void TextField::setText(std::string text) {
this->text = text;
selection = cursor = text.size();
if (changed) {
// widget::ChangeEvent
widget::ChangeEvent eChange;
// event::Change
event::Change eChange;
onChange(eChange);
}
}


+ 16
- 17
src/widget/Widget.cpp View File

@@ -1,5 +1,4 @@
#include "widget/Widget.hpp"
#include "widget/event.hpp"
#include "app.hpp"
#include <algorithm>

@@ -16,15 +15,15 @@ Widget::~Widget() {

void Widget::setPos(math::Vec pos) {
box.pos = pos;
// RepositionEvent
RepositionEvent eReposition;
// event::Reposition
event::Reposition eReposition;
onReposition(eReposition);
}

void Widget::setSize(math::Vec size) {
box.size = size;
// ResizeEvent
ResizeEvent eResize;
// event::Resize
event::Resize eResize;
onResize(eResize);
}

@@ -32,8 +31,8 @@ void Widget::show() {
if (visible)
return;
visible = true;
// ShowEvent
ShowEvent eShow;
// event::Show
event::Show eShow;
onShow(eShow);
}

@@ -41,8 +40,8 @@ void Widget::hide() {
if (!visible)
return;
visible = false;
// HideEvent
HideEvent eHide;
// event::Hide
event::Hide eHide;
onHide(eHide);
}

@@ -90,8 +89,8 @@ void Widget::addChild(Widget *child) {
assert(!child->parent);
child->parent = this;
children.push_back(child);
// AddEvent
AddEvent eAdd;
// event::Add
event::Add eAdd;
child->onAdd(eAdd);
}

@@ -99,8 +98,8 @@ void Widget::removeChild(Widget *child) {
assert(child);
// Make sure `this` is the child's parent
assert(child->parent == this);
// RemoveEvent
RemoveEvent eRemove;
// event::Remove
event::Remove eRemove;
child->onRemove(eRemove);
// Prepare to remove widget from the event state
APP->event->finalizeWidget(child);
@@ -114,8 +113,8 @@ void Widget::removeChild(Widget *child) {

void Widget::clearChildren() {
for (Widget *child : children) {
// RemoveEvent
RemoveEvent eRemove;
// event::Remove
event::Remove eRemove;
child->onRemove(eRemove);
APP->event->finalizeWidget(child);
child->parent = NULL;
@@ -129,8 +128,8 @@ void Widget::step() {
Widget *child = *it;
// Delete children if a delete is requested
if (child->requestedDelete) {
// RemoveEvent
RemoveEvent eRemove;
// event::Remove
event::Remove eRemove;
child->onRemove(eRemove);
APP->event->finalizeWidget(child);
it = children.erase(it);


+ 2
- 2
src/widget/ZoomWidget.cpp View File

@@ -23,8 +23,8 @@ void ZoomWidget::setZoom(float zoom) {
return;
this->zoom = zoom;

EventContext cZoom;
ZoomEvent eZoom;
event::Context cZoom;
event::Zoom eZoom;
eZoom.context = &cZoom;
Widget::onZoom(eZoom);
}


+ 1
- 1
src/window.cpp View File

@@ -3,7 +3,7 @@
#include "app/Scene.hpp"
#include "keyboard.hpp"
#include "gamepad.hpp"
#include "widget/event.hpp"
#include "event.hpp"
#include "app.hpp"
#include "patch.hpp"
#include "settings.hpp"


Loading…
Cancel
Save