VCV Rack API v2
Loading...
Searching...
No Matches
rack::app::RackWidget Struct Reference

Container for ModuleWidget and CableWidget. More...

#include <RackWidget.hpp>

Inheritance diagram for rack::app::RackWidget:
[legend]
Collaboration diagram for rack::app::RackWidget:
[legend]

Public Member Functions

PRIVATE RackWidget ()
 
PRIVATE ~RackWidget ()
 
void step () override
 Advances the module by one frame.
 
void draw (const DrawArgs &args) override
 Draws the widget to the NanoVG context.
 
void onHover (const HoverEvent &e) override
 
void onHoverKey (const HoverKeyEvent &e) override
 
void onButton (const ButtonEvent &e) override
 
void onDragStart (const DragStartEvent &e) override
 
void onDragEnd (const DragEndEvent &e) override
 
void onDragHover (const DragHoverEvent &e) override
 
widget::WidgetgetModuleContainer ()
 
widget::WidgetgetPlugContainer ()
 
widget::WidgetgetCableContainer ()
 
math::Vec getMousePos ()
 
void clear ()
 Completely clear the rack's modules and cables.
 
void mergeJson (json_t *rootJ)
 
void fromJson (json_t *rootJ)
 
void pasteJsonAction (json_t *rootJ)
 Pastes module JSON or selection JSON at the mouse position.
 
void pasteModuleJsonAction (json_t *moduleJ)
 
void pasteClipboardAction ()
 
void addModule (ModuleWidget *mw)
 Adds a module and adds it to the Engine, adopting ownership.
 
void addModuleAtMouse (ModuleWidget *mw)
 
void removeModule (ModuleWidget *mw)
 Removes the module and transfers ownership to the caller.
 
ModuleWidgetgetModule (int64_t moduleId)
 
std::vector< ModuleWidget * > getModules ()
 
bool hasModules ()
 
bool requestModulePos (ModuleWidget *mw, math::Vec pos)
 Sets a module's box if non-colliding.
 
void setModulePosNearest (ModuleWidget *mw, math::Vec pos)
 Moves a module to the closest non-colliding position.
 
void setModulePosForce (ModuleWidget *mw, math::Vec pos)
 Moves a module to a position, pushing other modules in the same row to the left or right, as needed.
 
void setModulePosSqueeze (ModuleWidget *mw, math::Vec pos)
 Moves a module, contracting old module positions and pushing modules to the right as needed to fit.
 
PRIVATE void squeezeModulePos (ModuleWidget *mw, math::Vec pos)
 
PRIVATE void unsqueezeModulePos (ModuleWidget *mw)
 
void updateModuleOldPositions ()
 Saves positions of modules for getModuleDragAction().
 
history::ComplexActiongetModuleDragAction ()
 
void updateSelectionFromRect ()
 
void selectAll ()
 
void deselectAll ()
 
void select (ModuleWidget *mw, bool selected=true)
 
bool hasSelection ()
 
const std::set< ModuleWidget * > & getSelected ()
 
bool isSelected (ModuleWidget *mw)
 
json_t * selectionToJson (bool cables=true)
 
void loadSelection (std::string path)
 
void loadSelectionDialog ()
 
void saveSelection (std::string path)
 
void saveSelectionDialog ()
 
void copyClipboardSelection ()
 
void resetSelectionAction ()
 
void randomizeSelectionAction ()
 
void disconnectSelectionAction ()
 
void cloneSelectionAction (bool cloneCables=true)
 
void bypassSelectionAction (bool bypassed)
 
bool isSelectionBypassed ()
 
void deleteSelectionAction ()
 
bool requestSelectionPos (math::Vec delta)
 
void setSelectionPosNearest (math::Vec delta)
 
void appendSelectionContextMenu (ui::Menu *menu)
 
void clearCables ()
 
void clearCablesAction ()
 
void clearCablesOnPort (PortWidget *port)
 Removes all cables connected to the port.
 
