easy splice-between for single-input node types

master
zetaPRIME 2022-03-22 17:49:01 -04:00
parent 4cbde894c4
commit cbce51744c
2 changed files with 15 additions and 2 deletions

3
notes
View File

@ -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

View File

@ -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);
}