VCV Rack API v2
Loading...
Searching...
No Matches
ZoomWidget.hpp
Go to the documentation of this file.
1#pragma once
2#include <widget/Widget.hpp>
3
4
5namespace rack {
6namespace widget {
7
8
12 float zoom = 1.f;
13
15 float getRelativeZoom(Widget* ancestor) override;
17 float getZoom();
19 void setZoom(float zoom);
20 void draw(const DrawArgs& args) override;
21 void drawLayer(const DrawArgs& args, int layer) override;
22
23 void onHover(const HoverEvent& e) override {
24 HoverEvent e2 = e;
25 e2.pos = e.pos.div(zoom);
27 }
28 void onButton(const ButtonEvent& e) override {
29 ButtonEvent e2 = e;
30 e2.pos = e.pos.div(zoom);
32 }
33 void onHoverKey(const HoverKeyEvent& e) override {
34 HoverKeyEvent e2 = e;
35 e2.pos = e.pos.div(zoom);
37 }
38 void onHoverText(const HoverTextEvent& e) override {
39 HoverTextEvent e2 = e;
40 e2.pos = e.pos.div(zoom);
42 }
43 void onHoverScroll(const HoverScrollEvent& e) override {
44 HoverScrollEvent e2 = e;
45 e2.pos = e.pos.div(zoom);
47 }
48 void onDragHover(const DragHoverEvent& e) override {
49 DragHoverEvent e2 = e;
50 e2.pos = e.pos.div(zoom);
52 }
53 void onPathDrop(const PathDropEvent& e) override {
54 PathDropEvent e2 = e;
55 e2.pos = e.pos.div(zoom);
57 }
58};
59
60
61} // namespace widget
62} // namespace rack
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
2-dimensional rectangle for graphics.
Definition math.hpp:301
2-dimensional vector of floats, representing a point on the plane for graphics.
Definition math.hpp:189
Vec div(float s) const
Definition math.hpp:221
Occurs each mouse button press or release.
Definition Widget.hpp:237
Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same o...
Definition Widget.hpp:391
Definition Widget.hpp:141
Occurs every frame when the mouse is hovering over a Widget.
Definition Widget.hpp:225
Occurs when a key is pressed, released, or repeated while the mouse is hovering a Widget.
Definition Widget.hpp:294
Occurs when the mouse scroll wheel is moved while the mouse is hovering a Widget.
Definition Widget.hpp:315
Occurs when a character is typed while the mouse is hovering a Widget.
Definition Widget.hpp:307
Occurs when a selection of files from the operating system is dropped onto a Widget.
Definition Widget.hpp:432
math::Vec pos
The pixel coordinate where the event occurred, relative to the Widget it is called on.
Definition Widget.hpp:218
A node in the 2D scene graph.
Definition Widget.hpp:21
virtual void onHoverKey(const HoverKeyEvent &e)
Definition Widget.hpp:295
virtual void onHover(const HoverEvent &e)
Definition Widget.hpp:229
virtual void onHoverText(const HoverTextEvent &e)
Definition Widget.hpp:308
virtual void onPathDrop(const PathDropEvent &e)
Definition Widget.hpp:438
virtual void onHoverScroll(const HoverScrollEvent &e)
Definition Widget.hpp:319
virtual void onButton(const ButtonEvent &e)
Definition Widget.hpp:245
virtual void onDragHover(const DragHoverEvent &e)
Definition Widget.hpp:397
Resizes the scale of appearance and PositionEvents of children.
Definition ZoomWidget.hpp:10
float getRelativeZoom(Widget *ancestor) override
Returns the zoom level in the coordinate system of ancestor.
void setZoom(float zoom)
Sets zoom scale and triggers DirtyEvent recursively if scale is changed, so children FramebufferWidge...
void onButton(const ButtonEvent &e) override
Definition ZoomWidget.hpp:28
math::Rect getViewport(math::Rect r) override
Returns a subset of the given Rect bounded by the box of this widget and all ancestors.
void drawLayer(const DrawArgs &args, int layer) override
Draw additional layers.
void onHover(const HoverEvent &e) override
Definition ZoomWidget.hpp:23
math::Vec getRelativeOffset(math::Vec v, Widget *ancestor) override
Returns v (given in local coordinates) transformed into the coordinate system of ancestor.
void draw(const DrawArgs &args) override
Draws the widget to the NanoVG context.
void onHoverKey(const HoverKeyEvent &e) override
Definition ZoomWidget.hpp:33
void onPathDrop(const PathDropEvent &e) override
Definition ZoomWidget.hpp:53
void onHoverText(const HoverTextEvent &e) override
Definition ZoomWidget.hpp:38
void onDragHover(const DragHoverEvent &e) override
Definition ZoomWidget.hpp:48
float zoom
Use setZoom() and getZoom() instead of using this variable directly.
Definition ZoomWidget.hpp:12
void onHoverScroll(const HoverScrollEvent &e) override
Definition ZoomWidget.hpp:43