void addCable (CableWidget *cw)
 Adds a cable and adopts ownership.
 
void removeCable (CableWidget *cw)
 Removes cable and releases ownership to caller.
 
DEPRECATED CableWidgetgetIncompleteCable ()
 Returns the top incomplete cable.
 
PlugWidgetgetTopPlug (PortWidget *port)
 Returns the topmost plug stacked on the port.
 
CableWidgetgetTopCable (PortWidget *port)
 Returns the cable with the topmost plug stacked on the port.
 
CableWidgetgetCable (int64_t cableId)
 
CableWidgetgetCable (PortWidget *outputPort, PortWidget *inputPort)
 
std::vector< CableWidget * > getCables ()
 Returns all cables, complete and incomplete.
 
std::vector< CableWidget * > getCompleteCables ()
 Returns all cables attached to 2 ports.
 
std::vector< CableWidget * > getIncompleteCables ()
 Returns all cables attached to less than 2 ports.
 
std::vector< CableWidget * > getCablesOnPort (PortWidget *port)
 Returns all cables attached to the port, complete or not.
 
std::vector< CableWidget * > getCompleteCablesOnPort (PortWidget *port)
 Returns all complete cables attached to the port.
 
int getNextCableColorId ()
 Returns but does not advance the next cable color.
 
void setNextCableColorId (int id)
 
NVGcolor getNextCableColor ()
 Returns and advances the next cable color.
 
ParamWidgetgetTouchedParam ()
 
void setTouchedParam (ParamWidget *pw)
 
PRIVATE void updateExpanders ()
 
- Public Member Functions inherited from rack::widget::OpaqueWidget
void onHoverText (const HoverTextEvent &e) override
 
void onHoverScroll (const HoverScrollEvent &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.
 
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 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 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 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

Internal * internal
 
ParamWidgettouchedParam = NULL
 DEPRECATED.
 
- 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

Container for ModuleWidget and CableWidget.

Constructor & Destructor Documentation

◆ RackWidget()

PRIVATE rack::app::RackWidget::RackWidget ( )

◆ ~RackWidget()

PRIVATE rack::app::RackWidget::~RackWidget ( )

Member Function Documentation

◆ step()

void rack::app::RackWidget::step ( )
overridevirtual

Advances the module by one frame.

Reimplemented from rack::widget::Widget.

◆ draw()

void rack::app::RackWidget::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.

◆ onHover()

void rack::app::RackWidget::onHover ( const HoverEvent & e)
overridevirtual

Reimplemented from rack::widget::OpaqueWidget.

◆ onHoverKey()

void rack::app::RackWidget::onHoverKey ( const HoverKeyEvent & e)
overridevirtual

Reimplemented from rack::widget::OpaqueWidget.

◆ onButton()

void rack::app::RackWidget::onButton ( const ButtonEvent & e)
overridevirtual

Reimplemented from rack::widget::OpaqueWidget.

◆ onDragStart()

void rack::app::RackWidget::onDragStart ( const DragStartEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

◆ onDragEnd()

void rack::app::RackWidget::onDragEnd ( const DragEndEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

◆ onDragHover()

void rack::app::RackWidget::onDragHover ( const DragHoverEvent & e)
overridevirtual

Reimplemented from rack::widget::OpaqueWidget.

◆ getModuleContainer()

widget::Widget * rack::app::RackWidget::getModuleContainer ( )

◆ getPlugContainer()

widget::Widget * rack::app::RackWidget::getPlugContainer ( )

◆ getCableContainer()

widget::Widget * rack::app::RackWidget::getCableContainer ( )

◆ getMousePos()

math::Vec rack::app::RackWidget::getMousePos ( )

◆ clear()

void rack::app::RackWidget::clear ( )

Completely clear the rack's modules and cables.

◆ mergeJson()

void rack::app::RackWidget::mergeJson ( json_t * rootJ)

◆ fromJson()

void rack::app::RackWidget::fromJson ( json_t * rootJ)

◆ pasteJsonAction()

void rack::app::RackWidget::pasteJsonAction ( json_t * rootJ)

Pastes module JSON or selection JSON at the mouse position.

◆ pasteModuleJsonAction()

void rack::app::RackWidget::pasteModuleJsonAction ( json_t * moduleJ)

◆ pasteClipboardAction()

void rack::app::RackWidget::pasteClipboardAction ( )

◆ addModule()

void rack::app::RackWidget::addModule ( ModuleWidget * mw)

Adds a module and adds it to the Engine, adopting ownership.

◆ addModuleAtMouse()

void rack::app::RackWidget::addModuleAtMouse ( ModuleWidget * mw)

◆ removeModule()

void rack::app::RackWidget::removeModule ( ModuleWidget * mw)

Removes the module and transfers ownership to the caller.

◆ getModule()

ModuleWidget * rack::app::RackWidget::getModule ( int64_t moduleId)

◆ getModules()

std::vector< ModuleWidget * > rack::app::RackWidget::getModules ( )

◆ hasModules()

bool rack::app::RackWidget::hasModules ( )

◆ requestModulePos()

bool rack::app::RackWidget::requestModulePos ( ModuleWidget * mw,
math::Vec pos )

Sets a module's box if non-colliding.

Returns true if set

◆ setModulePosNearest()

void rack::app::RackWidget::setModulePosNearest ( ModuleWidget * mw,
math::Vec pos )

Moves a module to the closest non-colliding position.

◆ setModulePosForce()

void rack::app::RackWidget::setModulePosForce ( ModuleWidget * mw,
math::Vec pos )

Moves a module to a position, pushing other modules in the same row to the left or right, as needed.

◆ setModulePosSqueeze()

void rack::app::RackWidget::setModulePosSqueeze ( ModuleWidget * mw,
math::Vec pos )

Moves a module, contracting old module positions and pushing modules to the right as needed to fit.

◆ squeezeModulePos()

PRIVATE void rack::app::RackWidget::squeezeModulePos ( ModuleWidget * mw,
math::Vec pos )

◆ unsqueezeModulePos()

PRIVATE void rack::app::RackWidget::unsqueezeModulePos ( ModuleWidget * mw)

◆ updateModuleOldPositions()

void rack::app::RackWidget::updateModuleOldPositions ( )

Saves positions of modules for getModuleDragAction().

◆ getModuleDragAction()

history::ComplexAction * rack::app::RackWidget::getModuleDragAction ( )

◆ updateSelectionFromRect()

void rack::app::RackWidget::updateSelectionFromRect ( )

◆ selectAll()

void rack::app::RackWidget::selectAll ( )

◆ deselectAll()

void rack::app::RackWidget::deselectAll ( )

◆ select()

void rack::app::RackWidget::select ( ModuleWidget * mw,
bool selected = true )

◆ hasSelection()

bool rack::app::RackWidget::hasSelection ( )

◆ getSelected()

const std::set< ModuleWidget * > & rack::app::RackWidget::getSelected ( )

◆ isSelected()

bool rack::app::RackWidget::isSelected ( ModuleWidget * mw)

◆ selectionToJson()

json_t * rack::app::RackWidget::selectionToJson ( bool cables = true)

◆ loadSelection()

void rack::app::RackWidget::loadSelection ( std::string path)

◆ loadSelectionDialog()

void rack::app::RackWidget::loadSelectionDialog ( )

◆ saveSelection()

void rack::app::RackWidget::saveSelection ( std::string path)

◆ saveSelectionDialog()

void rack::app::RackWidget::saveSelectionDialog ( )

◆ copyClipboardSelection()

void rack::app::RackWidget::copyClipboardSelection ( )

◆ resetSelectionAction()

void rack::app::RackWidget::resetSelectionAction ( )

◆ randomizeSelectionAction()

void rack::app::RackWidget::randomizeSelectionAction ( )

◆ disconnectSelectionAction()

void rack::app::RackWidget::disconnectSelectionAction ( )

◆ cloneSelectionAction()

void rack::app::RackWidget::cloneSelectionAction ( bool cloneCables = true)

◆ bypassSelectionAction()

void rack::app::RackWidget::bypassSelectionAction ( bool bypassed)

◆ isSelectionBypassed()

bool rack::app::RackWidget::isSelectionBypassed ( )

◆ deleteSelectionAction()

void rack::app::RackWidget::deleteSelectionAction ( )

◆ requestSelectionPos()

bool rack::app::RackWidget::requestSelectionPos ( math::Vec delta)

◆ setSelectionPosNearest()

void rack::app::RackWidget::setSelectionPosNearest ( math::Vec delta)

◆ appendSelectionContextMenu()

void rack::app::RackWidget::appendSelectionContextMenu ( ui::Menu * menu)

◆ clearCables()

void rack::app::RackWidget::clearCables ( )

◆ clearCablesAction()

void rack::app::RackWidget::clearCablesAction ( )

◆ clearCablesOnPort()

void rack::app::RackWidget::clearCablesOnPort ( PortWidget * port)

Removes all cables connected to the port.

◆ addCable()

void rack::app::RackWidget::addCable ( CableWidget * cw)

Adds a cable and adopts ownership.

◆ removeCable()

void rack::app::RackWidget::removeCable ( CableWidget * cw)

Removes cable and releases ownership to caller.

◆ getIncompleteCable()

DEPRECATED CableWidget * rack::app::RackWidget::getIncompleteCable ( )

Returns the top incomplete cable.

Use getIncompleteCables() instead.

◆ getTopPlug()

PlugWidget * rack::app::RackWidget::getTopPlug ( PortWidget * port)

Returns the topmost plug stacked on the port.

◆ getTopCable()

CableWidget * rack::app::RackWidget::getTopCable ( PortWidget * port)

Returns the cable with the topmost plug stacked on the port.

◆ getCable() [1/2]

CableWidget * rack::app::RackWidget::getCable ( int64_t cableId)

◆ getCable() [2/2]

CableWidget * rack::app::RackWidget::getCable ( PortWidget * outputPort,
PortWidget * inputPort )

◆ getCables()

std::vector< CableWidget * > rack::app::RackWidget::getCables ( )

Returns all cables, complete and incomplete.

◆ getCompleteCables()

std::vector< CableWidget * > rack::app::RackWidget::getCompleteCables ( )

Returns all cables attached to 2 ports.

◆ getIncompleteCables()

std::vector< CableWidget * > rack::app::RackWidget::getIncompleteCables ( )

Returns all cables attached to less than 2 ports.

◆ getCablesOnPort()

std::vector< CableWidget * > rack::app::RackWidget::getCablesOnPort ( PortWidget * port)

Returns all cables attached to the port, complete or not.

◆ getCompleteCablesOnPort()

std::vector< CableWidget * > rack::app::RackWidget::getCompleteCablesOnPort ( PortWidget * port)

Returns all complete cables attached to the port.

◆ getNextCableColorId()

int rack::app::RackWidget::getNextCableColorId ( )

Returns but does not advance the next cable color.

◆ setNextCableColorId()

void rack::app::RackWidget::setNextCableColorId ( int id)

◆ getNextCableColor()

NVGcolor rack::app::RackWidget::getNextCableColor ( )

Returns and advances the next cable color.

◆ getTouchedParam()

ParamWidget * rack::app::RackWidget::getTouchedParam ( )

◆ setTouchedParam()

void rack::app::RackWidget::setTouchedParam ( ParamWidget * pw)

◆ updateExpanders()

PRIVATE void rack::app::RackWidget::updateExpanders ( )

Member Data Documentation

◆ internal

Internal* rack::app::RackWidget::internal

◆ touchedParam

ParamWidget* rack::app::RackWidget::touchedParam = NULL

DEPRECATED.

Use get/setTouchedParam().


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