VCV Rack API v2
Loading...
Searching...
No Matches
RackWidget.hpp
Go to the documentation of this file.
1#pragma once
2#include <app/common.hpp>
5#include <ui/Menu.hpp>
6#include <app/RailWidget.hpp>
8#include <app/CableWidget.hpp>
9#include <app/PortWidget.hpp>
10#include <app/ParamWidget.hpp>
11#include <history.hpp>
12
13#include <set>
14
15
16namespace rack {
17namespace app {
18
19
22 struct Internal;
23 Internal* internal;
24
27
30
31 void step() override;
32 void draw(const DrawArgs& args) override;
33
34 void onHover(const HoverEvent& e) override;
35 void onHoverKey(const HoverKeyEvent& e) override;
36 void onButton(const ButtonEvent& e) override;
37 void onDragStart(const DragStartEvent& e) override;
38 void onDragEnd(const DragEndEvent& e) override;
39 void onDragHover(const DragHoverEvent& e) override;
40
41 // Rack methods
42
46
48 void clear();
49 void mergeJson(json_t* rootJ);
50 void fromJson(json_t* rootJ);
52 void pasteJsonAction(json_t* rootJ);
53 void pasteModuleJsonAction(json_t* moduleJ);
55
56 // Module methods
57
65 ModuleWidget* getModule(int64_t moduleId);
66 std::vector<ModuleWidget*> getModules();
67 bool hasModules();
68
69 // Module position methods
70
84
85 // Module selection methods
86
88 void selectAll();
90 void select(ModuleWidget* mw, bool selected = true);
92 const std::set<ModuleWidget*>& getSelected();
94 json_t* selectionToJson(bool cables = true);
95 void loadSelection(std::string path);
97 void saveSelection(std::string path);
103 void cloneSelectionAction(bool cloneCables = true);
104 void bypassSelectionAction(bool bypassed);
110
111 // Cable methods
112
129 CableWidget* getCable(int64_t cableId);
130 CableWidget* getCable(PortWidget* outputPort, PortWidget* inputPort);
131 std::vector<CableWidget*> getCompleteCables();
133 std::vector<CableWidget*> getCablesOnPort(PortWidget* port);
134 std::vector<CableWidget*> getCompleteCablesOnPort(PortWidget* port);
142
144};
145
146
147} // namespace app
148} // namespace rack
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:30
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
Definition CableWidget.hpp:16
Manages an engine::Module in the rack.
Definition ModuleWidget.hpp:17
Manages an engine::Param on a ModuleWidget.
Definition ParamWidget.hpp:14
Manages an engine::Port on a ModuleWidget.
Definition PortWidget.hpp:14
Container for ModuleWidget and CableWidget.
Definition RackWidget.hpp:21
PRIVATE void unsqueezeModulePos(ModuleWidget *mw)
void pasteModuleJsonAction(json_t *moduleJ)
bool requestSelectionPos(math::Vec delta)
Internal * internal
Definition RackWidget.hpp:23
PRIVATE void squeezeModulePos(ModuleWidget *mw, math::Vec pos)
history::ComplexAction * getModuleDragAction()
void setNextCableColorId(int id)
void cloneSelectionAction(bool cloneCables=true)
math::Vec getMousePos()
CableWidget * getIncompleteCable()
void pasteJsonAction(json_t *rootJ)
Pastes module JSON or selection JSON at the mouse position.
void clear()
Completely clear the rack's modules and cables.
std::vector< CableWidget * > getCablesOnPort(PortWidget *port)
Returns all cables attached to port, complete or not.
void step() override
Advances the module by one frame.
void setModulePosNearest(ModuleWidget *mw, math::Vec pos)
Moves a module to the closest non-colliding position.
const std::set< ModuleWidget * > & getSelected()
void setSelectionPosNearest(math::Vec delta)
ModuleWidget * getModule(int64_t moduleId)
void bypassSelectionAction(bool bypassed)
CableWidget * releaseIncompleteCable()
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,...
void setIncompleteCable(CableWidget *cw)
Takes ownership of cw and adds it as a child if it isn't already.
CableWidget * getCable(PortWidget *outputPort, PortWidget *inputPort)
void onHoverKey(const HoverKeyEvent &e) override
void onHover(const HoverEvent &e) override
void onButton(const ButtonEvent &e) override
void mergeJson(json_t *rootJ)
void onDragHover(const DragHoverEvent &e) override
void draw(const DrawArgs &args) override
Draws the widget to the NanoVG context.
ParamWidget * touchedParam
DEPRECATED.
Definition RackWidget.hpp:26
CableWidget * getTopCable(PortWidget *port)
Returns the most recently added complete cable connected to the given Port, i.e.
void removeModule(ModuleWidget *mw)
Removes the module and transfers ownership to the caller.
void addModuleAtMouse(ModuleWidget *mw)
void setTouchedParam(ParamWidget *pw)
bool isSelected(ModuleWidget *mw)
bool requestModulePos(ModuleWidget *mw, math::Vec pos)
Sets a module's box if non-colliding.
void addCable(CableWidget *cw)
Adds a complete cable and adopts ownership.
ParamWidget * getTouchedParam()
std::vector< CableWidget * > getCompleteCablesOnPort(PortWidget *port)
void appendSelectionContextMenu(ui::Menu *menu)
void setModulePosSqueeze(ModuleWidget *mw, math::Vec pos)
Moves a module, contracting old module positions and pushing modules to the right as needed to fit.
json_t * selectionToJson(bool cables=true)
void onDragStart(const DragStartEvent &e) override
void select(ModuleWidget *mw, bool selected=true)
widget::Widget * getModuleContainer()
void fromJson(json_t *rootJ)
PRIVATE void updateExpanders()
void updateModuleOldPositions()
Saves positions of modules for getModuleDragAction().
std::vector< ModuleWidget * > getModules()
void onDragEnd(const DragEndEvent &e) override
std::vector< CableWidget * > getCompleteCables()
void saveSelection(std::string path)
void loadSelection(std::string path)
void disconnectSelectionAction()
void clearCablesOnPort(PortWidget *port)
Removes all cables connected to the port.
CableWidget * getCable(int64_t cableId)
void addModule(ModuleWidget *mw)
Adds a module and adds it to the Engine, adopting ownership.
int getNextCableColorId()
Returns but does not advance the next cable color.
void removeCable(CableWidget *cw)
Removes cable and releases ownership to caller.
widget::Widget * getCableContainer()
NVGcolor getNextCableColor()
Returns and advances the next cable color.
Batches multiple actions into one.
Definition history.hpp:52
2-dimensional vector of floats, representing a point on the plane for graphics.
Definition math.hpp:189
Definition Menu.hpp:11
A Widget that stops propagation of all recursive PositionEvents (such as ButtonEvent) but gives a cha...
Definition OpaqueWidget.hpp:12
Occurs each mouse button press or release.
Definition Widget.hpp:237
Occurs when a Widget stops being dragged by releasing the mouse button.
Definition Widget.hpp:375
Occurs every frame when the mouse is hovering over a Widget while another Widget (possibly the same o...
Definition Widget.hpp:391
Occurs when a Widget begins being dragged.
Definition Widget.hpp:369
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
A node in the 2D scene graph.
Definition Widget.hpp:21