easy splice-between for single-input node types
parent
4cbde894c4
commit
cbce51744c
3
notes
3
notes
|
@ -37,8 +37,7 @@ TODO {
|
|||
|
||||
revert-to-saved menu action
|
||||
|
||||
- ringmod (easy!)
|
||||
splice-between behavior when trying to hook up a command input to something with both a command input and output while already connected
|
||||
- splice-between behavior when trying to hook up a command input to something with both a command input and output while already connected
|
||||
|
||||
distortion effect
|
||||
|
||||
|
|
|
@ -48,6 +48,20 @@ void PortObject::connectTo(PortObject* o) {
|
|||
if (port->type == Port::Input) { in = this; out = o; }
|
||||
else { out = this; in = o; }
|
||||
|
||||
// splice-between logic
|
||||
auto dt = port->dataType();
|
||||
if (in->port->type == Port::Input && in->port->singleInput() && in->port->isConnected() && out->port->dataType() == dt) {
|
||||
if (auto oi = out->port->owner.lock()->port(Port::Input, dt, 0); oi) {
|
||||
auto c = in->port->connections[0].lock();
|
||||
if (!oi->isConnected() || oi->connections[0].lock() == in->port->connections[0].lock()) {
|
||||
if (auto pc = in->connections[c->obj]; pc) delete pc;
|
||||
in->port->disconnect(c);
|
||||
|
||||
if (!oi->isConnected() && oi->connect(c)) new PortConnectionObject(oi->obj, c->obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (out->port->connect(in->port)) {
|
||||
/*auto* pc =*/ new PortConnectionObject(in, out);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue