summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-10-14 14:57:41 -0400
committerDavid Robillard <d@drobilla.net>2016-10-14 16:27:16 -0400
commit2e5df4c0d30fea03f0f3b176a449e17da5fc25f9 (patch)
treea0e136147bcadbf8c69dc3acf9f279402ef4f2e3 /src
parentc16ad68648812a8c4eb90e8666764959b166ac13 (diff)
downloadingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.tar.gz
ingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.tar.bz2
ingen-2e5df4c0d30fea03f0f3b176a449e17da5fc25f9.zip
Simplify port model code
Diffstat (limited to 'src')
-rw-r--r--src/client/ClientStore.cpp17
-rw-r--r--src/client/PortModel.cpp1
-rw-r--r--src/gui/GraphCanvas.cpp46
-rw-r--r--src/gui/Port.cpp10
-rw-r--r--src/gui/Port.hpp1
5 files changed, 28 insertions, 47 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index e99f9c73..d69992fe 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -435,10 +435,6 @@ ClientStore::attempt_connection(const Raul::Path& tail_path,
if (tail && head) {
SPtr<GraphModel> graph = connection_graph(tail_path, head_path);
SPtr<ArcModel> arc(new ArcModel(tail, head));
-
- tail->connected_to(head);
- head->connected_to(tail);
-
graph->add_arc(arc);
return true;
} else {
@@ -459,15 +455,8 @@ void
ClientStore::disconnect(const Raul::Path& src_path,
const Raul::Path& dst_path)
{
- SPtr<PortModel> tail = dynamic_ptr_cast<PortModel>(_object(src_path));
- SPtr<PortModel> head = dynamic_ptr_cast<PortModel>(_object(dst_path));
-
- if (tail)
- tail->disconnected_from(head);
-
- if (head)
- head->disconnected_from(tail);
-
+ SPtr<PortModel> tail = dynamic_ptr_cast<PortModel>(_object(src_path));
+ SPtr<PortModel> head = dynamic_ptr_cast<PortModel>(_object(dst_path));
SPtr<GraphModel> graph = connection_graph(src_path, dst_path);
if (graph)
graph->remove_arc(tail.get(), head.get());
@@ -493,8 +482,6 @@ ClientStore::disconnect_all(const Raul::Path& parent_graph,
|| arc->head()->parent() == object
|| arc->tail()->path() == path
|| arc->head()->path() == path) {
- arc->tail()->disconnected_from(arc->head());
- arc->head()->disconnected_from(arc->tail());
graph->remove_arc(arc->tail().get(), arc->head().get());
}
}
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 9b534ae1..7e5456dd 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -70,7 +70,6 @@ PortModel::set(SPtr<ObjectModel> model)
if (port) {
_index = port->_index;
_direction = port->_direction;
- _connections = port->_connections;
_signal_value_changed.emit(get_property(_uris.ingen_value));
}
}
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
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 9a20a8b8..c1947fea 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -81,8 +81,6 @@ Port::Port(App& app,
sigc::mem_fun(this, &Port::property_removed));
pm->signal_activity().connect(
sigc::mem_fun(this, &Port::activity));
- pm->signal_disconnection().connect(
- sigc::mem_fun(this, &Port::disconnected_from));
pm->signal_moved().connect(
sigc::mem_fun(this, &Port::moved));
@@ -371,14 +369,6 @@ Port::activity(const Atom& value)
}
}
-void
-Port::disconnected_from(SPtr<PortModel> port)
-{
- if (!model()->connected() && model()->is_a(_app.uris().lv2_AudioPort)) {
- set_fill_color(peak_color(0.0f));
- }
-}
-
GraphBox*
Port::get_graph_box() const
{
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index a9549160..5f683412 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -62,7 +62,6 @@ public:
void value_changed(const Atom& value);
void activity(const Atom& value);
- void disconnected_from(SPtr<Client::PortModel> port);
bool on_selected(gboolean b);