VCV Rack API v2
Loading...
Searching...
No Matches
rack::widget::ZoomWidget Struct Reference

Resizes the scale of appearance and PositionEvents of children. More...

#include <ZoomWidget.hpp>

Inheritance diagram for rack::widget::ZoomWidget:
[legend]
Collaboration diagram for rack::widget::ZoomWidget:
[legend]

Public Member Functions

math::Vec getRelativeOffset (math::Vec v, Widget *ancestor) override
 Returns v (given in local coordinates) transformed into the coordinate system of ancestor.
 
float getRelativeZoom (Widget *ancestor) override
 Returns the zoom level in the coordinate system of ancestor.
 
math::Rect getViewport (math::Rect r) override
 Returns a subset of the given Rect bounded by the box of this widget and all ancestors.
 
float getZoom ()
 
void setZoom (float zoom)
 Sets zoom scale and triggers DirtyEvent recursively if scale is changed, so children FramebufferWidgets are redrawn.
 
void draw (const DrawArgs &args) override
 Draws the widget to the NanoVG context.
 
void drawLayer (const DrawArgs &args, int layer) override
 Draw additional layers.
 
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
 
- Public Member Functions inherited from rack::widget::Widget
virtual ~Widget ()
 
math::Rect getBox ()
 
void setBox (math::Rect box)
 Calls setPosition() and then setSize().
 
math::Vec getPosition ()
 
void setPosition (math::Vec pos)
 Sets position and triggers RepositionEvent if position changed.
 
math::Vec getSize ()
 
void setSize (math::Vec size)
 Sets size and triggers ResizeEvent if size changed.
 
widget::WidgetgetParent ()
 
bool isVisible ()
 
void setVisible (bool visible)
 Sets visible and triggers ShowEvent or HideEvent if changed.
 
void show ()
 Makes Widget visible and triggers ShowEvent if changed.
 
void hide ()
 Makes Widget not visible and triggers HideEvent if changed.
 
void requestDelete ()
 Requests this Widget's parent to delete it in the next step().
 
virtual math::Rect getChildrenBoundingBox ()
 Returns the smallest rectangle containing this widget's children (visible and invisible) in its local coordinates.
 
virtual math::Rect getVisibleChildrenBoundingBox ()
 
bool isDescendantOf (Widget *ancestor)
 Returns whether ancestor is a parent or distant parent of this widget.
 
math::Vec getAbsoluteOffset (math::Vec v)
 Returns v transformed into world/root/global/absolute coordinates.
 
float getAbsoluteZoom ()
 
template<class T >
T * getAncestorOfType ()
 
template<class T >
T * getFirstDescendantOfType ()
 
bool hasChild (Widget *child)
 Checks if the given widget is a child of this widget.
 
void addChild (Widget *child)
 Adds widget to the top of the children.
 
void addChildBottom (Widget *child)
 Adds widget to the bottom of the children.
 
void addChildBelow (Widget *child, Widget *sibling)
 Adds widget directly below another widget.
 
void addChildAbove (Widget *child, Widget *sibling)
 
void removeChild (Widget *child)
 Removes widget from list of children if it exists.
 
void clearChildren ()
 Removes and deletes all child Widgets.
 
virtual void step ()
 Advances the module by one frame.
 
virtual DEPRECATED void draw (NVGcontext *vg)
 Override draw(const DrawArgs &args) instead.
 
void drawChild (Widget *child, const DrawArgs &args, int layer=0)
 Draws a particular child.
 
template<typename TMethod , class TEvent >
void recurseEvent (TMethod f, const TEvent &e)
 Recurses an event to all visible Widgets.
 
template<typename TMethod , class TEvent >
void recursePositionEvent (TMethod f, const TEvent &e)
 Recurses an event to all visible Widgets until it is consumed.
 
