VCV Rack API v2
|
A node in the 2D scene graph. More...
#include <Widget.hpp>
Classes | |
struct | ActionEvent |
Occurs after a certain action is triggered on a Widget. More... | |
struct | AddEvent |
Occurs after a Widget is added to a parent. More... | |
struct | ButtonEvent |
Occurs each mouse button press or release. More... | |
struct | ChangeEvent |
Occurs after the value of a Widget changes. More... | |
struct | ContextCreateEvent |
Occurs after the Window (including OpenGL and NanoVG contexts) are created. More... | |
struct | ContextDestroyEvent |
Occurs before the Window (including OpenGL and NanoVG contexts) are destroyed. More... | |
struct | DeselectEvent |
Occurs when a different Widget is selected. More... | |
struct | DirtyEvent |
Occurs when the pixel buffer of this module must be refreshed. More... | |
struct | DoubleClickEvent |
Occurs when the left mouse button is pressed a second time on the same Widget within a time duration. More... | |
struct | DragBaseEvent |
struct | DragDropEvent |
Occurs when the mouse button is released over a Widget while dragging. More... | |
struct | DragEndEvent |
Occurs when a Widget stops being dragged by releasing the mouse button. More... | |
struct | DragEnterEvent |
Occurs when the mouse enters a Widget while dragging. More... | |
struct | DragHoverEvent |
Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same one) is being dragged. More... | |
struct | DragLeaveEvent |
Occurs when the mouse leaves a Widget while dragging. More... | |
struct | DragMoveEvent |
Occurs every frame on the dragged Widget. More... | |
struct | DragStartEvent |
Occurs when a Widget begins being dragged. More... | |
struct | DrawArgs |
struct | EnterEvent |
Occurs when a Widget begins consuming the Hover event. More... | |
struct | HideEvent |
Occurs after a Widget is hidden with Widget::hide(). More... | |
struct | HoverEvent |
Occurs every frame when the mouse is hovering over a Widget. More... | |
struct | HoverKeyEvent |
Occurs when a key is pressed, released, or repeated while the mouse is hovering a Widget. More... | |
struct | HoverScrollEvent |
Occurs when the mouse scroll wheel is moved while the mouse is hovering a Widget. More... | |
struct | HoverTextEvent |
Occurs when a character is typed while the mouse is hovering a Widget. More... | |
struct | KeyBaseEvent |
An event prototype with a GLFW key. More... | |
struct | LeaveEvent |
Occurs when a different Widget is entered. More... | |
struct | PathDropEvent |
Occurs when a selection of files from the operating system is dropped onto a Widget. More... | |
struct | PositionBaseEvent |
An event prototype with a vector position. More... | |
struct | RemoveEvent |
Occurs before a Widget is removed from its parent. More... | |
struct | RepositionEvent |
Occurs after a Widget's position is set by Widget::setPosition(). More... | |
struct | ResizeEvent |
Occurs after a Widget's size is set by Widget::setSize(). More... | |
struct | SelectEvent |
Occurs when a Widget begins consuming the Button press event for the left mouse button. More... | |
struct | SelectKeyEvent |
Occurs when a key is pressed, released, or repeated while a Widget is selected. More... | |
struct | SelectTextEvent |
Occurs when text is typed while a Widget is selected. More... | |
struct | ShowEvent |
Occurs after a Widget is shown with Widget::show(). More... | |
struct | TextBaseEvent |
An event prototype with a Unicode character. More... | |
Public Types | |
using | BaseEvent = widget::BaseEvent |
Public Member Functions | |
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::Widget * | getParent () |
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. | |
virtual math::Vec | getRelativeOffset (math::Vec v, Widget *ancestor) |
Returns v (given in local coordinates) transformed into the coordinate system of ancestor . | |
math::Vec | getAbsoluteOffset (math::Vec v) |
Returns v transformed into world/root/global/absolute coordinates. | |
virtual float | getRelativeZoom (Widget *ancestor) |
Returns the zoom level in the coordinate system of ancestor . | |
float | getAbsoluteZoom () |
virtual math::Rect | getViewport (math::Rect r=math::Rect::inf()) |
Returns a subset of the given Rect bounded by the box of this widget and all ancestors. | |
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 void | draw (const DrawArgs &args) |
Draws the widget to the NanoVG context. | |
virtual DEPRECATED void | draw (NVGcontext *vg) |
Override draw(const DrawArgs &args) instead. | |
virtual void | drawLayer (const DrawArgs &args, int layer) |
Draw additional layers. | |
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 | onHover (const HoverEvent &e) |
virtual void | onButton (const ButtonEvent &e) |
virtual void | onDoubleClick (const DoubleClickEvent &e) |
virtual void | onHoverKey (const HoverKeyEvent &e) |
virtual void | onHoverText (const HoverTextEvent &e) |
virtual void | onHoverScroll (const HoverScrollEvent &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) |
virtual void | onDragEnter (const DragEnterEvent &e) |
virtual void | onDragLeave (const DragLeaveEvent &e) |
virtual void | onDragDrop (const DragDropEvent &e) |
virtual void | onPathDrop (const PathDropEvent &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 | |
math::Rect | box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)) |
Position relative to parent and size of widget. | |
Widget * | parent = 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 | |
WeakHandle * | weakHandle = nullptr |
A node in the 2D scene graph.
The bounding box of a Widget is a rectangle specified by box
relative to their parent. The appearance is defined by overriding draw()
, and the behavior is defined by overriding step()
and on*()
event handlers.
|
virtual |
math::Rect rack::widget::Widget::getBox | ( | ) |
void rack::widget::Widget::setBox | ( | math::Rect | box | ) |
Calls setPosition() and then setSize().
math::Vec rack::widget::Widget::getPosition | ( | ) |
void rack::widget::Widget::setPosition | ( | math::Vec | pos | ) |
Sets position and triggers RepositionEvent if position changed.
math::Vec rack::widget::Widget::getSize | ( | ) |
void rack::widget::Widget::setSize | ( | math::Vec | size | ) |
Sets size and triggers ResizeEvent if size changed.
widget::Widget * rack::widget::Widget::getParent | ( | ) |
bool rack::widget::Widget::isVisible | ( | ) |
void rack::widget::Widget::setVisible | ( | bool | visible | ) |
|
inline |
void rack::widget::Widget::requestDelete | ( | ) |
|
virtual |
Returns the smallest rectangle containing this widget's children (visible and invisible) in its local coordinates.
Returns Rect(Vec(inf, inf), Vec(-inf, -inf))
if there are no children.
|
virtual |
bool rack::widget::Widget::isDescendantOf | ( | Widget * | ancestor | ) |
Returns whether ancestor
is a parent or distant parent of this widget.
|
virtual |
Returns v
(given in local coordinates) transformed into the coordinate system of ancestor
.
Reimplemented in rack::widget::ZoomWidget.
Returns v
transformed into world/root/global/absolute coordinates.
|
virtual |
Returns the zoom level in the coordinate system of ancestor
.
Only ZoomWidget
should override this to return value other than 1.
Reimplemented in rack::widget::ZoomWidget.
|
inline |
|
virtual |
Returns a subset of the given Rect bounded by the box of this widget and all ancestors.
Reimplemented in rack::widget::ZoomWidget.
|
inline |
|
inline |
bool rack::widget::Widget::hasChild | ( | Widget * | child | ) |
Checks if the given widget is a child of this
widget.
void rack::widget::Widget::addChild | ( | Widget * | child | ) |
Adds widget to the top of the children.
Gives ownership of widget to this widget instance.
void rack::widget::Widget::addChildBottom | ( | Widget * | child | ) |
Adds widget to the bottom of the children.
Adds widget directly below another widget.
The sibling widget must already be a child of this
widget.
void rack::widget::Widget::removeChild | ( | Widget * | child | ) |
Removes widget from list of children if it exists.
Triggers RemoveEvent of child. Does not delete widget but transfers ownership to caller
void rack::widget::Widget::clearChildren | ( | ) |
Removes and deletes all child Widgets.
Triggers RemoveEvent of all children.
|
virtual |
Advances the module by one frame.
Reimplemented in rack::app::AudioBlockSizeChoice, rack::app::AudioDeviceChoice, rack::app::AudioDriverChoice, rack::app::AudioSampleRateChoice, rack::app::CableWidget, rack::app::MidiChannelChoice, rack::app::MidiDeviceChoice, rack::app::MidiDriverChoice, rack::app::ModuleLightWidget, rack::app::ParamWidget, rack::app::PlugWidget, rack::app::PortWidget, rack::app::RackScrollWidget, rack::app::RackWidget, rack::app::RailWidget, rack::app::Scene, rack::app::SvgPanel, rack::app::Switch, rack::app::ThemedSvgPanel, rack::app::ThemedSvgPort, rack::app::ThemedSvgScrew, rack::componentlibrary::LightSlider< VCVSlider, VCVSliderLight< BlueLight > >, rack::componentlibrary::LightSlider< VCVSlider, VCVSliderLight< GreenLight > >, rack::componentlibrary::LightSlider< VCVSlider, VCVSliderLight< RedLight > >, rack::componentlibrary::LightSlider< VCVSlider, VCVSliderLight< WhiteLight > >, rack::componentlibrary::LightSlider< VCVSlider, VCVSliderLight< YellowLight > >, rack::ui::ColorDotMenuItem, rack::ui::List, rack::ui::Menu, rack::ui::MenuItem, rack::ui::MenuLabel, rack::ui::MenuOverlay, rack::ui::ScrollWidget, rack::ui::SequentialLayout, rack::ui::Tooltip, rack::widget::FramebufferWidget, and rack::widget::OpenGlWidget.
|
virtual |
Draws the widget to the NanoVG context.
When overriding, call the superclass's draw(args)
to recurse to children.
Reimplemented in rack::app::CableWidget, rack::app::CircularShadow, rack::app::LedDisplay, rack::app::LedDisplayChoice, rack::app::LedDisplaySeparator, rack::app::LedDisplayTextField, rack::app::LightWidget, rack::app::ModuleWidget, rack::app::PanelBorder, rack::app::ParamWidget, rack::app::PortWidget, rack::app::RackScrollWidget, rack::app::RackWidget, rack::app::RailWidget, rack::app::Scene, rack::componentlibrary::SegmentDisplay, rack::ui::Button, rack::ui::ChoiceButton, rack::ui::ColorDotMenuItem, rack::ui::Label, rack::ui::Menu, rack::ui::MenuItem, rack::ui::MenuLabel, rack::ui::MenuOverlay, rack::ui::MenuSeparator, rack::ui::OptionButton, rack::ui::ProgressBar, rack::ui::RadioButton, rack::ui::Scrollbar, rack::ui::ScrollWidget, rack::ui::Slider, rack::ui::TextField, rack::ui::Tooltip, rack::widget::FramebufferWidget, rack::widget::SvgWidget, rack::widget::TransformWidget, and rack::widget::ZoomWidget.
|
inlinevirtual |
Override draw(const DrawArgs &args) instead.
|
virtual |
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 in rack::app::CableWidget, rack::app::LedDisplay, rack::app::LedDisplayChoice, rack::app::LedDisplayTextField, rack::app::LightWidget, rack::app::ModuleWidget, rack::widget::TransformWidget, and rack::widget::ZoomWidget.
Draws a particular child.
Saves and restores NanoVG context to prevent changing the given context.
|
inline |
Recurses an event to all visible Widgets.
|
inline |
Recurses an event to all visible Widgets until it is consumed.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::app::Knob, rack::app::LedDisplayChoice, rack::app::ModuleWidget, rack::app::ParamWidget, rack::app::PortWidget, rack::app::RackScrollWidget, rack::app::RackWidget, rack::app::SliderKnob, rack::app::SvgButton, rack::ui::MenuOverlay, rack::ui::Scrollbar, rack::ui::ScrollWidget, rack::ui::TextField, rack::widget::OpaqueWidget, rack::widget::TransparentWidget, and rack::widget::ZoomWidget.
|
inlinevirtual |
Reimplemented in rack::app::ParamWidget, rack::app::Switch, and rack::ui::Slider.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::widget::OpaqueWidget, rack::widget::TransparentWidget, and rack::widget::ZoomWidget.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::app::ModuleLightWidget, rack::app::ParamWidget, rack::app::PortWidget, and rack::ui::MenuItem.
|
inlinevirtual |
Reimplemented in rack::app::Knob, rack::app::ModuleLightWidget, rack::app::ParamWidget, and rack::app::PortWidget.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::ui::TextField.
|
inlinevirtual |
Reimplemented in rack::ui::TextField.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::app::Knob, rack::app::ModuleWidget, rack::ui::Scrollbar, rack::ui::ScrollWidget, and rack::ui::Slider.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::app::PortWidget.
|
inlinevirtual |
Reimplemented in rack::app::Knob, and rack::app::PortWidget.
|
inlinevirtual |
Reimplemented in rack::app::PortWidget, rack::app::SvgButton, rack::ui::Button, rack::ui::MenuItem, and rack::ui::RadioButton.
|
inlinevirtual |
Reimplemented in rack::app::Scene, rack::widget::OpaqueWidget, rack::widget::TransparentWidget, and rack::widget::ZoomWidget.
|
inlinevirtual |
Reimplemented in rack::app::AudioBlockSizeChoice, rack::app::AudioButton, rack::app::AudioDeviceChoice, rack::app::AudioDeviceMenuChoice, rack::app::AudioDriverChoice, rack::app::AudioSampleRateChoice, rack::app::Knob, rack::app::MidiButton, rack::app::MidiChannelChoice, rack::app::MidiDeviceChoice, rack::app::MidiDriverChoice, rack::ui::MenuItem, and rack::ui::MenuOverlay.
|
inlinevirtual |
Reimplemented in rack::app::SvgKnob, rack::app::SvgSlider, and rack::app::SvgSwitch.
|
inlinevirtual |
Reimplemented in rack::widget::FramebufferWidget.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::app::CableWidget.
|
inlinevirtual |
Reimplemented in rack::app::CableWidget.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in rack::widget::FramebufferWidget.
|
inlinevirtual |
Reimplemented in rack::widget::FramebufferWidget.
math::Rect rack::widget::Widget::box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)) |
Position relative to parent and size of widget.
Widget* rack::widget::Widget::parent = NULL |
std::list<Widget*> rack::widget::Widget::children |
bool rack::widget::Widget::visible = true |
Disables rendering but allow stepping.
Use isVisible(), setVisible(), show(), or hide() instead of using this variable directly.
bool rack::widget::Widget::requestedDelete = false |
If set to true, parent will delete Widget in the next step().
Use requestDelete() instead of using this variable directly.