VCV Rack API v2
Loading...
Searching...
No Matches
CableWidget.hpp
Go to the documentation of this file.
1#pragma once
2#include <map>
3#include <app/common.hpp>
4#include <widget/Widget.hpp>
5#include <app/PortWidget.hpp>
6#include <engine/Cable.hpp>
7
8
9namespace rack {
10namespace app {
11
12
13struct CableWidget;
14
15
17 struct Internal;
18 Internal* internal;
19
22 void step() override;
23 PRIVATE void setColor(NVGcolor color);
24 PRIVATE void setAngle(float angle);
25 PRIVATE void setTop(bool top);
28};
29
30
32 struct Internal;
33 Internal* internal;
34
37 NVGcolor color;
40
45
49 bool isComplete();
69 void mergeJson(json_t* rootJ);
70 void fromJson(json_t* rootJ);
71 void step() override;
72 void draw(const DrawArgs& args) override;
73 void drawLayer(const DrawArgs& args, int layer) override;
75 void onAdd(const AddEvent& e) override;
76 void onRemove(const RemoveEvent& e) override;
77};
78
79
80} // namespace app
81} // namespace rack
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:32
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
Definition CableWidget.hpp:31
void fromJson(json_t *rootJ)
PlugWidget * outputPlug
Definition CableWidget.hpp:39
Internal * internal
Definition CableWidget.hpp:33
void onAdd(const AddEvent &e) override
void step() override
Advances the module by one frame.
void drawLayer(const DrawArgs &args, int layer) override
Draw additional layers.
PortWidget *& getPort(engine::Port::Type type)
Definition CableWidget.hpp:61
math::Vec getOutputPos()
bool isComplete()
Returns whether cable is connected to 2 ports.
PortWidget * outputPort
Definition CableWidget.hpp:42
PortWidget * hoveredInputPort
Definition CableWidget.hpp:43
engine::Cable * releaseCable()
PortWidget * inputPort
Definition CableWidget.hpp:41
PlugWidget * inputPlug
Definition CableWidget.hpp:38
PortWidget *& getHoveredPort(engine::Port::Type type)
Definition CableWidget.hpp:64
NVGcolor color
Definition CableWidget.hpp:37
PortWidget * hoveredOutputPort
Definition CableWidget.hpp:44
void updateCable()
Based on the input/output ports, re-creates the cable and removes/adds it to the Engine.
void mergeJson(json_t *rootJ)
void onRemove(const RemoveEvent &e) override
engine::Cable * getCable()
PlugWidget *& getPlug(engine::Port::Type type)
Definition CableWidget.hpp:58
void setCable(engine::Cable *cable)
From a cable, sets the input/output ports.
engine::Cable * cable
Owned.
Definition CableWidget.hpp:36
void draw(const DrawArgs &args) override
Draws the widget to the NanoVG context.
Definition CableWidget.hpp:16
CableWidget * getCable()
PRIVATE void setTop(bool top)
void step() override
Advances the module by one frame.
engine::Port::Type getType()
Internal * internal
Definition CableWidget.hpp:18
PRIVATE void setColor(NVGcolor color)
PRIVATE void setAngle(float angle)
Manages an engine::Port on a ModuleWidget.
Definition PortWidget.hpp:14
Definition Cable.hpp:10
Type
Definition Port.hpp:37
@ INPUT
Definition Port.hpp:38
2-dimensional vector of floats, representing a point on the plane for graphics.
Definition math.hpp:189
Occurs after a Widget is added to a parent.
Definition Widget.hpp:474
Definition Widget.hpp:141
Occurs before a Widget is removed from its parent.
Definition Widget.hpp:479
A node in the 2D scene graph.
Definition Widget.hpp:21