virtual void onDoubleClick (const DoubleClickEvent &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 onDragEnter (const DragEnterEvent &e)
 
virtual void onDragLeave (const DragLeaveEvent &e)
 
virtual void onDragDrop (const DragDropEvent &e)
 
virtual void onAction (const ActionEvent &e)
 
virtual void onChange (const ChangeEvent &e)
 
virtual void onDirty (const DirtyEvent &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)
 
virtual void onHide (const HideEvent &e)
 
virtual void onContextCreate (const ContextCreateEvent &e)
 
virtual void onContextDestroy (const ContextDestroyEvent &e)
 
- Public Member Functions inherited from rack::WeakBase
 ~WeakBase ()
 
size_t getWeakCount ()
 

Public Attributes

float zoom = 1.f
 Use setZoom() and getZoom() instead of using this variable directly.
 
- Public Attributes inherited from rack::widget::Widget
math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY))
 Position relative to parent and size of widget.
 
Widgetparent = NULL
 Automatically set when Widget is added as a child to another Widget.
 
std::list< Widget * > children
 
bool visible = true
 Disables rendering but allow stepping.
 
bool requestedDelete = false
 If set to true, parent will delete Widget in the next step().
 
- Public Attributes inherited from rack::WeakBase
WeakHandleweakHandle = nullptr
 

Additional Inherited Members

- Public Types inherited from rack::widget::Widget
using BaseEvent = widget::BaseEvent
 

Detailed Description

Resizes the scale of appearance and PositionEvents of children.

Member Function Documentation

◆ getRelativeOffset()

math::Vec rack::widget::ZoomWidget::getRelativeOffset ( math::Vec v,
Widget * ancestor )
overridevirtual

Returns v (given in local coordinates) transformed into the coordinate system of ancestor.

Reimplemented from rack::widget::Widget.

◆ getRelativeZoom()

float rack::widget::ZoomWidget::getRelativeZoom ( Widget * ancestor)
overridevirtual

Returns the zoom level in the coordinate system of ancestor.

Only ZoomWidget should override this to return value other than 1.

Reimplemented from rack::widget::Widget.

◆ getViewport()

math::Rect rack::widget::ZoomWidget::getViewport ( math::Rect r)
overridevirtual

Returns a subset of the given Rect bounded by the box of this widget and all ancestors.

Reimplemented from rack::widget::Widget.

◆ getZoom()

float rack::widget::ZoomWidget::getZoom ( )

◆ setZoom()

void rack::widget::ZoomWidget::setZoom ( float zoom)

Sets zoom scale and triggers DirtyEvent recursively if scale is changed, so children FramebufferWidgets are redrawn.

◆ draw()

void rack::widget::ZoomWidget::draw ( const DrawArgs & args)
overridevirtual

Draws the widget to the NanoVG context.

When overriding, call the superclass's draw(args) to recurse to children.

Reimplemented from rack::widget::Widget.

◆ drawLayer()

void rack::widget::ZoomWidget::drawLayer ( const DrawArgs & args,
int layer )
overridevirtual

Draw additional layers.

Custom widgets may draw its children multiple times on different layers, passing an arbitrary layer number each time. Layer 0 calls children's draw(). When overriding, always wrap draw commands in if (layer == ...) {} to avoid drawing on all layers. When overriding, call the superclass's drawLayer(args, layer) to recurse to children.

Reimplemented from rack::widget::Widget.

◆ onHover()

void rack::widget::ZoomWidget::onHover ( const HoverEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onButton()

void rack::widget::ZoomWidget::onButton ( const ButtonEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onHoverKey()

void rack::widget::ZoomWidget::onHoverKey ( const HoverKeyEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onHoverText()

void rack::widget::ZoomWidget::onHoverText ( const HoverTextEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onHoverScroll()

void rack::widget::ZoomWidget::onHoverScroll ( const HoverScrollEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onDragHover()

void rack::widget::ZoomWidget::onDragHover ( const DragHoverEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

◆ onPathDrop()

void rack::widget::ZoomWidget::onPathDrop ( const PathDropEvent & e)
inlineoverridevirtual

Reimplemented from rack::widget::Widget.

Member Data Documentation

◆ zoom

float rack::widget::ZoomWidget::zoom = 1.f

Use setZoom() and getZoom() instead of using this variable directly.


The documentation for this struct was generated from the following file: