diff options
author | David Robillard <d@drobilla.net> | 2016-10-14 14:57:41 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-10-14 16:27:16 -0400 |
commit | 2e5df4c0d30fea03f0f3b176a449e17da5fc25f9 (patch) | |
tree | a0e136147bcadbf8c69dc3acf9f279402ef4f2e3 /src/gui/GraphCanvas.cpp | |
parent | c16ad68648812a8c4eb90e8666764959b166ac13 (diff) | |
download | ingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.tar.gz ingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.tar.bz2 ingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.zip |
Simplify port model code
Diffstat (limited to 'src/gui/GraphCanvas.cpp')
-rw-r--r-- | src/gui/GraphCanvas.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 7053b495..565f607e 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -405,6 +405,7 @@ GraphCanvas::get_port_view(SPtr<PortModel> port) return NULL; } +/** Called when a connection is added to the model. */ void GraphCanvas::connection(SPtr<const ArcModel> arc) { @@ -419,44 +420,49 @@ GraphCanvas::connection(SPtr<const ArcModel> arc) } } +/** Called when a connection is removed from the model. */ void GraphCanvas::disconnection(SPtr<const ArcModel> arc) { - Ganv::Port* const src = get_port_view(arc->tail()); - Ganv::Port* const dst = get_port_view(arc->head()); + Ganv::Port* const tail = get_port_view(arc->tail()); + Ganv::Port* const head = get_port_view(arc->head()); - if (src && dst) { - remove_edge_between(src, dst); + if (tail && head) { + remove_edge_between(tail, head); + if (arc->head()->is_a(_app.uris().lv2_AudioPort)) { + GUI::Port* const h = dynamic_cast<GUI::Port*>(head); + if (h) { + h->activity(_app.forge().make(0.0f)); // Reset peaks + } + } } else { _app.log().error(fmt("Unable to find ports to disconnect %1% => %2%\n") % arc->tail_path() % arc->head_path()); } } +/** Called when the user connects ports on the canvas. */ void -GraphCanvas::connect(Ganv::Node* tail, - Ganv::Node* head) +GraphCanvas::connect(Ganv::Node* tail, Ganv::Node* head) { - const Ingen::GUI::Port* const src - = dynamic_cast<Ingen::GUI::Port*>(tail); + const GUI::Port* const t = dynamic_cast<GUI::Port*>(tail); + const GUI::Port* const h = dynamic_cast<GUI::Port*>(head); - const Ingen::GUI::Port* const dst - = dynamic_cast<Ingen::GUI::Port*>(head); - - if (!src || !dst) - return; - - _app.interface()->connect(src->model()->path(), dst->model()->path()); + if (t && h) { + _app.interface()->connect(t->model()->path(), h->model()->path()); + } } +/** Called when the user disconnects ports on the canvas. */ void -GraphCanvas::disconnect(Ganv::Node* tail, - Ganv::Node* head) +GraphCanvas::disconnect(Ganv::Node* tail, Ganv::Node* head) { - const Ingen::GUI::Port* const t = dynamic_cast<Ingen::GUI::Port*>(tail); - const Ingen::GUI::Port* const h = dynamic_cast<Ingen::GUI::Port*>(head); + const GUI::Port* const t = dynamic_cast<GUI::Port*>(tail); + const GUI::Port* const h = dynamic_cast<GUI::Port*>(head); - _app.interface()->disconnect(t->model()->path(), h->model()->path()); + if (t && h) { + _app.interface()->disconnect(t->model()->path(), h->model()->path()); + } } void |