@@ -23,9 +23,9 @@ struct Window; | |||||
struct PatchManager; | struct PatchManager; | ||||
namespace widget { | |||||
struct EventState; | |||||
}; | |||||
namespace event { | |||||
struct State; | |||||
} // namespace event | |||||
namespace app { | namespace app { | ||||
@@ -35,7 +35,7 @@ namespace app { | |||||
/** Contains the application state */ | /** Contains the application state */ | ||||
struct App { | struct App { | ||||
widget::EventState *event = NULL; | |||||
event::State *event = NULL; | |||||
app::Scene *scene = NULL; | app::Scene *scene = NULL; | ||||
engine::Engine *engine = NULL; | engine::Engine *engine = NULL; | ||||
Window *window = NULL; | Window *window = NULL; | ||||
@@ -20,11 +20,11 @@ struct Knob : ParamWidget { | |||||
/** Drag horizontally instead of vertically */ | /** Drag horizontally instead of vertically */ | ||||
bool horizontal = false; | 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 reset() override; | ||||
void randomize() override; | void randomize() override; | ||||
}; | }; | ||||
@@ -26,7 +26,7 @@ struct LedDisplayChoice : widget::TransparentWidget { | |||||
NVGcolor bgColor; | NVGcolor bgColor; | ||||
LedDisplayChoice(); | LedDisplayChoice(); | ||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
void onButton(const widget::ButtonEvent &e) override; | |||||
void onButton(const event::Button &e) override; | |||||
}; | }; | ||||
struct LedDisplayTextField : ui::TextField { | struct LedDisplayTextField : ui::TextField { | ||||
@@ -37,12 +37,12 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
void drawShadow(const DrawArgs &args); | 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 | /** Associates this ModuleWidget with the Module | ||||
Transfers ownership | Transfers ownership | ||||
@@ -19,10 +19,10 @@ struct ParamWidget : widget::OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) 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 */ | /** For legacy patch loading */ | ||||
void fromJson(json_t *rootJ); | void fromJson(json_t *rootJ); | ||||
@@ -28,14 +28,14 @@ struct PortWidget : widget::OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) 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; | |||||
}; | }; | ||||
@@ -18,8 +18,8 @@ struct RackScrollWidget : ui::ScrollWidget { | |||||
RackScrollWidget(); | RackScrollWidget(); | ||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) 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(); | void reset(); | ||||
}; | }; | ||||
@@ -28,11 +28,11 @@ struct RackWidget : widget::OpaqueWidget { | |||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) 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 */ | /** Completely clear the rack's modules and cables */ | ||||
void clear(); | void clear(); | ||||
@@ -28,8 +28,8 @@ struct Scene : widget::OpaqueWidget { | |||||
~Scene(); | ~Scene(); | ||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) 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(); | void runCheckVersion(); | ||||
}; | }; | ||||
@@ -9,10 +9,10 @@ namespace app { | |||||
struct SliderKnob : Knob { | struct SliderKnob : Knob { | ||||
// Bypass Knob's circular hitbox detection | // Bypass Knob's circular hitbox detection | ||||
void onHover(const widget::HoverEvent &e) override { | |||||
void onHover(const event::Hover &e) override { | |||||
ParamWidget::onHover(e); | ParamWidget::onHover(e); | ||||
} | } | ||||
void onButton(const widget::ButtonEvent &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
ParamWidget::onButton(e); | ParamWidget::onButton(e); | ||||
} | } | ||||
}; | }; | ||||
@@ -18,9 +18,9 @@ struct SvgButton : widget::OpaqueWidget { | |||||
SvgButton(); | SvgButton(); | ||||
void addFrame(std::shared_ptr<Svg> svg); | 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; | |||||
}; | }; | ||||
@@ -23,7 +23,7 @@ struct SvgKnob : Knob { | |||||
SvgKnob(); | SvgKnob(); | ||||
void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(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; | |||||
}; | }; | ||||
@@ -22,7 +22,7 @@ struct SvgSlider : app::SliderKnob { | |||||
SvgSlider(); | SvgSlider(); | ||||
void setBackgroundSvg(std::shared_ptr<Svg> svg); | void setBackgroundSvg(std::shared_ptr<Svg> svg); | ||||
void setHandleSvg(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 setBackgroundSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | ||||
DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | ||||
@@ -20,7 +20,7 @@ struct SvgSwitch : Switch { | |||||
SvgSwitch(); | SvgSwitch(); | ||||
/** Adds an SVG file to represent the next switch position */ | /** Adds an SVG file to represent the next switch position */ | ||||
void addFrame(std::shared_ptr<Svg> svg); | void addFrame(std::shared_ptr<Svg> svg); | ||||
void onChange(const widget::ChangeEvent &e) override; | |||||
void onChange(const event::Change &e) override; | |||||
}; | }; | ||||
@@ -16,9 +16,9 @@ struct Switch : ParamWidget { | |||||
bool momentaryReleased = false; | bool momentaryReleased = false; | ||||
void step() override; | 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 reset() override; | ||||
void randomize() override; | void randomize() override; | ||||
}; | }; | ||||
@@ -5,24 +5,28 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace widget { | namespace widget { | ||||
struct Widget; | |||||
} | |||||
struct Widget; | |||||
namespace event { | |||||
/** A per-event state shared and writable by all widgets that recursively handle an 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; | bool propagating = true; | ||||
}; | }; | ||||
/** Base class for all events. */ | /** 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 { | void stopPropagating() const { | ||||
if (context) | if (context) | ||||
@@ -36,32 +40,32 @@ struct Event { | |||||
/** Tells the event handler that a particular Widget consumed the event. | /** Tells the event handler that a particular Widget consumed the event. | ||||
You usually want to stop propagation as well, so call consume() instead. | 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) | if (context) | ||||
context->target = w; | context->target = w; | ||||
} | } | ||||
Widget *getTarget() const { | |||||
widget::Widget *getTarget() const { | |||||
if (context) | if (context) | ||||
return context->target; | return context->target; | ||||
return NULL; | return NULL; | ||||
} | } | ||||
/** Sets the target Widget and stops propagation. */ | /** Sets the target Widget and stops propagation. */ | ||||
void consume(Widget *w) const { | |||||
void consume(widget::Widget *w) const { | |||||
setTarget(w); | setTarget(w); | ||||
stopPropagating(); | 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. */ | /** The pixel coordinate where the event occurred, relative to the Widget it is called on. */ | ||||
math::Vec pos; | math::Vec pos; | ||||
}; | }; | ||||
/** An Event prototype with a GLFW key. */ | |||||
struct KeyEvent { | |||||
/** An event prototype with a GLFW key. */ | |||||
struct KeyBase { | |||||
/** GLFW_KEY_* */ | /** GLFW_KEY_* */ | ||||
int key; | int key; | ||||
/** GLFW_KEY_*. You should usually use `key` instead. */ | /** 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 */ | /** Unicode code point of the character */ | ||||
int codepoint; | int codepoint; | ||||
}; | }; | ||||
// Concrete events | |||||
/** Occurs every frame when the mouse is hovering over a Widget. | /** Occurs every frame when the mouse is hovering over a Widget. | ||||
Recurses until consumed. | Recurses until consumed. | ||||
If `target` is set, other events may occur on that Widget. | 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. */ | /** Change in mouse position since the last frame. Can be zero. */ | ||||
math::Vec mouseDelta; | math::Vec mouseDelta; | ||||
}; | }; | ||||
@@ -97,7 +98,7 @@ struct HoverEvent : Event, PositionEvent { | |||||
Recurses until consumed. | Recurses until consumed. | ||||
If `target` is set, other events may occur on that Widget. | 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. */ | /** GLFW_MOUSE_BUTTON_LEFT, GLFW_MOUSE_BUTTON_RIGHT, GLFW_MOUSE_BUTTON_MIDDLE, etc. */ | ||||
int button; | int button; | ||||
/** GLFW_PRESS or GLFW_RELEASE */ | /** 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. | /** 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. | /** Occurs when a key is pressed, released, or repeated while the mouse is hovering a Widget. | ||||
Recurses until consumed. | 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. | /** Occurs when a character is typed while the mouse is hovering a Widget. | ||||
Recurses until consumed. | 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. | /** Occurs when the mouse scroll wheel is moved while the mouse is hovering a Widget. | ||||
Recurses until consumed. | Recurses until consumed. | ||||
*/ | */ | ||||
struct HoverScrollEvent : Event, PositionEvent { | |||||
struct HoverScroll : Base, PositionBase { | |||||
/** Change of scroll wheel position. */ | /** Change of scroll wheel position. */ | ||||
math::Vec scrollDelta; | math::Vec scrollDelta; | ||||
}; | }; | ||||
@@ -139,59 +140,59 @@ struct HoverScrollEvent : Event, PositionEvent { | |||||
/** Occurs when a Widget begins consuming the Hover event. | /** Occurs when a Widget begins consuming the Hover event. | ||||
Must consume to set the widget as hovered. | Must consume to set the widget as hovered. | ||||
*/ | */ | ||||
struct EnterEvent : Event { | |||||
struct Enter : Base { | |||||
}; | }; | ||||
/** Occurs when a different Widget is entered. | /** Occurs when a different Widget is entered. | ||||
*/ | */ | ||||
struct LeaveEvent : Event { | |||||
struct Leave : Base { | |||||
}; | }; | ||||
/** Occurs when a Widget begins consuming the Button press event. | /** Occurs when a Widget begins consuming the Button press event. | ||||
Must consume to set the widget as selected. | Must consume to set the widget as selected. | ||||
*/ | */ | ||||
struct SelectEvent : Event { | |||||
struct Select : Base { | |||||
}; | }; | ||||
/** Occurs when a different Widget is selected. | /** 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. | /** Occurs when a key is pressed, released, or repeated while a Widget is selected. | ||||
If consumed, a HoverKey event will not be triggered. | 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. | /** Occurs when text is typed while a Widget is selected. | ||||
If consumed, a HoverText event will not be triggered. | If consumed, a HoverText event will not be triggered. | ||||
*/ | */ | ||||
struct SelectTextEvent : Event, TextEvent { | |||||
struct SelectText : Base, TextBase { | |||||
}; | }; | ||||
/** Occurs when a Widget begins being dragged. | /** Occurs when a Widget begins being dragged. | ||||
Must consume to set the widget as 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. | /** 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. | /** Occurs every frame on the dragged Widget. | ||||
*/ | */ | ||||
struct DragMoveEvent : Event { | |||||
struct DragMove : Base { | |||||
/** Change in mouse position since the last frame. Can be zero. */ | /** Change in mouse position since the last frame. Can be zero. */ | ||||
math::Vec mouseDelta; | 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. | /** Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same one) is being dragged. | ||||
Recurses until consumed. | Recurses until consumed. | ||||
*/ | */ | ||||
struct DragHoverEvent : Event, PositionEvent { | |||||
struct DragHover : Base, PositionBase { | |||||
/** The dragged widget */ | /** The dragged widget */ | ||||
Widget *origin = NULL; | |||||
widget::Widget *origin = NULL; | |||||
/** Change in mouse position since the last frame. Can be zero. */ | /** Change in mouse position since the last frame. Can be zero. */ | ||||
math::Vec mouseDelta; | math::Vec mouseDelta; | ||||
}; | }; | ||||
@@ -210,33 +211,33 @@ struct DragHoverEvent : Event, PositionEvent { | |||||
/** Occurs when the mouse enters a Widget while dragging. | /** Occurs when the mouse enters a Widget while dragging. | ||||
Must consume to set the widget as drag-hovered. | Must consume to set the widget as drag-hovered. | ||||
*/ | */ | ||||
struct DragEnterEvent : Event { | |||||
struct DragEnter : Base { | |||||
/** The dragged widget */ | /** The dragged widget */ | ||||
Widget *origin = NULL; | |||||
widget::Widget *origin = NULL; | |||||
}; | }; | ||||
/** Occurs when the mouse leaves a Widget while dragging. | /** Occurs when the mouse leaves a Widget while dragging. | ||||
*/ | */ | ||||
struct DragLeaveEvent : Event { | |||||
struct DragLeave : Base { | |||||
/** The dragged widget */ | /** The dragged widget */ | ||||
Widget *origin = NULL; | |||||
widget::Widget *origin = NULL; | |||||
}; | }; | ||||
/** Occurs when the mouse button is released over a Widget while dragging. | /** Occurs when the mouse button is released over a Widget while dragging. | ||||
*/ | */ | ||||
struct DragDropEvent : Event { | |||||
struct DragDrop : Base { | |||||
/** The dragged widget */ | /** 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. | /** Occurs when a selection of files from the operating system is dropped onto a Widget. | ||||
Recurses until consumed. | 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 */ | /** List of file paths in the dropped selection */ | ||||
const std::vector<std::string> &paths; | const std::vector<std::string> &paths; | ||||
@@ -246,79 +247,79 @@ struct PathDropEvent : Event, PositionEvent { | |||||
/** Occurs after a certain action is triggered on a Widget. | /** Occurs after a certain action is triggered on a Widget. | ||||
The concept of an "action" is dependent on the type of 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. | /** Occurs after the value of a Widget changes. | ||||
The concept of a "value" is dependent on the type of Widget. | 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. | /** Occurs after the zoom level of a Widget is changed. | ||||
Recurses until consumed. | Recurses until consumed. | ||||
*/ | */ | ||||
struct ZoomEvent : Event { | |||||
struct Zoom : Base { | |||||
}; | }; | ||||
/** Occurs after a Widget's position is set by Widget::setPos(). | /** 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(). | /** 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. | /** Occurs after a Widget is added to a parent. | ||||
*/ | */ | ||||
struct AddEvent : Event { | |||||
struct Add : Base { | |||||
}; | }; | ||||
/** Occurs before a Widget is removed from its parent. | /** Occurs before a Widget is removed from its parent. | ||||
*/ | */ | ||||
struct RemoveEvent : Event { | |||||
struct Remove : Base { | |||||
}; | }; | ||||
/** Occurs after a Widget is shown with Widget::show(). | /** Occurs after a Widget is shown with Widget::show(). | ||||
*/ | */ | ||||
struct ShowEvent : Event { | |||||
struct Show : Base { | |||||
}; | }; | ||||
/** Occurs after a Widget is hidden with Widget::hide(). | /** 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 | /** State widgets | ||||
Don't set these directly unless you know what you're doing. Use the set*() methods instead. | 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 */ | /** For double-clicking */ | ||||
double lastClickTime = -INFINITY; | 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 */ | /** 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 handleButton(math::Vec pos, int button, int action, int mods); | ||||
void handleHover(math::Vec pos, math::Vec mouseDelta); | void handleHover(math::Vec pos, math::Vec mouseDelta); | ||||
@@ -331,5 +332,5 @@ struct EventState { | |||||
}; | }; | ||||
} // namespace widget | |||||
} // namespace event | |||||
} // namespace rack | } // namespace rack |
@@ -16,11 +16,11 @@ struct Button : widget::OpaqueWidget { | |||||
Button(); | Button(); | ||||
void draw(const DrawArgs &args) override; | 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; | |||||
}; | }; | ||||
@@ -19,7 +19,7 @@ struct Menu : widget::OpaqueWidget { | |||||
void setChildMenu(Menu *menu); | void setChildMenu(Menu *menu); | ||||
void step() override; | void step() override; | ||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
void onHoverScroll(const widget::HoverScrollEvent &e) override; | |||||
void onHoverScroll(const event::HoverScroll &e) override; | |||||
}; | }; | ||||
@@ -16,9 +16,9 @@ struct MenuItem : MenuEntry { | |||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
void step() 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(); | void doAction(); | ||||
virtual Menu *createChildMenu() {return NULL;} | virtual Menu *createChildMenu() {return NULL;} | ||||
}; | }; | ||||
@@ -10,8 +10,8 @@ namespace ui { | |||||
/** Deletes itself from parent when clicked */ | /** Deletes itself from parent when clicked */ | ||||
struct MenuOverlay : widget::OpaqueWidget { | struct MenuOverlay : widget::OpaqueWidget { | ||||
void step() override; | 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; | |||||
}; | }; | ||||
@@ -15,10 +15,10 @@ struct RadioButton : widget::OpaqueWidget { | |||||
RadioButton(); | RadioButton(); | ||||
void draw(const DrawArgs &args) override; | 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; | |||||
}; | }; | ||||
@@ -20,9 +20,9 @@ struct ScrollBar : widget::OpaqueWidget { | |||||
ScrollBar(); | ScrollBar(); | ||||
void draw(const DrawArgs &args) override; | 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; | |||||
}; | }; | ||||
@@ -19,8 +19,8 @@ struct ScrollWidget : widget::Widget { | |||||
void scrollTo(math::Rect r); | void scrollTo(math::Rect r); | ||||
void draw(const DrawArgs &args) override; | void draw(const DrawArgs &args) override; | ||||
void step() 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; | |||||
}; | }; | ||||
@@ -16,10 +16,10 @@ struct Slider : widget::OpaqueWidget { | |||||
Slider(); | Slider(); | ||||
void draw(const DrawArgs &args) override; | 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; | |||||
}; | }; | ||||
@@ -1,7 +1,6 @@ | |||||
#pragma once | #pragma once | ||||
#include "widget/OpaqueWidget.hpp" | #include "widget/OpaqueWidget.hpp" | ||||
#include "ui/common.hpp" | #include "ui/common.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
@@ -22,12 +21,12 @@ struct TextField : widget::OpaqueWidget { | |||||
TextField(); | TextField(); | ||||
void draw(const DrawArgs &args) override; | 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 */ | /** Inserts text at the cursor, replacing the selection if necessary */ | ||||
void insertText(std::string text); | void insertText(std::string text); | ||||
@@ -10,37 +10,37 @@ namespace widget { | |||||
Remember to call these methods in your subclass if you wish to preserve default OpaqueWidget behavior. | Remember to call these methods in your subclass if you wish to preserve default OpaqueWidget behavior. | ||||
*/ | */ | ||||
struct OpaqueWidget : Widget { | struct OpaqueWidget : Widget { | ||||
void onHover(const HoverEvent &e) override { | |||||
void onHover(const event::Hover &e) override { | |||||
Widget::onHover(e); | Widget::onHover(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
// Consume if not consumed by child | // Consume if not consumed by child | ||||
if (!e.getTarget()) | if (!e.getTarget()) | ||||
e.setTarget(this); | e.setTarget(this); | ||||
} | } | ||||
void onButton(const ButtonEvent &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
Widget::onButton(e); | Widget::onButton(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
// Consume if not consumed by child | // Consume if not consumed by child | ||||
if (!e.getTarget()) | if (!e.getTarget()) | ||||
e.setTarget(this); | e.setTarget(this); | ||||
} | } | ||||
void onHoverKey(const HoverKeyEvent &e) override { | |||||
void onHoverKey(const event::HoverKey &e) override { | |||||
Widget::onHoverKey(e); | Widget::onHoverKey(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
} | } | ||||
void onHoverText(const HoverTextEvent &e) override { | |||||
void onHoverText(const event::HoverText &e) override { | |||||
Widget::onHoverText(e); | Widget::onHoverText(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
} | } | ||||
void onHoverScroll(const HoverScrollEvent &e) override { | |||||
void onHoverScroll(const event::HoverScroll &e) override { | |||||
Widget::onHoverScroll(e); | Widget::onHoverScroll(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
} | } | ||||
void onDragHover(const DragHoverEvent &e) override { | |||||
void onDragHover(const event::DragHover &e) override { | |||||
Widget::onDragHover(e); | Widget::onDragHover(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
} | } | ||||
void onPathDrop(const PathDropEvent &e) override { | |||||
void onPathDrop(const event::PathDrop &e) override { | |||||
Widget::onPathDrop(e); | Widget::onPathDrop(e); | ||||
e.stopPropagating(); | e.stopPropagating(); | ||||
} | } | ||||
@@ -9,13 +9,13 @@ namespace widget { | |||||
/** A Widget that does not respond to events and does not pass events to children */ | /** A Widget that does not respond to events and does not pass events to children */ | ||||
struct TransparentWidget : Widget { | struct TransparentWidget : Widget { | ||||
/** Override behavior to do nothing instead. */ | /** 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 {} | |||||
}; | }; | ||||
@@ -3,7 +3,7 @@ | |||||
#include "math.hpp" | #include "math.hpp" | ||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "color.hpp" | #include "color.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "event.hpp" | |||||
#include <list> | #include <list> | ||||
@@ -138,35 +138,35 @@ struct Widget { | |||||
/** Override these event callbacks to respond to events. | /** Override these event callbacks to respond to events. | ||||
See events.hpp for a description of each event. | See events.hpp for a description of each event. | ||||
*/ | */ | ||||
virtual void onHover(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);} | |||||
}; | }; | ||||
@@ -15,38 +15,38 @@ struct ZoomWidget : Widget { | |||||
void setZoom(float zoom); | void setZoom(float zoom); | ||||
void draw(const DrawArgs &args) override; | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onHover(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onButton(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onHoverKey(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onHoverText(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onHoverScroll(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onDragHover(e2); | 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); | e2.pos = e.pos.div(zoom); | ||||
Widget::onPathDrop(e2); | Widget::onPathDrop(e2); | ||||
} | } | ||||
@@ -36,20 +36,20 @@ struct ModuleResizeHandle : OpaqueWidget { | |||||
box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT); | 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) { | if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
} | } | ||||
void onDragStart(const widget::DragStartEvent &e) override { | |||||
void onDragStart(const event::DragStart &e) override { | |||||
dragX = APP->scene->rack->mousePos.x; | dragX = APP->scene->rack->mousePos.x; | ||||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ||||
originalBox = m->box; | originalBox = m->box; | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onDragMove(const widget::DragMoveEvent &e) override { | |||||
void onDragMove(const event::DragMove &e) override { | |||||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | ||||
float newDragX = APP->scene->rack->mousePos.x; | float newDragX = APP->scene->rack->mousePos.x; | ||||
@@ -145,7 +145,7 @@ struct CV_Gate : Module { | |||||
struct CV_GateVelocityItem : MenuItem { | struct CV_GateVelocityItem : MenuItem { | ||||
CV_Gate *module; | CV_Gate *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | module->velocityMode ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -153,7 +153,7 @@ struct CV_GateVelocityItem : MenuItem { | |||||
struct CV_GatePanicItem : MenuItem { | struct CV_GatePanicItem : MenuItem { | ||||
CV_Gate *module; | CV_Gate *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->midiOutput.panic(); | module->midiOutput.panic(); | ||||
} | } | ||||
}; | }; | ||||
@@ -319,7 +319,7 @@ struct CV_MIDI : Module { | |||||
struct CV_MIDIPanicItem : MenuItem { | struct CV_MIDIPanicItem : MenuItem { | ||||
CV_MIDI *module; | CV_MIDI *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->midiOutput.panic(); | module->midiOutput.panic(); | ||||
} | } | ||||
}; | }; | ||||
@@ -419,7 +419,7 @@ struct MIDI_CV : Module { | |||||
struct ClockDivisionValueItem : MenuItem { | struct ClockDivisionValueItem : MenuItem { | ||||
MIDI_CV *module; | MIDI_CV *module; | ||||
int clockDivision; | int clockDivision; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->clockDivision = clockDivision; | module->clockDivision = clockDivision; | ||||
} | } | ||||
}; | }; | ||||
@@ -447,7 +447,7 @@ struct ClockDivisionItem : MenuItem { | |||||
struct ChannelValueItem : MenuItem { | struct ChannelValueItem : MenuItem { | ||||
MIDI_CV *module; | MIDI_CV *module; | ||||
int channels; | int channels; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->setChannels(channels); | module->setChannels(channels); | ||||
} | } | ||||
}; | }; | ||||
@@ -476,7 +476,7 @@ struct ChannelItem : MenuItem { | |||||
struct PolyModeValueItem : MenuItem { | struct PolyModeValueItem : MenuItem { | ||||
MIDI_CV *module; | MIDI_CV *module; | ||||
MIDI_CV::PolyMode polyMode; | MIDI_CV::PolyMode polyMode; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->setPolyMode(polyMode); | module->setPolyMode(polyMode); | ||||
} | } | ||||
}; | }; | ||||
@@ -508,7 +508,7 @@ struct PolyModeItem : MenuItem { | |||||
struct MIDI_CVPanicItem : MenuItem { | struct MIDI_CVPanicItem : MenuItem { | ||||
MIDI_CV *module; | MIDI_CV *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->panic(); | module->panic(); | ||||
} | } | ||||
}; | }; | ||||
@@ -151,7 +151,7 @@ struct MIDI_Gate : Module { | |||||
struct MIDI_GateVelocityItem : MenuItem { | struct MIDI_GateVelocityItem : MenuItem { | ||||
MIDI_Gate *module; | MIDI_Gate *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->velocityMode ^= true; | module->velocityMode ^= true; | ||||
} | } | ||||
}; | }; | ||||
@@ -159,7 +159,7 @@ struct MIDI_GateVelocityItem : MenuItem { | |||||
struct MIDI_GatePanicItem : MenuItem { | struct MIDI_GatePanicItem : MenuItem { | ||||
MIDI_Gate *module; | MIDI_Gate *module; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
module->panic(); | module->panic(); | ||||
} | } | ||||
}; | }; | ||||
@@ -246,7 +246,7 @@ struct MIDI_MapChoice : LedDisplayChoice { | |||||
this->module = module; | this->module = module; | ||||
} | } | ||||
void onButton(const widget::ButtonEvent &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
if (!module) | if (!module) | ||||
return; | 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) | if (!module) | ||||
return; | return; | ||||
@@ -273,7 +273,7 @@ struct MIDI_MapChoice : LedDisplayChoice { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onDeselect(const widget::DeselectEvent &e) override { | |||||
void onDeselect(const event::Deselect &e) override { | |||||
if (!module) | if (!module) | ||||
return; | return; | ||||
// Check if a ParamWidget was touched | // Check if a ParamWidget was touched | ||||
@@ -95,7 +95,7 @@ struct CcChoice : LedDisplayChoice { | |||||
} | } | ||||
} | } | ||||
void onSelect(const widget::SelectEvent &e) override { | |||||
void onSelect(const event::Select &e) override { | |||||
if (!module) | if (!module) | ||||
return; | return; | ||||
module->learningId = id; | module->learningId = id; | ||||
@@ -103,7 +103,7 @@ struct CcChoice : LedDisplayChoice { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onDeselect(const widget::DeselectEvent &e) override { | |||||
void onDeselect(const event::Deselect &e) override { | |||||
if (!module) | if (!module) | ||||
return; | return; | ||||
if (module->learningId == id) { | 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'; | int c = e.codepoint - '0'; | ||||
if (0 <= c && c <= 9) { | if (0 <= c && c <= 9) { | ||||
if (focusCc < 0) | if (focusCc < 0) | ||||
@@ -126,9 +126,9 @@ struct CcChoice : LedDisplayChoice { | |||||
e.consume(this); | 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) { | 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); | onDeselect(eDeselect); | ||||
APP->event->selectedWidget = NULL; | APP->event->selectedWidget = NULL; | ||||
e.consume(this); | 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) | if (!module) | ||||
return; | return; | ||||
module->learningId = id; | module->learningId = id; | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void onDeselect(const widget::DeselectEvent &e) override { | |||||
void onDeselect(const event::Deselect &e) override { | |||||
if (!module) | if (!module) | ||||
return; | return; | ||||
if (module->learningId == id) { | if (module->learningId == id) { | ||||
@@ -1,5 +1,4 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "patch.hpp" | #include "patch.hpp" | ||||
#include "engine/Engine.hpp" | #include "engine/Engine.hpp" | ||||
@@ -14,7 +13,7 @@ namespace rack { | |||||
void App::init() { | void App::init() { | ||||
engine = new engine::Engine; | engine = new engine::Engine; | ||||
if (!settings::headless) { | if (!settings::headless) { | ||||
event = new widget::EventState; | |||||
event = new event::State; | |||||
history = new history::State; | history = new history::State; | ||||
window = new Window; | window = new Window; | ||||
patch = new PatchManager; | patch = new PatchManager; | ||||
@@ -10,14 +10,14 @@ namespace app { | |||||
struct AudioDriverItem : ui::MenuItem { | struct AudioDriverItem : ui::MenuItem { | ||||
audio::Port *port; | audio::Port *port; | ||||
int driver; | int driver; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setDriver(driver); | port->setDriver(driver); | ||||
} | } | ||||
}; | }; | ||||
struct AudioDriverChoice : LedDisplayChoice { | struct AudioDriverChoice : LedDisplayChoice { | ||||
audio::Port *port; | audio::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -45,7 +45,7 @@ struct AudioDeviceItem : ui::MenuItem { | |||||
audio::Port *port; | audio::Port *port; | ||||
int device; | int device; | ||||
int offset; | int offset; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setDevice(device, offset); | port->setDevice(device, offset); | ||||
} | } | ||||
}; | }; | ||||
@@ -55,7 +55,7 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
/** Prevents devices with a ridiculous number of channels from being displayed */ | /** Prevents devices with a ridiculous number of channels from being displayed */ | ||||
int maxTotalChannels = 128; | int maxTotalChannels = 128; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -103,14 +103,14 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
struct AudioSampleRateItem : ui::MenuItem { | struct AudioSampleRateItem : ui::MenuItem { | ||||
audio::Port *port; | audio::Port *port; | ||||
int sampleRate; | int sampleRate; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setSampleRate(sampleRate); | port->setSampleRate(sampleRate); | ||||
} | } | ||||
}; | }; | ||||
struct AudioSampleRateChoice : LedDisplayChoice { | struct AudioSampleRateChoice : LedDisplayChoice { | ||||
audio::Port *port; | audio::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -141,14 +141,14 @@ struct AudioSampleRateChoice : LedDisplayChoice { | |||||
struct AudioBlockSizeItem : ui::MenuItem { | struct AudioBlockSizeItem : ui::MenuItem { | ||||
audio::Port *port; | audio::Port *port; | ||||
int blockSize; | int blockSize; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setBlockSize(blockSize); | port->setBlockSize(blockSize); | ||||
} | } | ||||
}; | }; | ||||
struct AudioBlockSizeChoice : LedDisplayChoice { | struct AudioBlockSizeChoice : LedDisplayChoice { | ||||
audio::Port *port; | audio::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -1,7 +1,6 @@ | |||||
#include "app/CableWidget.hpp" | #include "app/CableWidget.hpp" | ||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "patch.hpp" | #include "patch.hpp" | ||||
#include "settings.hpp" | #include "settings.hpp" | ||||
@@ -12,7 +12,7 @@ namespace app { | |||||
static const float KNOB_SENSITIVITY = 0.0015f; | 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); | math::Vec c = box.size.div(2); | ||||
float dist = e.pos.minus(c).norm(); | float dist = e.pos.minus(c).norm(); | ||||
if (dist <= c.x) { | 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); | math::Vec c = box.size.div(2); | ||||
float dist = e.pos.minus(c).norm(); | float dist = e.pos.minus(c).norm(); | ||||
if (dist <= c.x) { | 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) { | if (paramQuantity) { | ||||
oldValue = paramQuantity->getSmoothValue(); | oldValue = paramQuantity->getSmoothValue(); | ||||
if (snap) { | if (snap) { | ||||
@@ -40,7 +40,7 @@ void Knob::onDragStart(const widget::DragStartEvent &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void Knob::onDragEnd(const widget::DragEndEvent &e) { | |||||
void Knob::onDragEnd(const event::DragEnd &e) { | |||||
APP->window->cursorUnlock(); | APP->window->cursorUnlock(); | ||||
if (paramQuantity) { | 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) { | if (paramQuantity) { | ||||
float range; | float range; | ||||
if (paramQuantity->isBounded()) { | if (paramQuantity->isBounded()) { | ||||
@@ -1,7 +1,6 @@ | |||||
#include "app/LedDisplay.hpp" | #include "app/LedDisplay.hpp" | ||||
#include "asset.hpp" | #include "asset.hpp" | ||||
#include "window.hpp" | #include "window.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "app.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)) { | 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); | onAction(eAction); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
@@ -10,14 +10,14 @@ namespace app { | |||||
struct MidiDriverItem : ui::MenuItem { | struct MidiDriverItem : ui::MenuItem { | ||||
midi::Port *port; | midi::Port *port; | ||||
int driverId; | int driverId; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setDriverId(driverId); | port->setDriverId(driverId); | ||||
} | } | ||||
}; | }; | ||||
struct MidiDriverChoice : LedDisplayChoice { | struct MidiDriverChoice : LedDisplayChoice { | ||||
midi::Port *port; | midi::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -51,14 +51,14 @@ struct MidiDriverChoice : LedDisplayChoice { | |||||
struct MidiDeviceItem : ui::MenuItem { | struct MidiDeviceItem : ui::MenuItem { | ||||
midi::Port *port; | midi::Port *port; | ||||
int deviceId; | int deviceId; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->setDeviceId(deviceId); | port->setDeviceId(deviceId); | ||||
} | } | ||||
}; | }; | ||||
struct MidiDeviceChoice : LedDisplayChoice { | struct MidiDeviceChoice : LedDisplayChoice { | ||||
midi::Port *port; | midi::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -100,14 +100,14 @@ struct MidiDeviceChoice : LedDisplayChoice { | |||||
struct MidiChannelItem : ui::MenuItem { | struct MidiChannelItem : ui::MenuItem { | ||||
midi::Port *port; | midi::Port *port; | ||||
int channel; | int channel; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
port->channel = channel; | port->channel = channel; | ||||
} | } | ||||
}; | }; | ||||
struct MidiChannelChoice : LedDisplayChoice { | struct MidiChannelChoice : LedDisplayChoice { | ||||
midi::Port *port; | midi::Port *port; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
if (!port) | if (!port) | ||||
return; | return; | ||||
@@ -60,7 +60,7 @@ struct BrowserOverlay : widget::OpaqueWidget { | |||||
OpaqueWidget::step(); | OpaqueWidget::step(); | ||||
} | } | ||||
void onButton(const widget::ButtonEvent &e) override { | |||||
void onButton(const event::Button &e) override { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | return; | ||||
@@ -252,26 +252,26 @@ struct ModelBox : widget::OpaqueWidget { | |||||
OpaqueWidget::draw(args); | 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); | e.consume(this); | ||||
infoBox->show(); | infoBox->show(); | ||||
} | } | ||||
void onLeave(const widget::LeaveEvent &e) override { | |||||
void onLeave(const event::Leave &e) override { | |||||
infoBox->hide(); | infoBox->hide(); | ||||
} | } | ||||
}; | }; | ||||
struct AuthorItem : ui::MenuItem { | struct AuthorItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override; | |||||
void onAction(const event::Action &e) override; | |||||
}; | }; | ||||
struct TagItem : ui::MenuItem { | 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(); | TextField::step(); | ||||
} | } | ||||
void onSelectKey(const widget::SelectKeyEvent &e) override { | |||||
void onSelectKey(const event::SelectKey &e) override { | |||||
if (e.action == GLFW_PRESS) { | if (e.action == GLFW_PRESS) { | ||||
if (e.key == GLFW_KEY_ESCAPE) { | if (e.key == GLFW_KEY_ESCAPE) { | ||||
BrowserOverlay *overlay = getAncestorOfType<BrowserOverlay>(); | BrowserOverlay *overlay = getAncestorOfType<BrowserOverlay>(); | ||||
@@ -295,14 +295,14 @@ struct BrowserSearchField : ui::TextField { | |||||
ui::TextField::onSelectKey(e); | 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); | APP->event->setSelected(NULL); | ||||
ui::TextField::onHide(e); | ui::TextField::onHide(e); | ||||
} | } | ||||
void onShow(const widget::ShowEvent &e) override { | |||||
void onShow(const event::Show &e) override { | |||||
selectAll(); | selectAll(); | ||||
TextField::onShow(e); | TextField::onShow(e); | ||||
} | } | ||||
@@ -613,7 +613,7 @@ struct ModuleBrowser : widget::OpaqueWidget { | |||||
// Implementations to resolve dependencies | // Implementations to resolve dependencies | ||||
inline void ModelBox::onButton(const widget::ButtonEvent &e) { | |||||
inline void ModelBox::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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>(); | ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>(); | ||||
if (browser->author == text) | if (browser->author == text) | ||||
browser->author = ""; | 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>(); | ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>(); | ||||
if (browser->tag == text) | if (browser->tag == text) | ||||
browser->tag = ""; | 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>(); | ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>(); | ||||
browser->search = string::trim(text); | browser->search = string::trim(text); | ||||
browser->refresh(); | browser->refresh(); | ||||
@@ -23,7 +23,7 @@ static const char PRESET_FILTERS[] = "VCV Rack module preset (.vcvm):vcvm"; | |||||
struct ModuleUrlItem : ui::MenuItem { | struct ModuleUrlItem : ui::MenuItem { | ||||
std::string url; | std::string url; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t(system::openBrowser, url); | std::thread t(system::openBrowser, url); | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
@@ -32,7 +32,7 @@ struct ModuleUrlItem : ui::MenuItem { | |||||
struct ModuleFolderItem : ui::MenuItem { | struct ModuleFolderItem : ui::MenuItem { | ||||
std::string path; | std::string path; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t(system::openFolder, path); | std::thread t(system::openFolder, path); | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
@@ -108,7 +108,7 @@ struct ModulePluginItem : ui::MenuItem { | |||||
struct ModuleDisconnectItem : ui::MenuItem { | struct ModuleDisconnectItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->disconnectAction(); | moduleWidget->disconnectAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -116,7 +116,7 @@ struct ModuleDisconnectItem : ui::MenuItem { | |||||
struct ModuleResetItem : ui::MenuItem { | struct ModuleResetItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->resetAction(); | moduleWidget->resetAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -124,7 +124,7 @@ struct ModuleResetItem : ui::MenuItem { | |||||
struct ModuleRandomizeItem : ui::MenuItem { | struct ModuleRandomizeItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->randomizeAction(); | moduleWidget->randomizeAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -132,7 +132,7 @@ struct ModuleRandomizeItem : ui::MenuItem { | |||||
struct ModuleCopyItem : ui::MenuItem { | struct ModuleCopyItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->copyClipboard(); | moduleWidget->copyClipboard(); | ||||
} | } | ||||
}; | }; | ||||
@@ -140,7 +140,7 @@ struct ModuleCopyItem : ui::MenuItem { | |||||
struct ModulePasteItem : ui::MenuItem { | struct ModulePasteItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->pasteClipboardAction(); | moduleWidget->pasteClipboardAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -148,7 +148,7 @@ struct ModulePasteItem : ui::MenuItem { | |||||
struct ModuleSaveItem : ui::MenuItem { | struct ModuleSaveItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->saveDialog(); | moduleWidget->saveDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -156,7 +156,7 @@ struct ModuleSaveItem : ui::MenuItem { | |||||
struct ModuleLoadItem : ui::MenuItem { | struct ModuleLoadItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->loadDialog(); | moduleWidget->loadDialog(); | ||||
} | } | ||||
}; | }; | ||||
@@ -165,7 +165,7 @@ struct ModuleLoadItem : ui::MenuItem { | |||||
struct ModulePresetPathItem : ui::MenuItem { | struct ModulePresetPathItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
std::string presetPath; | std::string presetPath; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->loadAction(presetPath); | moduleWidget->loadAction(presetPath); | ||||
} | } | ||||
}; | }; | ||||
@@ -219,7 +219,7 @@ struct ModulePresetItem : ui::MenuItem { | |||||
struct ModuleCloneItem : ui::MenuItem { | struct ModuleCloneItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->cloneAction(); | moduleWidget->cloneAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -227,7 +227,7 @@ struct ModuleCloneItem : ui::MenuItem { | |||||
struct ModuleBypassItem : ui::MenuItem { | struct ModuleBypassItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->bypassAction(); | moduleWidget->bypassAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -235,7 +235,7 @@ struct ModuleBypassItem : ui::MenuItem { | |||||
struct ModuleDeleteItem : ui::MenuItem { | struct ModuleDeleteItem : ui::MenuItem { | ||||
ModuleWidget *moduleWidget; | ModuleWidget *moduleWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
moduleWidget->removeAction(); | moduleWidget->removeAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -304,7 +304,7 @@ void ModuleWidget::drawShadow(const DrawArgs &args) { | |||||
nvgFill(args.vg); | nvgFill(args.vg); | ||||
} | } | ||||
void ModuleWidget::onHover(const widget::HoverEvent &e) { | |||||
void ModuleWidget::onHover(const event::Hover &e) { | |||||
widget::OpaqueWidget::onHover(e); | widget::OpaqueWidget::onHover(e); | ||||
if (!APP->event->selectedWidget) { | 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); | widget::OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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); | widget::OpaqueWidget::onHoverKey(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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; | oldPos = box.pos; | ||||
dragPos = APP->scene->rack->mousePos.minus(box.pos); | dragPos = APP->scene->rack->mousePos.minus(box.pos); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void ModuleWidget::onDragEnd(const widget::DragEndEvent &e) { | |||||
void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||||
if (!box.pos.isEqual(oldPos)) { | if (!box.pos.isEqual(oldPos)) { | ||||
// history::ModuleMove | // history::ModuleMove | ||||
history::ModuleMove *h = new 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) { | if (!settings::lockModules) { | ||||
math::Rect newBox = box; | math::Rect newBox = box; | ||||
newBox.pos = APP->scene->rack->mousePos.minus(dragPos); | newBox.pos = APP->scene->rack->mousePos.minus(dragPos); | ||||
@@ -29,7 +29,7 @@ struct ParamField : ui::TextField { | |||||
selectAll(); | 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)) { | if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { | ||||
float oldValue = paramWidget->paramQuantity->getValue(); | float oldValue = paramWidget->paramQuantity->getValue(); | ||||
if (paramWidget->paramQuantity) | if (paramWidget->paramQuantity) | ||||
@@ -87,7 +87,7 @@ struct ParamLabel : ui::MenuLabel { | |||||
struct ParamResetItem : ui::MenuItem { | struct ParamResetItem : ui::MenuItem { | ||||
ParamWidget *paramWidget; | ParamWidget *paramWidget; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
paramWidget->resetAction(); | paramWidget->resetAction(); | ||||
} | } | ||||
}; | }; | ||||
@@ -99,7 +99,7 @@ struct ParamFineItem : ui::MenuItem { | |||||
struct ParamUnmapItem : ui::MenuItem { | struct ParamUnmapItem : ui::MenuItem { | ||||
ParamWidget *paramWidget; | 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); | engine::ParamHandle *paramHandle = APP->engine->getParamHandle(paramWidget->paramQuantity->module, paramWidget->paramQuantity->paramId); | ||||
if (paramHandle) { | if (paramHandle) { | ||||
APP->engine->updateParamHandle(paramHandle, -1, 0); | APP->engine->updateParamHandle(paramHandle, -1, 0); | ||||
@@ -114,7 +114,7 @@ void ParamWidget::step() { | |||||
// Trigger change event when paramQuantity value changes | // Trigger change event when paramQuantity value changes | ||||
if (value != dirtyValue) { | if (value != dirtyValue) { | ||||
dirtyValue = value; | dirtyValue = value; | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(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); | OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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(); | resetAction(); | ||||
} | } | ||||
void ParamWidget::onEnter(const widget::EnterEvent &e) { | |||||
void ParamWidget::onEnter(const event::Enter &e) { | |||||
if (settings::paramTooltip && !tooltip && paramQuantity) { | if (settings::paramTooltip && !tooltip && paramQuantity) { | ||||
ParamTooltip *paramTooltip = new ParamTooltip; | ParamTooltip *paramTooltip = new ParamTooltip; | ||||
paramTooltip->paramWidget = this; | 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) { | if (tooltip) { | ||||
APP->scene->removeChild(tooltip); | APP->scene->removeChild(tooltip); | ||||
delete tooltip; | delete tooltip; | ||||
@@ -59,7 +59,7 @@ void PortWidget::draw(const DrawArgs &args) { | |||||
Widget::draw(args); | Widget::draw(args); | ||||
} | } | ||||
void PortWidget::onButton(const widget::ButtonEvent &e) { | |||||
void PortWidget::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | 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; | hovered = true; | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void PortWidget::onLeave(const widget::LeaveEvent &e) { | |||||
void PortWidget::onLeave(const event::Leave &e) { | |||||
hovered = false; | hovered = false; | ||||
} | } | ||||
void PortWidget::onDragStart(const widget::DragStartEvent &e) { | |||||
void PortWidget::onDragStart(const event::DragStart &e) { | |||||
CableWidget *cw = NULL; | CableWidget *cw = NULL; | ||||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | ||||
if (type == OUTPUT) { | if (type == OUTPUT) { | ||||
@@ -131,7 +131,7 @@ void PortWidget::onDragStart(const widget::DragStartEvent &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void PortWidget::onDragEnd(const widget::DragEndEvent &e) { | |||||
void PortWidget::onDragEnd(const event::DragEnd &e) { | |||||
CableWidget *cw = APP->scene->rack->releaseIncompleteCable(); | CableWidget *cw = APP->scene->rack->releaseIncompleteCable(); | ||||
if (cw->isComplete()) { | if (cw->isComplete()) { | ||||
APP->scene->rack->addCable(cw); | 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 | // Reject ports if this is an input port and something is already plugged into it | ||||
if (type == INPUT) { | if (type == INPUT) { | ||||
if (APP->scene->rack->getTopCable(this)) | 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 | // Reject ports if this is an input port and something is already plugged into it | ||||
if (type == INPUT) { | if (type == INPUT) { | ||||
if (APP->scene->rack->getTopCable(this)) | if (APP->scene->rack->getTopCable(this)) | ||||
@@ -180,7 +180,7 @@ void PortWidget::onDragEnter(const widget::DragEnterEvent &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void PortWidget::onDragLeave(const widget::DragLeaveEvent &e) { | |||||
void PortWidget::onDragLeave(const event::DragLeave &e) { | |||||
PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | PortWidget *originPort = dynamic_cast<PortWidget*>(e.origin); | ||||
if (!originPort) | if (!originPort) | ||||
return; | return; | ||||
@@ -71,7 +71,7 @@ void RackScrollWidget::draw(const DrawArgs &args) { | |||||
ScrollWidget::draw(args); | ScrollWidget::draw(args); | ||||
} | } | ||||
void RackScrollWidget::onHover(const widget::HoverEvent &e) { | |||||
void RackScrollWidget::onHover(const event::Hover &e) { | |||||
if (!APP->event->selectedWidget) { | if (!APP->event->selectedWidget) { | ||||
// Scroll with arrow keys | // Scroll with arrow keys | ||||
float arrowSpeed = 30.0; | float arrowSpeed = 30.0; | ||||
@@ -95,7 +95,7 @@ void RackScrollWidget::onHover(const widget::HoverEvent &e) { | |||||
ScrollWidget::onHover(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) { | if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | ||||
// Increase zoom | // Increase zoom | ||||
float zoomDelta = e.scrollDelta.y / 50 / 4; | float zoomDelta = e.scrollDelta.y / 50 / 4; | ||||
@@ -116,12 +116,12 @@ void RackWidget::draw(const DrawArgs &args) { | |||||
OpaqueWidget::draw(args); | OpaqueWidget::draw(args); | ||||
} | } | ||||
void RackWidget::onHover(const widget::HoverEvent &e) { | |||||
void RackWidget::onHover(const event::Hover &e) { | |||||
mousePos = e.pos; | mousePos = e.pos; | ||||
OpaqueWidget::onHover(e); | OpaqueWidget::onHover(e); | ||||
} | } | ||||
void RackWidget::onHoverKey(const widget::HoverKeyEvent &e) { | |||||
void RackWidget::onHoverKey(const event::HoverKey &e) { | |||||
OpaqueWidget::onHoverKey(e); | OpaqueWidget::onHoverKey(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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); | OpaqueWidget::onDragHover(e); | ||||
mousePos = e.pos; | mousePos = e.pos; | ||||
} | } | ||||
void RackWidget::onButton(const widget::ButtonEvent &e) { | |||||
void RackWidget::onButton(const event::Button &e) { | |||||
OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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); | OpaqueWidget::onZoom(e); | ||||
} | } | ||||
@@ -71,7 +71,7 @@ void Scene::draw(const DrawArgs &args) { | |||||
OpaqueWidget::draw(args); | OpaqueWidget::draw(args); | ||||
} | } | ||||
void Scene::onHoverKey(const widget::HoverKeyEvent &e) { | |||||
void Scene::onHoverKey(const event::HoverKey &e) { | |||||
OpaqueWidget::onHoverKey(e); | OpaqueWidget::onHoverKey(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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); | OpaqueWidget::onPathDrop(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | return; | ||||
@@ -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) { | if (frames.size() >= 2) { | ||||
sw->setSvg(frames[1]); | sw->setSvg(frames[1]); | ||||
fb->dirty = true; | fb->dirty = true; | ||||
@@ -38,16 +38,16 @@ void SvgButton::onDragStart(const widget::DragStartEvent &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void SvgButton::onDragEnd(const widget::DragEndEvent &e) { | |||||
void SvgButton::onDragEnd(const event::DragEnd &e) { | |||||
if (frames.size() >= 1) { | if (frames.size() >= 1) { | ||||
sw->setSvg(frames[0]); | sw->setSvg(frames[0]); | ||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
} | } | ||||
void SvgButton::onDragDrop(const widget::DragDropEvent &e) { | |||||
void SvgButton::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
widget::ActionEvent eAction; | |||||
event::Action eAction; | |||||
onAction(eAction); | onAction(eAction); | ||||
} | } | ||||
} | } | ||||
@@ -31,7 +31,7 @@ void SvgKnob::setSvg(std::shared_ptr<Svg> svg) { | |||||
// shadow->box = shadow->box.grow(math::Vec(2, 2)); | // 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 | // Re-transform the widget::TransformWidget | ||||
if (paramQuantity) { | if (paramQuantity) { | ||||
float angle; | float angle; | ||||
@@ -30,7 +30,7 @@ void SvgSlider::setHandleSvg(std::shared_ptr<Svg> svg) { | |||||
fb->dirty = true; | fb->dirty = true; | ||||
} | } | ||||
void SvgSlider::onChange(const widget::ChangeEvent &e) { | |||||
void SvgSlider::onChange(const event::Change &e) { | |||||
if (paramQuantity) { | if (paramQuantity) { | ||||
// Interpolate handle position | // Interpolate handle position | ||||
float v = paramQuantity->getScaledValue(); | float v = paramQuantity->getScaledValue(); | ||||
@@ -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) { | if (!frames.empty() && paramQuantity) { | ||||
int index = (int) std::round(paramQuantity->getValue()); | int index = (int) std::round(paramQuantity->getValue()); | ||||
index = math::clamp(index, 0, (int) frames.size() - 1); | index = math::clamp(index, 0, (int) frames.size() - 1); | ||||
@@ -24,11 +24,11 @@ void Switch::step() { | |||||
ParamWidget::step(); | ParamWidget::step(); | ||||
} | } | ||||
void Switch::onDoubleClick(const widget::DoubleClickEvent &e) { | |||||
void Switch::onDoubleClick(const event::DoubleClick &e) { | |||||
// Don't reset parameter on double-click | // Don't reset parameter on double-click | ||||
} | } | ||||
void Switch::onDragStart(const widget::DragStartEvent &e) { | |||||
void Switch::onDragStart(const event::DragStart &e) { | |||||
if (momentary) { | if (momentary) { | ||||
if (paramQuantity) { | if (paramQuantity) { | ||||
// Set to maximum value | // Set to maximum value | ||||
@@ -64,7 +64,7 @@ void Switch::onDragStart(const widget::DragStartEvent &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void Switch::onDragEnd(const widget::DragEndEvent &e) { | |||||
void Switch::onDragEnd(const event::DragEnd &e) { | |||||
if (momentary) { | if (momentary) { | ||||
momentaryReleased = true; | momentaryReleased = true; | ||||
} | } | ||||
@@ -34,63 +34,63 @@ struct MenuButton : ui::Button { | |||||
struct NewItem : ui::MenuItem { | struct NewItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->resetDialog(); | APP->patch->resetDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct OpenItem : ui::MenuItem { | struct OpenItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->loadDialog(); | APP->patch->loadDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct SaveItem : ui::MenuItem { | struct SaveItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->saveDialog(); | APP->patch->saveDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct SaveAsItem : ui::MenuItem { | struct SaveAsItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->saveAsDialog(); | APP->patch->saveAsDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct SaveTemplateItem : ui::MenuItem { | struct SaveTemplateItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->saveTemplateDialog(); | APP->patch->saveTemplateDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct RevertItem : ui::MenuItem { | struct RevertItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->revertDialog(); | APP->patch->revertDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct DisconnectCablesItem : ui::MenuItem { | struct DisconnectCablesItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->patch->disconnectDialog(); | APP->patch->disconnectDialog(); | ||||
} | } | ||||
}; | }; | ||||
struct QuitItem : ui::MenuItem { | struct QuitItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->window->close(); | APP->window->close(); | ||||
} | } | ||||
}; | }; | ||||
struct FileButton : MenuButton { | struct FileButton : MenuButton { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ui::Menu *menu = createMenu(); | ui::Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -136,21 +136,21 @@ struct FileButton : MenuButton { | |||||
struct UndoItem : ui::MenuItem { | struct UndoItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->history->undo(); | APP->history->undo(); | ||||
} | } | ||||
}; | }; | ||||
struct RedoItem : ui::MenuItem { | struct RedoItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->history->redo(); | APP->history->redo(); | ||||
} | } | ||||
}; | }; | ||||
struct EditButton : MenuButton { | struct EditButton : MenuButton { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ui::Menu *menu = createMenu(); | ui::Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -247,28 +247,28 @@ struct CableTensionSlider : ui::Slider { | |||||
struct CpuMeterItem : ui::MenuItem { | struct CpuMeterItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::cpuMeter ^= true; | settings::cpuMeter ^= true; | ||||
} | } | ||||
}; | }; | ||||
struct ParamTooltipItem : ui::MenuItem { | struct ParamTooltipItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::paramTooltip ^= true; | settings::paramTooltip ^= true; | ||||
} | } | ||||
}; | }; | ||||
struct LockModulesItem : ui::MenuItem { | struct LockModulesItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::lockModules ^= true; | settings::lockModules ^= true; | ||||
} | } | ||||
}; | }; | ||||
struct EnginePauseItem : ui::MenuItem { | struct EnginePauseItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->engine->setPaused(!APP->engine->isPaused()); | APP->engine->setPaused(!APP->engine->isPaused()); | ||||
} | } | ||||
}; | }; | ||||
@@ -276,7 +276,7 @@ struct EnginePauseItem : ui::MenuItem { | |||||
struct SampleRateValueItem : ui::MenuItem { | struct SampleRateValueItem : ui::MenuItem { | ||||
float sampleRate; | float sampleRate; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->engine->setSampleRate(sampleRate); | APP->engine->setSampleRate(sampleRate); | ||||
APP->engine->setPaused(false); | APP->engine->setPaused(false); | ||||
} | } | ||||
@@ -324,7 +324,7 @@ struct ThreadCountValueItem : ui::MenuItem { | |||||
text += " (lowest CPU usage)"; | text += " (lowest CPU usage)"; | ||||
rightText = CHECKMARK(APP->engine->getThreadCount() == threadCount); | rightText = CHECKMARK(APP->engine->getThreadCount() == threadCount); | ||||
} | } | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
APP->engine->setThreadCount(threadCount); | APP->engine->setThreadCount(threadCount); | ||||
} | } | ||||
}; | }; | ||||
@@ -346,14 +346,14 @@ struct ThreadCount : ui::MenuItem { | |||||
struct FullscreenItem : 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()); | APP->window->setFullScreen(!APP->window->isFullScreen()); | ||||
} | } | ||||
}; | }; | ||||
struct SettingsButton : MenuButton { | struct SettingsButton : MenuButton { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ui::Menu *menu = createMenu(); | ui::Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -406,7 +406,7 @@ struct SettingsButton : MenuButton { | |||||
struct RegisterItem : ui::MenuItem { | struct RegisterItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/"); | system::openBrowser("https://vcvrack.com/"); | ||||
}); | }); | ||||
@@ -417,7 +417,7 @@ struct RegisterItem : ui::MenuItem { | |||||
struct AccountEmailField : ui::TextField { | struct AccountEmailField : ui::TextField { | ||||
ui::TextField *passwordField; | 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) { | if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) { | ||||
APP->event->selectedWidget = passwordField; | APP->event->selectedWidget = passwordField; | ||||
e.consume(this); | e.consume(this); | ||||
@@ -431,7 +431,7 @@ struct AccountEmailField : ui::TextField { | |||||
struct AccountPasswordField : ui::PasswordField { | struct AccountPasswordField : ui::PasswordField { | ||||
ui::MenuItem *logInItem; | 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)) { | if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { | ||||
logInItem->doAction(); | logInItem->doAction(); | ||||
e.consume(this); | e.consume(this); | ||||
@@ -446,7 +446,7 @@ struct AccountPasswordField : ui::PasswordField { | |||||
struct LogInItem : ui::MenuItem { | struct LogInItem : ui::MenuItem { | ||||
ui::TextField *emailField; | ui::TextField *emailField; | ||||
ui::TextField *passwordField; | ui::TextField *passwordField; | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::string email = emailField->text; | std::string email = emailField->text; | ||||
std::string password = passwordField->text; | std::string password = passwordField->text; | ||||
std::thread t([&, email, password]() { | std::thread t([&, email, password]() { | ||||
@@ -460,7 +460,7 @@ struct LogInItem : ui::MenuItem { | |||||
struct ManageItem : ui::MenuItem { | struct ManageItem : ui::MenuItem { | ||||
ManageItem() { | ManageItem() { | ||||
} | } | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
std::thread t([&]() { | std::thread t([&]() { | ||||
system::openBrowser("https://vcvrack.com/plugins.html"); | system::openBrowser("https://vcvrack.com/plugins.html"); | ||||
}); | }); | ||||
@@ -470,7 +470,7 @@ struct ManageItem : ui::MenuItem { | |||||
struct SyncItem : 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; | // completed = false; | ||||
// } | // } | ||||
// } | // } | ||||
// void onAction(const widget::ActionEvent &e) override { | |||||
// void onAction(const event::Action &e) override { | |||||
// available = false; | // available = false; | ||||
// std::thread t([this]() { | // std::thread t([this]() { | ||||
// if (plugin::sync(false)) | // if (plugin::sync(false)) | ||||
@@ -512,7 +512,7 @@ struct SyncItem : ui::MenuItem { | |||||
struct LogOutItem : ui::MenuItem { | struct LogOutItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
plugin::logOut(); | plugin::logOut(); | ||||
} | } | ||||
}; | }; | ||||
@@ -538,7 +538,7 @@ struct DownloadQuantity : Quantity { | |||||
struct PluginsButton : MenuButton { | struct PluginsButton : MenuButton { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ui::Menu *menu = createMenu(); | ui::Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -604,7 +604,7 @@ struct PluginsButton : MenuButton { | |||||
struct ManualItem : ui::MenuItem { | 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/"); | std::thread t(system::openBrowser, "https://vcvrack.com/manual/"); | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
@@ -612,7 +612,7 @@ struct ManualItem : ui::MenuItem { | |||||
struct WebsiteItem : 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/"); | std::thread t(system::openBrowser, "https://vcvrack.com/"); | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
@@ -620,14 +620,14 @@ struct WebsiteItem : ui::MenuItem { | |||||
struct CheckVersionItem : ui::MenuItem { | struct CheckVersionItem : ui::MenuItem { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
settings::checkVersion ^= true; | settings::checkVersion ^= true; | ||||
} | } | ||||
}; | }; | ||||
struct UserFolderItem : ui::MenuItem { | 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("")); | std::thread t(system::openFolder, asset::user("")); | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
@@ -635,7 +635,7 @@ struct UserFolderItem : ui::MenuItem { | |||||
struct HelpButton : MenuButton { | struct HelpButton : MenuButton { | ||||
void onAction(const widget::ActionEvent &e) override { | |||||
void onAction(const event::Action &e) override { | |||||
ui::Menu *menu = createMenu(); | ui::Menu *menu = createMenu(); | ||||
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); | ||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
@@ -1,69 +1,69 @@ | |||||
#include "widget/event.hpp" | |||||
#include "event.hpp" | |||||
#include "widget/Widget.hpp" | #include "widget/Widget.hpp" | ||||
namespace rack { | namespace rack { | ||||
namespace widget { | |||||
namespace event { | |||||
void EventState::setHovered(Widget *w) { | |||||
void State::setHovered(widget::Widget *w) { | |||||
if (w == hoveredWidget) | if (w == hoveredWidget) | ||||
return; | return; | ||||
if (hoveredWidget) { | if (hoveredWidget) { | ||||
// LeaveEvent | |||||
LeaveEvent eLeave; | |||||
// Leave | |||||
Leave eLeave; | |||||
hoveredWidget->onLeave(eLeave); | hoveredWidget->onLeave(eLeave); | ||||
hoveredWidget = NULL; | hoveredWidget = NULL; | ||||
} | } | ||||
if (w) { | if (w) { | ||||
// EnterEvent | |||||
EventContext cEnter; | |||||
EnterEvent eEnter; | |||||
// Enter | |||||
Context cEnter; | |||||
Enter eEnter; | |||||
eEnter.context = &cEnter; | eEnter.context = &cEnter; | ||||
w->onEnter(eEnter); | w->onEnter(eEnter); | ||||
hoveredWidget = cEnter.target; | hoveredWidget = cEnter.target; | ||||
} | } | ||||
} | } | ||||
void EventState::setDragged(Widget *w) { | |||||
void State::setDragged(widget::Widget *w) { | |||||
if (w == draggedWidget) | if (w == draggedWidget) | ||||
return; | return; | ||||
if (draggedWidget) { | if (draggedWidget) { | ||||
// DragEndEvent | |||||
DragEndEvent eDragEnd; | |||||
// DragEnd | |||||
DragEnd eDragEnd; | |||||
draggedWidget->onDragEnd(eDragEnd); | draggedWidget->onDragEnd(eDragEnd); | ||||
draggedWidget = NULL; | draggedWidget = NULL; | ||||
} | } | ||||
if (w) { | if (w) { | ||||
// DragStartEvent | |||||
EventContext cDragStart; | |||||
DragStartEvent eDragStart; | |||||
// DragStart | |||||
Context cDragStart; | |||||
DragStart eDragStart; | |||||
eDragStart.context = &cDragStart; | eDragStart.context = &cDragStart; | ||||
w->onDragStart(eDragStart); | w->onDragStart(eDragStart); | ||||
draggedWidget = cDragStart.target; | draggedWidget = cDragStart.target; | ||||
} | } | ||||
} | } | ||||
void EventState::setDragHovered(Widget *w) { | |||||
void State::setDragHovered(widget::Widget *w) { | |||||
if (w == dragHoveredWidget) | if (w == dragHoveredWidget) | ||||
return; | return; | ||||
if (dragHoveredWidget) { | if (dragHoveredWidget) { | ||||
// DragLeaveEvent | |||||
DragLeaveEvent eDragLeave; | |||||
// DragLeave | |||||
DragLeave eDragLeave; | |||||
eDragLeave.origin = draggedWidget; | eDragLeave.origin = draggedWidget; | ||||
dragHoveredWidget->onDragLeave(eDragLeave); | dragHoveredWidget->onDragLeave(eDragLeave); | ||||
dragHoveredWidget = NULL; | dragHoveredWidget = NULL; | ||||
} | } | ||||
if (w) { | if (w) { | ||||
// DragEnterEvent | |||||
EventContext cDragEnter; | |||||
DragEnterEvent eDragEnter; | |||||
// DragEnter | |||||
Context cDragEnter; | |||||
DragEnter eDragEnter; | |||||
eDragEnter.context = &cDragEnter; | eDragEnter.context = &cDragEnter; | ||||
eDragEnter.origin = draggedWidget; | eDragEnter.origin = draggedWidget; | ||||
w->onDragEnter(eDragEnter); | 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) | if (w == selectedWidget) | ||||
return; | return; | ||||
if (selectedWidget) { | if (selectedWidget) { | ||||
// DeselectEvent | |||||
DeselectEvent eDeselect; | |||||
// Deselect | |||||
Deselect eDeselect; | |||||
selectedWidget->onDeselect(eDeselect); | selectedWidget->onDeselect(eDeselect); | ||||
selectedWidget = NULL; | selectedWidget = NULL; | ||||
} | } | ||||
if (w) { | if (w) { | ||||
// SelectEvent | |||||
EventContext cSelect; | |||||
SelectEvent eSelect; | |||||
// Select | |||||
Context cSelect; | |||||
Select eSelect; | |||||
eSelect.context = &cSelect; | eSelect.context = &cSelect; | ||||
w->onSelect(eSelect); | w->onSelect(eSelect); | ||||
selectedWidget = cSelect.target; | selectedWidget = cSelect.target; | ||||
} | } | ||||
} | } | ||||
void EventState::finalizeWidget(Widget *w) { | |||||
void State::finalizeWidget(widget::Widget *w) { | |||||
if (hoveredWidget == w) setHovered(NULL); | if (hoveredWidget == w) setHovered(NULL); | ||||
if (draggedWidget == w) setDragged(NULL); | if (draggedWidget == w) setDragged(NULL); | ||||
if (dragHoveredWidget == w) setDragHovered(NULL); | if (dragHoveredWidget == w) setDragHovered(NULL); | ||||
@@ -100,17 +100,17 @@ void EventState::finalizeWidget(Widget *w) { | |||||
if (lastClickedWidget == w) lastClickedWidget = NULL; | 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.context = &cButton; | ||||
eButton.pos = pos; | eButton.pos = pos; | ||||
eButton.button = button; | eButton.button = button; | ||||
eButton.action = action; | eButton.action = action; | ||||
eButton.mods = mods; | eButton.mods = mods; | ||||
rootWidget->onButton(eButton); | rootWidget->onButton(eButton); | ||||
Widget *clickedWidget = cButton.target; | |||||
widget::Widget *clickedWidget = cButton.target; | |||||
if (button == GLFW_MOUSE_BUTTON_LEFT) { | if (button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
if (action == GLFW_PRESS) { | if (action == GLFW_PRESS) { | ||||
@@ -121,8 +121,8 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) { | |||||
setDragHovered(NULL); | setDragHovered(NULL); | ||||
if (clickedWidget && draggedWidget) { | if (clickedWidget && draggedWidget) { | ||||
// DragDropEvent | |||||
DragDropEvent eDragDrop; | |||||
// DragDrop | |||||
DragDrop eDragDrop; | |||||
eDragDrop.origin = draggedWidget; | eDragDrop.origin = draggedWidget; | ||||
clickedWidget->onDragDrop(eDragDrop); | clickedWidget->onDragDrop(eDragDrop); | ||||
} | } | ||||
@@ -140,8 +140,8 @@ void EventState::handleButton(math::Vec pos, int button, int action, int mods) { | |||||
if (clickedWidget | if (clickedWidget | ||||
&& clickTime - lastClickTime <= doubleClickDuration | && clickTime - lastClickTime <= doubleClickDuration | ||||
&& lastClickedWidget == clickedWidget) { | && lastClickedWidget == clickedWidget) { | ||||
// DoubleClickEvent | |||||
DoubleClickEvent eDoubleClick; | |||||
// DoubleClick | |||||
DoubleClick eDoubleClick; | |||||
clickedWidget->onDoubleClick(eDoubleClick); | clickedWidget->onDoubleClick(eDoubleClick); | ||||
// Reset double click | // Reset double click | ||||
lastClickTime = -INFINITY; | 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) { | if (draggedWidget) { | ||||
// DragMoveEvent | |||||
DragMoveEvent eDragMove; | |||||
// DragMove | |||||
DragMove eDragMove; | |||||
eDragMove.mouseDelta = mouseDelta; | eDragMove.mouseDelta = mouseDelta; | ||||
draggedWidget->onDragMove(eDragMove); | draggedWidget->onDragMove(eDragMove); | ||||
// DragHoverEvent | |||||
EventContext cDragHover; | |||||
DragHoverEvent eDragHover; | |||||
// DragHover | |||||
Context cDragHover; | |||||
DragHover eDragHover; | |||||
eDragHover.context = &cDragHover; | eDragHover.context = &cDragHover; | ||||
eDragHover.pos = pos; | eDragHover.pos = pos; | ||||
eDragHover.mouseDelta = mouseDelta; | eDragHover.mouseDelta = mouseDelta; | ||||
@@ -176,9 +176,9 @@ void EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { | |||||
return; | return; | ||||
} | } | ||||
// HoverEvent | |||||
EventContext cHover; | |||||
HoverEvent eHover; | |||||
// Hover | |||||
Context cHover; | |||||
Hover eHover; | |||||
eHover.context = &cHover; | eHover.context = &cHover; | ||||
eHover.pos = pos; | eHover.pos = pos; | ||||
eHover.mouseDelta = mouseDelta; | eHover.mouseDelta = mouseDelta; | ||||
@@ -187,35 +187,35 @@ void EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { | |||||
setHovered(cHover.target); | setHovered(cHover.target); | ||||
} | } | ||||
void EventState::handleLeave() { | |||||
void State::handleLeave() { | |||||
setDragHovered(NULL); | setDragHovered(NULL); | ||||
setHovered(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.context = &cHoverScroll; | ||||
eHoverScroll.pos = pos; | eHoverScroll.pos = pos; | ||||
eHoverScroll.scrollDelta = scrollDelta; | eHoverScroll.scrollDelta = scrollDelta; | ||||
rootWidget->onHoverScroll(eHoverScroll); | 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.context = &cPathDrop; | ||||
ePathDrop.pos = pos; | ePathDrop.pos = pos; | ||||
rootWidget->onPathDrop(ePathDrop); | rootWidget->onPathDrop(ePathDrop); | ||||
} | } | ||||
void EventState::handleText(math::Vec pos, int codepoint) { | |||||
void State::handleText(math::Vec pos, int codepoint) { | |||||
if (selectedWidget) { | if (selectedWidget) { | ||||
// SelectTextEvent | |||||
EventContext cSelectText; | |||||
SelectTextEvent eSelectText; | |||||
// SelectText | |||||
Context cSelectText; | |||||
SelectText eSelectText; | |||||
eSelectText.context = &cSelectText; | eSelectText.context = &cSelectText; | ||||
eSelectText.codepoint = codepoint; | eSelectText.codepoint = codepoint; | ||||
selectedWidget->onSelectText(eSelectText); | selectedWidget->onSelectText(eSelectText); | ||||
@@ -223,20 +223,20 @@ void EventState::handleText(math::Vec pos, int codepoint) { | |||||
return; | return; | ||||
} | } | ||||
// HoverTextEvent | |||||
EventContext cHoverText; | |||||
HoverTextEvent eHoverText; | |||||
// HoverText | |||||
Context cHoverText; | |||||
HoverText eHoverText; | |||||
eHoverText.context = &cHoverText; | eHoverText.context = &cHoverText; | ||||
eHoverText.pos = pos; | eHoverText.pos = pos; | ||||
eHoverText.codepoint = codepoint; | eHoverText.codepoint = codepoint; | ||||
rootWidget->onHoverText(eHoverText); | 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) { | if (selectedWidget) { | ||||
// SelectKeyEvent | |||||
EventContext cSelectKey; | |||||
SelectKeyEvent eSelectKey; | |||||
// SelectKey | |||||
Context cSelectKey; | |||||
SelectKey eSelectKey; | |||||
eSelectKey.context = &cSelectKey; | eSelectKey.context = &cSelectKey; | ||||
eSelectKey.key = key; | eSelectKey.key = key; | ||||
eSelectKey.scancode = scancode; | eSelectKey.scancode = scancode; | ||||
@@ -247,9 +247,9 @@ void EventState::handleKey(math::Vec pos, int key, int scancode, int action, int | |||||
return; | return; | ||||
} | } | ||||
// HoverKeyEvent | |||||
EventContext cHoverKey; | |||||
HoverKeyEvent eHoverKey; | |||||
// HoverKey | |||||
Context cHoverKey; | |||||
HoverKey eHoverKey; | |||||
eHoverKey.context = &cHoverKey; | eHoverKey.context = &cHoverKey; | ||||
eHoverKey.pos = pos; | eHoverKey.pos = pos; | ||||
eHoverKey.key = key; | eHoverKey.key = key; | ||||
@@ -259,14 +259,14 @@ void EventState::handleKey(math::Vec pos, int key, int scancode, int action, int | |||||
rootWidget->onHoverKey(eHoverKey); | rootWidget->onHoverKey(eHoverKey); | ||||
} | } | ||||
void EventState::handleZoom() { | |||||
// ZoomEvent | |||||
EventContext cZoom; | |||||
ZoomEvent eZoom; | |||||
void State::handleZoom() { | |||||
// Zoom | |||||
Context cZoom; | |||||
Zoom eZoom; | |||||
eZoom.context = &cZoom; | eZoom.context = &cZoom; | ||||
rootWidget->onZoom(eZoom); | rootWidget->onZoom(eZoom); | ||||
} | } | ||||
} // namespace widget | |||||
} // namespace event | |||||
} // namespace rack | } // namespace rack |
@@ -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()); | 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; | state = BND_HOVER; | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void Button::onLeave(const widget::LeaveEvent &e) { | |||||
void Button::onLeave(const event::Leave &e) { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
} | } | ||||
void Button::onDragStart(const widget::DragStartEvent &e) { | |||||
void Button::onDragStart(const event::DragStart &e) { | |||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
if (quantity) | if (quantity) | ||||
quantity->setMax(); | quantity->setMax(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void Button::onDragEnd(const widget::DragEndEvent &e) { | |||||
void Button::onDragEnd(const event::DragEnd &e) { | |||||
state = BND_HOVER; | state = BND_HOVER; | ||||
if (quantity) | if (quantity) | ||||
quantity->setMin(); | quantity->setMin(); | ||||
} | } | ||||
void Button::onDragDrop(const widget::DragDropEvent &e) { | |||||
void Button::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
widget::ActionEvent eAction; | |||||
event::Action eAction; | |||||
onAction(eAction); | onAction(eAction); | ||||
} | } | ||||
} | } | ||||
@@ -54,7 +54,7 @@ void Menu::draw(const DrawArgs &args) { | |||||
Widget::draw(args); | Widget::draw(args); | ||||
} | } | ||||
void Menu::onHoverScroll(const widget::HoverScrollEvent &e) { | |||||
void Menu::onHoverScroll(const event::HoverScroll &e) { | |||||
if (parent && !parent->box.isContaining(box)) | if (parent && !parent->box.isContaining(box)) | ||||
box.pos.y += e.scrollDelta.y; | box.pos.y += e.scrollDelta.y; | ||||
} | } | ||||
@@ -41,7 +41,7 @@ void MenuItem::step() { | |||||
Widget::step(); | Widget::step(); | ||||
} | } | ||||
void MenuItem::onEnter(const widget::EnterEvent &e) { | |||||
void MenuItem::onEnter(const event::Enter &e) { | |||||
e.consume(this); | e.consume(this); | ||||
Menu *parentMenu = dynamic_cast<Menu*>(parent); | Menu *parentMenu = dynamic_cast<Menu*>(parent); | ||||
if (!parentMenu) | if (!parentMenu) | ||||
@@ -58,11 +58,11 @@ void MenuItem::onEnter(const widget::EnterEvent &e) { | |||||
parentMenu->setChildMenu(childMenu); | parentMenu->setChildMenu(childMenu); | ||||
} | } | ||||
void MenuItem::onDragStart(const widget::DragStartEvent &e) { | |||||
void MenuItem::onDragStart(const event::DragStart &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void MenuItem::onDragDrop(const widget::DragDropEvent &e) { | |||||
void MenuItem::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin != this) | if (e.origin != this) | ||||
return; | return; | ||||
doAction(); | doAction(); | ||||
@@ -72,8 +72,8 @@ void MenuItem::doAction() { | |||||
if (disabled) | if (disabled) | ||||
return; | return; | ||||
widget::EventContext cAction; | |||||
widget::ActionEvent eAction; | |||||
event::Context cAction; | |||||
event::Action eAction; | |||||
eAction.context = &cAction; | eAction.context = &cAction; | ||||
// Consume event by default, but allow action to un-consume it to prevent the menu from being removed. | // Consume event by default, but allow action to un-consume it to prevent the menu from being removed. | ||||
eAction.consume(this); | eAction.consume(this); | ||||
@@ -17,7 +17,7 @@ void MenuOverlay::step() { | |||||
Widget::step(); | Widget::step(); | ||||
} | } | ||||
void MenuOverlay::onButton(const widget::ButtonEvent &e) { | |||||
void MenuOverlay::onButton(const event::Button &e) { | |||||
widget::OpaqueWidget::onButton(e); | widget::OpaqueWidget::onButton(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | 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); | widget::OpaqueWidget::onHoverKey(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | return; | ||||
@@ -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()); | 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; | state = BND_HOVER; | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void RadioButton::onLeave(const widget::LeaveEvent &e) { | |||||
void RadioButton::onLeave(const event::Leave &e) { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
} | } | ||||
void RadioButton::onDragStart(const widget::DragStartEvent &e) { | |||||
void RadioButton::onDragStart(const event::DragStart &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void RadioButton::onDragDrop(const widget::DragDropEvent &e) { | |||||
void RadioButton::onDragDrop(const event::DragDrop &e) { | |||||
if (e.origin == this) { | if (e.origin == this) { | ||||
if (quantity) { | if (quantity) { | ||||
if (quantity->isMax()) | if (quantity->isMax()) | ||||
@@ -42,7 +42,7 @@ void RadioButton::onDragDrop(const widget::DragDropEvent &e) { | |||||
quantity->setMax(); | quantity->setMax(); | ||||
} | } | ||||
widget::ActionEvent eAction; | |||||
event::Action eAction; | |||||
onAction(eAction); | onAction(eAction); | ||||
} | } | ||||
} | } | ||||
@@ -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); | 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; | state = BND_ACTIVE; | ||||
APP->window->cursorLock(); | APP->window->cursorLock(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void ScrollBar::onDragMove(const widget::DragMoveEvent &e) { | |||||
void ScrollBar::onDragMove(const event::DragMove &e) { | |||||
const float sensitivity = 1.f; | const float sensitivity = 1.f; | ||||
ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent); | ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent); | ||||
@@ -33,7 +33,7 @@ void ScrollBar::onDragMove(const widget::DragMoveEvent &e) { | |||||
scrollWidget->offset.y += sensitivity * e.mouseDelta.y; | scrollWidget->offset.y += sensitivity * e.mouseDelta.y; | ||||
} | } | ||||
void ScrollBar::onDragEnd(const widget::DragEndEvent &e) { | |||||
void ScrollBar::onDragEnd(const event::DragEnd &e) { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
APP->window->cursorUnlock(); | APP->window->cursorUnlock(); | ||||
} | } | ||||
@@ -1,6 +1,5 @@ | |||||
#include "ui/ScrollWidget.hpp" | #include "ui/ScrollWidget.hpp" | ||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "widget/event.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -64,11 +63,11 @@ void ScrollWidget::step() { | |||||
verticalScrollBar->box.size.y = horizontalScrollBar->visible ? inner.y : box.size.y; | 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); | widget::Widget::onHover(e); | ||||
} | } | ||||
void ScrollWidget::onHoverScroll(const widget::HoverScrollEvent &e) { | |||||
void ScrollWidget::onHoverScroll(const event::HoverScroll &e) { | |||||
widget::Widget::onHoverScroll(e); | widget::Widget::onHoverScroll(e); | ||||
if (e.getTarget() != this) | if (e.getTarget() != this) | ||||
return; | return; | ||||
@@ -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); | 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; | state = BND_ACTIVE; | ||||
APP->window->cursorLock(); | APP->window->cursorLock(); | ||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void Slider::onDragMove(const widget::DragMoveEvent &e) { | |||||
void Slider::onDragMove(const event::DragMove &e) { | |||||
if (quantity) { | if (quantity) { | ||||
quantity->moveScaledValue(SENSITIVITY * e.mouseDelta.x); | quantity->moveScaledValue(SENSITIVITY * e.mouseDelta.x); | ||||
} | } | ||||
} | } | ||||
void Slider::onDragEnd(const widget::DragEndEvent &e) { | |||||
void Slider::onDragEnd(const event::DragEnd &e) { | |||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
APP->window->cursorUnlock(); | APP->window->cursorUnlock(); | ||||
} | } | ||||
void Slider::onDoubleClick(const widget::DoubleClickEvent &e) { | |||||
void Slider::onDoubleClick(const event::DoubleClick &e) { | |||||
if (quantity) | if (quantity) | ||||
quantity->reset(); | quantity->reset(); | ||||
} | } | ||||
@@ -30,7 +30,7 @@ void TextField::draw(const DrawArgs &args) { | |||||
nvgResetScissor(args.vg); | nvgResetScissor(args.vg); | ||||
} | } | ||||
void TextField::onHover(const widget::HoverEvent &e) { | |||||
void TextField::onHover(const event::Hover &e) { | |||||
widget::OpaqueWidget::onHover(e); | widget::OpaqueWidget::onHover(e); | ||||
if (this == APP->event->draggedWidget) { | 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); | widget::OpaqueWidget::onButton(e); | ||||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { | 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); | e.consume(this); | ||||
} | } | ||||
void TextField::onSelect(const widget::SelectEvent &e) { | |||||
void TextField::onSelect(const event::Select &e) { | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
void TextField::onSelectText(const widget::SelectTextEvent &e) { | |||||
void TextField::onSelectText(const event::SelectText &e) { | |||||
if (e.codepoint < 128) { | if (e.codepoint < 128) { | ||||
std::string newText(1, (char) e.codepoint); | std::string newText(1, (char) e.codepoint); | ||||
insertText(newText); | insertText(newText); | ||||
@@ -65,7 +65,7 @@ void TextField::onSelectText(const widget::SelectTextEvent &e) { | |||||
e.consume(this); | 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) { | if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_BACKSPACE: { | case GLFW_KEY_BACKSPACE: { | ||||
@@ -73,7 +73,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) { | |||||
cursor--; | cursor--; | ||||
if (cursor >= 0) { | if (cursor >= 0) { | ||||
text.erase(cursor, 1); | text.erase(cursor, 1); | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
} | } | ||||
selection = cursor; | selection = cursor; | ||||
@@ -81,7 +81,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) { | |||||
else { | else { | ||||
int begin = std::min(cursor, selection); | int begin = std::min(cursor, selection); | ||||
text.erase(begin, std::abs(selection - cursor)); | text.erase(begin, std::abs(selection - cursor)); | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
cursor = selection = begin; | cursor = selection = begin; | ||||
} | } | ||||
@@ -89,13 +89,13 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) { | |||||
case GLFW_KEY_DELETE: { | case GLFW_KEY_DELETE: { | ||||
if (cursor == selection) { | if (cursor == selection) { | ||||
text.erase(cursor, 1); | text.erase(cursor, 1); | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
} | } | ||||
else { | else { | ||||
int begin = std::min(cursor, selection); | int begin = std::min(cursor, selection); | ||||
text.erase(begin, std::abs(selection - cursor)); | text.erase(begin, std::abs(selection - cursor)); | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
cursor = selection = begin; | cursor = selection = begin; | ||||
} | } | ||||
@@ -170,7 +170,7 @@ void TextField::onSelectKey(const widget::SelectKeyEvent &e) { | |||||
insertText("\n"); | insertText("\n"); | ||||
} | } | ||||
else { | else { | ||||
widget::ActionEvent eAction; | |||||
event::Action eAction; | |||||
onAction(eAction); | onAction(eAction); | ||||
} | } | ||||
} break; | } break; | ||||
@@ -191,7 +191,7 @@ void TextField::insertText(std::string text) { | |||||
this->text.insert(cursor, text); | this->text.insert(cursor, text); | ||||
cursor += text.size(); | cursor += text.size(); | ||||
selection = cursor; | selection = cursor; | ||||
widget::ChangeEvent eChange; | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
} | } | ||||
@@ -200,8 +200,8 @@ void TextField::setText(std::string text) { | |||||
this->text = text; | this->text = text; | ||||
selection = cursor = text.size(); | selection = cursor = text.size(); | ||||
if (changed) { | if (changed) { | ||||
// widget::ChangeEvent | |||||
widget::ChangeEvent eChange; | |||||
// event::Change | |||||
event::Change eChange; | |||||
onChange(eChange); | onChange(eChange); | ||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,4 @@ | |||||
#include "widget/Widget.hpp" | #include "widget/Widget.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include <algorithm> | #include <algorithm> | ||||
@@ -16,15 +15,15 @@ Widget::~Widget() { | |||||
void Widget::setPos(math::Vec pos) { | void Widget::setPos(math::Vec pos) { | ||||
box.pos = pos; | box.pos = pos; | ||||
// RepositionEvent | |||||
RepositionEvent eReposition; | |||||
// event::Reposition | |||||
event::Reposition eReposition; | |||||
onReposition(eReposition); | onReposition(eReposition); | ||||
} | } | ||||
void Widget::setSize(math::Vec size) { | void Widget::setSize(math::Vec size) { | ||||
box.size = size; | box.size = size; | ||||
// ResizeEvent | |||||
ResizeEvent eResize; | |||||
// event::Resize | |||||
event::Resize eResize; | |||||
onResize(eResize); | onResize(eResize); | ||||
} | } | ||||
@@ -32,8 +31,8 @@ void Widget::show() { | |||||
if (visible) | if (visible) | ||||
return; | return; | ||||
visible = true; | visible = true; | ||||
// ShowEvent | |||||
ShowEvent eShow; | |||||
// event::Show | |||||
event::Show eShow; | |||||
onShow(eShow); | onShow(eShow); | ||||
} | } | ||||
@@ -41,8 +40,8 @@ void Widget::hide() { | |||||
if (!visible) | if (!visible) | ||||
return; | return; | ||||
visible = false; | visible = false; | ||||
// HideEvent | |||||
HideEvent eHide; | |||||
// event::Hide | |||||
event::Hide eHide; | |||||
onHide(eHide); | onHide(eHide); | ||||
} | } | ||||
@@ -90,8 +89,8 @@ void Widget::addChild(Widget *child) { | |||||
assert(!child->parent); | assert(!child->parent); | ||||
child->parent = this; | child->parent = this; | ||||
children.push_back(child); | children.push_back(child); | ||||
// AddEvent | |||||
AddEvent eAdd; | |||||
// event::Add | |||||
event::Add eAdd; | |||||
child->onAdd(eAdd); | child->onAdd(eAdd); | ||||
} | } | ||||
@@ -99,8 +98,8 @@ void Widget::removeChild(Widget *child) { | |||||
assert(child); | assert(child); | ||||
// Make sure `this` is the child's parent | // Make sure `this` is the child's parent | ||||
assert(child->parent == this); | assert(child->parent == this); | ||||
// RemoveEvent | |||||
RemoveEvent eRemove; | |||||
// event::Remove | |||||
event::Remove eRemove; | |||||
child->onRemove(eRemove); | child->onRemove(eRemove); | ||||
// Prepare to remove widget from the event state | // Prepare to remove widget from the event state | ||||
APP->event->finalizeWidget(child); | APP->event->finalizeWidget(child); | ||||
@@ -114,8 +113,8 @@ void Widget::removeChild(Widget *child) { | |||||
void Widget::clearChildren() { | void Widget::clearChildren() { | ||||
for (Widget *child : children) { | for (Widget *child : children) { | ||||
// RemoveEvent | |||||
RemoveEvent eRemove; | |||||
// event::Remove | |||||
event::Remove eRemove; | |||||
child->onRemove(eRemove); | child->onRemove(eRemove); | ||||
APP->event->finalizeWidget(child); | APP->event->finalizeWidget(child); | ||||
child->parent = NULL; | child->parent = NULL; | ||||
@@ -129,8 +128,8 @@ void Widget::step() { | |||||
Widget *child = *it; | Widget *child = *it; | ||||
// Delete children if a delete is requested | // Delete children if a delete is requested | ||||
if (child->requestedDelete) { | if (child->requestedDelete) { | ||||
// RemoveEvent | |||||
RemoveEvent eRemove; | |||||
// event::Remove | |||||
event::Remove eRemove; | |||||
child->onRemove(eRemove); | child->onRemove(eRemove); | ||||
APP->event->finalizeWidget(child); | APP->event->finalizeWidget(child); | ||||
it = children.erase(it); | it = children.erase(it); | ||||
@@ -23,8 +23,8 @@ void ZoomWidget::setZoom(float zoom) { | |||||
return; | return; | ||||
this->zoom = zoom; | this->zoom = zoom; | ||||
EventContext cZoom; | |||||
ZoomEvent eZoom; | |||||
event::Context cZoom; | |||||
event::Zoom eZoom; | |||||
eZoom.context = &cZoom; | eZoom.context = &cZoom; | ||||
Widget::onZoom(eZoom); | Widget::onZoom(eZoom); | ||||
} | } | ||||
@@ -3,7 +3,7 @@ | |||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "keyboard.hpp" | #include "keyboard.hpp" | ||||
#include "gamepad.hpp" | #include "gamepad.hpp" | ||||
#include "widget/event.hpp" | |||||
#include "event.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "patch.hpp" | #include "patch.hpp" | ||||
#include "settings.hpp" | #include "settings.hpp" | ||||