VCV Rack API v2
Loading...
Searching...
No Matches
rack::app::ModuleWidget Struct Reference
module NULL

Manages an engine::Module in the rack. More...

#include <ModuleWidget.hpp>

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

Public Member Functions

 ModuleWidget ()
 
DEPRECATED ModuleWidget (engine::Module *module)
 
 ~ModuleWidget ()
 
plugin::ModelgetModel ()
 Returns the Model instance of this ModuleWidget.
 
void setModel (plugin::Model *model)
 
engine::ModulegetModule ()
 Returns Module attached to this ModuleWidget.
 
template<class TModule >
TModule * getModule ()
 Returns Module attached to this ModuleWidget, casted to the given Module type.
 
void setModule (engine::Module *module)
 Associates this ModuleWidget with the Module.
 
widget::WidgetgetPanel ()
 
void setPanel (widget::Widget *panel)
 Sets the panel and sets the size of the ModuleWidget from the panel.
 
void setPanel (std::shared_ptr< window::Svg > svg)
 
void addParam (ParamWidget *param)
 Convenience functions for adding special widgets.
 
void addInput (PortWidget *input)
 
void addOutput (PortWidget *output)
 
ParamWidgetgetParam (int paramId)
 Scans children widgets recursively for a ParamWidget with the given paramId.
 
PortWidgetgetInput (int portId)
 
PortWidgetgetOutput (int portId)
 
std::vector< ParamWidget * > getParams ()
 Scans children widgets recursively for all ParamWidgets.
 
std::vector< PortWidget * > getPorts ()
 
std::vector< PortWidget * > getInputs ()
 
std::vector< PortWidget * > getOutputs ()
 
void draw (const DrawArgs &args) override
 Draws the widget to the NanoVG context.
 
void drawLayer (const DrawArgs &args, int layer) override
 Draw additional layers.
 
virtual void appendContextMenu (ui::Menu *menu)
 Override to add context menu entries to your subclass.
 
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 onDragMove (const DragMoveEvent &e) override
 
void onDragHover (const DragHoverEvent &e) override
 
json_t * toJson ()
 
void fromJson (json_t *rootJ)
 
bool pasteJsonAction (json_t *rootJ)
 Returns whether paste was successful.
 
void copyClipboard ()
 
bool pasteClipboardAction ()
 
void load (std::string filename)
 
void loadAction (std::string filename)
 
void loadTemplate ()
 
void loadDialog ()
 
void save (std::string filename)
 
void saveTemplate ()
 
void saveTemplateDialog ()
 
bool hasTemplate ()
 
void clearTemplate ()
 
void clearTemplateDialog ()
 
void saveDialog ()
 
void disconnect ()
 Disconnects cables from all ports Called when the user clicks Disconnect Cables in the context menu.
 
void resetAction ()
 Resets the parameters of the module and calls the Module's randomize().
 
void randomizeAction ()
 Randomizes the parameters of the module and calls the Module's randomize().
 
void appendDisconnectActions (history::ComplexAction *complexAction)
 
void disconnectAction ()
 
void cloneAction (bool cloneCables=true)
 
void bypassAction (bool bypassed)
 
void removeAction ()
 Deletes this
 
void createContextMenu ()
 
math::Vec getGridPosition ()
 
void setGridPosition (math::Vec pos)
 
math::Vec getGridSize ()
 
math::Rect getGridBox ()
 
PRIVATE math::VecdragOffset ()
 
PRIVATE bool & dragEnabled ()
 
PRIVATE engine::ModulereleaseModule ()
 
- Public Member Functions inherited from rack::widget::OpaqueWidget
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.
 
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 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 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
 
plugin::Modelmodel = NULL
 Not owned.
 
- 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

Manages an engine::Module in the rack.

Constructor & Destructor Documentation

◆ ModuleWidget() [1/2]

rack::app::ModuleWidget::ModuleWidget ( )

◆ ModuleWidget() [2/2]

DEPRECATED rack::app::ModuleWidget::ModuleWidget ( engine::Module * module)
inline

◆ ~ModuleWidget()

rack::app::ModuleWidget::~ModuleWidget ( )

Member Function Documentation

◆ getModel()

plugin::Model * rack::app::ModuleWidget::getModel ( )

Returns the Model instance of this ModuleWidget.

◆ setModel()

void rack::app::ModuleWidget::setModel ( plugin::Model * model)

◆ getModule() [1/2]

engine::Module * rack::app::ModuleWidget::getModule ( )

Returns Module attached to this ModuleWidget.

◆ getModule() [2/2]

template<class TModule >
TModule * rack::app::ModuleWidget::getModule ( )
inline

Returns Module attached to this ModuleWidget, casted to the given Module type.

◆ setModule()

void rack::app::ModuleWidget::setModule ( engine::Module * module)

Associates this ModuleWidget with the Module.

Transfers ownership to this.

◆ getPanel()

widget::Widget * rack::app::ModuleWidget::getPanel ( )

◆ setPanel() [1/2]

void rack::app::ModuleWidget::setPanel ( widget::Widget * panel)

Sets the panel and sets the size of the ModuleWidget from the panel.

Transfers ownership.

◆ setPanel() [2/2]

void rack::app::ModuleWidget::setPanel ( std::shared_ptr< window::Svg > svg)

◆ addParam()

void rack::app::ModuleWidget::addParam ( ParamWidget * param)

Convenience functions for adding special widgets.

