diff options
author | David Robillard <d@drobilla.net> | 2020-11-28 12:32:24 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-28 12:45:57 +0100 |
commit | db5d1f603e0dd3076444f27008fcf1a61a4e151c (patch) | |
tree | 78af24e87c81e54fab14a59389adea859577f49e /src/PatchageCanvas.hpp | |
parent | 0ae4276ac187a9a361950f26bd67eb2d54636aff (diff) | |
download | patchage-db5d1f603e0dd3076444f27008fcf1a61a4e151c.tar.gz patchage-db5d1f603e0dd3076444f27008fcf1a61a4e151c.tar.bz2 patchage-db5d1f603e0dd3076444f27008fcf1a61a4e151c.zip |
Factor out Connector from PatchageCanvas
This finally breaks the dependency of the canvas on the entire application, and
fixes the confusing situation where it wasn't clear whether connect/disconnect
methods made/broke connections on the canvas or on the system.
Diffstat (limited to 'src/PatchageCanvas.hpp')
-rw-r--r-- | src/PatchageCanvas.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 40ec51c..349512b 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -36,14 +36,14 @@ PATCHAGE_RESTORE_WARNINGS #include <string> #include <utility> -class Patchage; class PatchageModule; class PatchagePort; +class Connector; class PatchageCanvas : public Ganv::Canvas { public: - PatchageCanvas(Patchage* _app, int width, int height); + PatchageCanvas(Connector& connector, int width, int height); PatchageModule* find_module(const std::string& name, ModuleType type); PatchagePort* find_port(const PortID& id); @@ -54,10 +54,6 @@ public: PatchagePort* find_port_by_name(const std::string& client_name, const std::string& port_name); - void connect(Ganv::Node* port1, Ganv::Node* port2); - - void disconnect(Ganv::Node* port1, Ganv::Node* port2); - void index_port(const PortID& id, PatchagePort* port) { _port_index.insert(std::make_pair(id, port)); @@ -77,10 +73,15 @@ private: using PortIndex = std::map<const PortID, PatchagePort*>; using ModuleIndex = std::multimap<const std::string, PatchageModule*>; + friend void disconnect_edge(GanvEdge*, void*); + bool on_event(GdkEvent* ev); bool on_connection_event(Ganv::Edge* c, GdkEvent* ev); - Patchage* _app; + void on_connect(Ganv::Node* port1, Ganv::Node* port2); + void on_disconnect(Ganv::Node* port1, Ganv::Node* port2); + + Connector& _connector; PortIndex _port_index; ModuleIndex _module_index; }; |