Just calls addChild() with additional checking. It is not required to call this method. You may instead use addChild() in a child widget for example.

◆ addInput()

void rack::app::ModuleWidget::addInput ( PortWidget * input)

◆ addOutput()

void rack::app::ModuleWidget::addOutput ( PortWidget * output)

◆ getParam()

ParamWidget * rack::app::ModuleWidget::getParam ( int paramId)

Scans children widgets recursively for a ParamWidget with the given paramId.

◆ getInput()

PortWidget * rack::app::ModuleWidget::getInput ( int portId)

◆ getOutput()

PortWidget * rack::app::ModuleWidget::getOutput ( int portId)

◆ getParams()

std::vector< ParamWidget * > rack::app::ModuleWidget::getParams ( )

Scans children widgets recursively for all ParamWidgets.

◆ getPorts()

std::vector< PortWidget * > rack::app::ModuleWidget::getPorts ( )

◆ getInputs()

std::vector< PortWidget * > rack::app::ModuleWidget::getInputs ( )

◆ getOutputs()

std::vector< PortWidget * > rack::app::ModuleWidget::getOutputs ( )

◆ draw()

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

◆ appendContextMenu()

virtual void rack::app::ModuleWidget::appendContextMenu ( ui::Menu * menu)
inlinevirtual

Override to add context menu entries to your subclass.

It is recommended to add a blank ui::MenuSeparator first for spacing.

◆ onHover()

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

Reimplemented from rack::widget::Widget.

◆ onHoverKey()

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

Reimplemented from rack::widget::Widget.

◆ onButton()

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

Reimplemented from rack::widget::Widget.

◆ onDragStart()

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

Reimplemented from rack::widget::Widget.

◆ onDragEnd()

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

Reimplemented from rack::widget::Widget.

◆ onDragMove()

void rack::app::ModuleWidget::onDragMove ( const DragMoveEvent & e)
overridevirtual

Reimplemented from rack::widget::Widget.

◆ onDragHover()

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

Reimplemented from rack::widget::Widget.

◆ toJson()

json_t * rack::app::ModuleWidget::toJson ( )

◆ fromJson()

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

◆ pasteJsonAction()

bool rack::app::ModuleWidget::pasteJsonAction ( json_t * rootJ)

Returns whether paste was successful.

◆ copyClipboard()

void rack::app::ModuleWidget::copyClipboard ( )

◆ pasteClipboardAction()

bool rack::app::ModuleWidget::pasteClipboardAction ( )

◆ load()

void rack::app::ModuleWidget::load ( std::string filename)

◆ loadAction()

void rack::app::ModuleWidget::loadAction ( std::string filename)

◆ loadTemplate()

void rack::app::ModuleWidget::loadTemplate ( )

◆ loadDialog()

void rack::app::ModuleWidget::loadDialog ( )

◆ save()

void rack::app::ModuleWidget::save ( std::string filename)

◆ saveTemplate()

void rack::app::ModuleWidget::saveTemplate ( )

◆ saveTemplateDialog()

void rack::app::ModuleWidget::saveTemplateDialog ( )

◆ hasTemplate()

bool rack::app::ModuleWidget::hasTemplate ( )

◆ clearTemplate()

void rack::app::ModuleWidget::clearTemplate ( )

◆ clearTemplateDialog()

void rack::app::ModuleWidget::clearTemplateDialog ( )

◆ saveDialog()

void rack::app::ModuleWidget::saveDialog ( )

◆ disconnect()

void rack::app::ModuleWidget::disconnect ( )

Disconnects cables from all ports Called when the user clicks Disconnect Cables in the context menu.

◆ resetAction()

void rack::app::ModuleWidget::resetAction ( )

Resets the parameters of the module and calls the Module's randomize().

Called when the user clicks Initialize in the context menu.

◆ randomizeAction()

void rack::app::ModuleWidget::randomizeAction ( )

Randomizes the parameters of the module and calls the Module's randomize().

Called when the user clicks Randomize in the context menu.

◆ appendDisconnectActions()

void rack::app::ModuleWidget::appendDisconnectActions ( history::ComplexAction * complexAction)

◆ disconnectAction()

void rack::app::ModuleWidget::disconnectAction ( )

◆ cloneAction()

void rack::app::ModuleWidget::cloneAction ( bool cloneCables = true)

◆ bypassAction()

void rack::app::ModuleWidget::bypassAction ( bool bypassed)

◆ removeAction()

void rack::app::ModuleWidget::removeAction ( )

Deletes this

◆ createContextMenu()

void rack::app::ModuleWidget::createContextMenu ( )

◆ getGridPosition()

math::Vec rack::app::ModuleWidget::getGridPosition ( )

◆ setGridPosition()

void rack::app::ModuleWidget::setGridPosition ( math::Vec pos)

◆ getGridSize()

math::Vec rack::app::ModuleWidget::getGridSize ( )

◆ getGridBox()

math::Rect rack::app::ModuleWidget::getGridBox ( )

◆ dragOffset()

PRIVATE math::Vec & rack::app::ModuleWidget::dragOffset ( )

◆ dragEnabled()

PRIVATE bool & rack::app::ModuleWidget::dragEnabled ( )

◆ releaseModule()

PRIVATE engine::Module * rack::app::ModuleWidget::releaseModule ( )

Member Data Documentation

◆ internal

Internal* rack::app::ModuleWidget::internal

◆ model

plugin::Model* rack::app::ModuleWidget::model = NULL

Not owned.


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