diff options
-rw-r--r-- | src/Canvas.cpp (renamed from src/PatchageCanvas.cpp) | 112 | ||||
-rw-r--r-- | src/Canvas.hpp (renamed from src/PatchageCanvas.hpp) | 36 | ||||
-rw-r--r-- | src/CanvasModule.cpp (renamed from src/PatchageModule.cpp) | 53 | ||||
-rw-r--r-- | src/CanvasModule.hpp (renamed from src/PatchageModule.hpp) | 28 | ||||
-rw-r--r-- | src/CanvasPort.hpp (renamed from src/PatchagePort.hpp) | 42 | ||||
-rw-r--r-- | src/Driver.hpp | 4 | ||||
-rw-r--r-- | src/Event.hpp (renamed from src/PatchageEvent.hpp) | 16 | ||||
-rw-r--r-- | src/JackDbusDriver.cpp | 2 | ||||
-rw-r--r-- | src/JackLibDriver.cpp | 2 | ||||
-rw-r--r-- | src/Patchage.cpp | 48 | ||||
-rw-r--r-- | src/Patchage.hpp | 14 | ||||
-rw-r--r-- | src/event_to_string.cpp | 6 | ||||
-rw-r--r-- | src/event_to_string.hpp | 6 | ||||
-rw-r--r-- | src/handle_event.cpp | 18 | ||||
-rw-r--r-- | src/handle_event.hpp | 4 | ||||
-rw-r--r-- | wscript | 4 |
16 files changed, 194 insertions, 201 deletions
diff --git a/src/PatchageCanvas.cpp b/src/Canvas.cpp index 0fc0ebe..a3d3a89 100644 --- a/src/PatchageCanvas.cpp +++ b/src/Canvas.cpp @@ -14,14 +14,14 @@ * along with Patchage. If not, see <http://www.gnu.org/licenses/>. */ -#include "PatchageCanvas.hpp" +#include "Canvas.hpp" #include "patchage_config.h" +#include "CanvasModule.hpp" +#include "CanvasPort.hpp" #include "Connector.hpp" #include "Patchage.hpp" -#include "PatchageModule.hpp" -#include "PatchagePort.hpp" #include "PortNames.hpp" #include "SignalDirection.hpp" #include "warnings.hpp" @@ -39,20 +39,19 @@ PATCHAGE_RESTORE_WARNINGS namespace patchage { -PatchageCanvas::PatchageCanvas(Connector& connector, int width, int height) +Canvas::Canvas(Connector& connector, int width, int height) : Ganv::Canvas(width, height) , _connector(connector) { - signal_event.connect(sigc::mem_fun(this, &PatchageCanvas::on_event)); - signal_connect.connect(sigc::mem_fun(this, &PatchageCanvas::on_connect)); - signal_disconnect.connect( - sigc::mem_fun(this, &PatchageCanvas::on_disconnect)); + signal_event.connect(sigc::mem_fun(this, &Canvas::on_event)); + signal_connect.connect(sigc::mem_fun(this, &Canvas::on_connect)); + signal_disconnect.connect(sigc::mem_fun(this, &Canvas::on_disconnect)); } -PatchageModule* -PatchageCanvas::create_module(Patchage& patchage, - const ClientID& id, - const ClientInfo& info) +CanvasModule* +Canvas::create_module(Patchage& patchage, + const ClientID& id, + const ClientInfo& info) { (void)patchage; (void)id; @@ -60,10 +59,8 @@ PatchageCanvas::create_module(Patchage& patchage, return nullptr; } -PatchagePort* -PatchageCanvas::create_port(Patchage& patchage, - const PortID& id, - const PortInfo& info) +CanvasPort* +Canvas::create_port(Patchage& patchage, const PortID& id, const PortInfo& info) { const auto client_id = id.client(); @@ -95,10 +92,10 @@ PatchageCanvas::create_port(Patchage& patchage, } // Find or create parent module - PatchageModule* parent = find_module(client_id, module_type); + CanvasModule* parent = find_module(client_id, module_type); if (!parent) { parent = - new PatchageModule(&patchage, client_name, module_type, client_id); + new CanvasModule(&patchage, client_name, module_type, client_id); parent->load_location(); add_module(client_id, parent); @@ -111,28 +108,27 @@ PatchageCanvas::create_port(Patchage& patchage, return nullptr; } - auto* const port = - new PatchagePort(*parent, - info.type, - id, - port_name, - info.label, - info.direction == SignalDirection::input, - patchage.conf().get_port_color(info.type), - patchage.show_human_names(), - info.order); + auto* const port = new CanvasPort(*parent, + info.type, + id, + port_name, + info.label, + info.direction == SignalDirection::input, + patchage.conf().get_port_color(info.type), + patchage.show_human_names(), + info.order); index_port(id, port); return port; } -PatchageModule* -PatchageCanvas::find_module(const ClientID& id, const SignalDirection type) +CanvasModule* +Canvas::find_module(const ClientID& id, const SignalDirection type) { auto i = _module_index.find(id); - PatchageModule* io_module = nullptr; + CanvasModule* io_module = nullptr; for (; i != _module_index.end() && i->first == id; ++i) { if (i->second->type() == type) { return i->second; @@ -148,19 +144,19 @@ PatchageCanvas::find_module(const ClientID& id, const SignalDirection type) } void -PatchageCanvas::remove_module(const ClientID& id) +Canvas::remove_module(const ClientID& id) { auto i = _module_index.find(id); while (i != _module_index.end()) { - PatchageModule* mod = i->second; + CanvasModule* mod = i->second; _module_index.erase(i); i = _module_index.find(id); delete mod; } } -PatchagePort* -PatchageCanvas::find_port(const PortID& id) +CanvasPort* +Canvas::find_port(const PortID& id) { auto i = _port_index.find(id); if (i != _port_index.end()) { @@ -172,30 +168,30 @@ PatchageCanvas::find_port(const PortID& id) } void -PatchageCanvas::remove_port(const PortID& id) +Canvas::remove_port(const PortID& id) { - PatchagePort* const port = find_port(id); + CanvasPort* const port = find_port(id); _port_index.erase(id); delete port; } struct RemovePortsData { - using Predicate = bool (*)(const PatchagePort*); + using Predicate = bool (*)(const CanvasPort*); explicit RemovePortsData(Predicate p) : pred(p) {} - Predicate pred; - std::set<PatchageModule*> empty; + Predicate pred; + std::set<CanvasModule*> empty; }; static void delete_port_if_matches(GanvPort* port, void* cdata) { auto* data = static_cast<RemovePortsData*>(cdata); - auto* pport = dynamic_cast<PatchagePort*>(Glib::wrap(port)); + auto* pport = dynamic_cast<CanvasPort*>(Glib::wrap(port)); if (pport && data->pred(pport)) { delete pport; } @@ -209,7 +205,7 @@ remove_ports_matching(GanvNode* node, void* cdata) } Ganv::Module* cmodule = Glib::wrap(GANV_MODULE(node)); - auto* pmodule = dynamic_cast<PatchageModule*>(cmodule); + auto* pmodule = dynamic_cast<CanvasModule*>(cmodule); if (!pmodule) { return; } @@ -224,7 +220,7 @@ remove_ports_matching(GanvNode* node, void* cdata) } void -PatchageCanvas::remove_ports(bool (*pred)(const PatchagePort*)) +Canvas::remove_ports(bool (*pred)(const CanvasPort*)) { RemovePortsData data(pred); @@ -239,16 +235,16 @@ PatchageCanvas::remove_ports(bool (*pred)(const PatchagePort*)) i = next; } - for (PatchageModule* m : data.empty) { + for (CanvasModule* m : data.empty) { delete m; } } void -PatchageCanvas::on_connect(Ganv::Node* port1, Ganv::Node* port2) +Canvas::on_connect(Ganv::Node* port1, Ganv::Node* port2) { - auto* const p1 = dynamic_cast<PatchagePort*>(port1); - auto* const p2 = dynamic_cast<PatchagePort*>(port2); + auto* const p1 = dynamic_cast<CanvasPort*>(port1); + auto* const p2 = dynamic_cast<CanvasPort*>(port2); if (p1 && p2) { if (p1->is_output() && p2->is_input()) { @@ -260,10 +256,10 @@ PatchageCanvas::on_connect(Ganv::Node* port1, Ganv::Node* port2) } void -PatchageCanvas::on_disconnect(Ganv::Node* port1, Ganv::Node* port2) +Canvas::on_disconnect(Ganv::Node* port1, Ganv::Node* port2) { - auto* const p1 = dynamic_cast<PatchagePort*>(port1); - auto* const p2 = dynamic_cast<PatchagePort*>(port2); + auto* const p1 = dynamic_cast<CanvasPort*>(port1); + auto* const p2 = dynamic_cast<CanvasPort*>(port2); if (p1 && p2) { if (p1->is_output() && p2->is_input()) { @@ -275,13 +271,13 @@ PatchageCanvas::on_disconnect(Ganv::Node* port1, Ganv::Node* port2) } void -PatchageCanvas::add_module(const ClientID& id, PatchageModule* module) +Canvas::add_module(const ClientID& id, CanvasModule* module) { _module_index.emplace(id, module); // Join partners, if applicable - PatchageModule* in_module = nullptr; - PatchageModule* out_module = nullptr; + CanvasModule* in_module = nullptr; + CanvasModule* out_module = nullptr; if (module->type() == SignalDirection::input) { in_module = module; out_module = find_module(id, SignalDirection::output); @@ -298,13 +294,13 @@ PatchageCanvas::add_module(const ClientID& id, PatchageModule* module) void disconnect_edge(GanvEdge* edge, void* data) { - auto* canvas = static_cast<PatchageCanvas*>(data); + auto* canvas = static_cast<Canvas*>(data); Ganv::Edge* edgemm = Glib::wrap(edge); canvas->on_disconnect(edgemm->get_tail(), edgemm->get_head()); } bool -PatchageCanvas::on_event(GdkEvent* ev) +Canvas::on_event(GdkEvent* ev) { if (ev->type == GDK_KEY_PRESS && ev->key.keyval == GDK_Delete) { for_each_selected_edge(disconnect_edge, this); @@ -316,14 +312,14 @@ PatchageCanvas::on_event(GdkEvent* ev) } bool -PatchageCanvas::make_connection(Ganv::Node* tail, Ganv::Node* head) +Canvas::make_connection(Ganv::Node* tail, Ganv::Node* head) { new Ganv::Edge(*this, tail, head); return true; } void -PatchageCanvas::remove_module(PatchageModule* module) +Canvas::remove_module(CanvasModule* module) { // Remove module from cache for (auto i = _module_index.find(module->id()); @@ -337,7 +333,7 @@ PatchageCanvas::remove_module(PatchageModule* module) } void -PatchageCanvas::clear() +Canvas::clear() { _port_index.clear(); _module_index.clear(); diff --git a/src/PatchageCanvas.hpp b/src/Canvas.hpp index b823727..cf27155 100644 --- a/src/PatchageCanvas.hpp +++ b/src/Canvas.hpp @@ -19,8 +19,8 @@ #include "patchage_config.h" -#include "PatchageEvent.hpp" -#include "PatchageModule.hpp" +#include "CanvasModule.hpp" +#include "Event.hpp" #include "PortID.hpp" #include "warnings.hpp" @@ -35,36 +35,36 @@ PATCHAGE_RESTORE_WARNINGS namespace patchage { class Patchage; -class PatchageModule; -class PatchagePort; +class CanvasModule; +class CanvasPort; class Connector; -class PatchageCanvas : public Ganv::Canvas +class Canvas : public Ganv::Canvas { public: - PatchageCanvas(Connector& connector, int width, int height); + Canvas(Connector& connector, int width, int height); - PatchageModule* create_module(Patchage& patchage, - const ClientID& id, - const ClientInfo& info); + CanvasModule* create_module(Patchage& patchage, + const ClientID& id, + const ClientInfo& info); - PatchagePort* + CanvasPort* create_port(Patchage& patchage, const PortID& id, const PortInfo& info); - PatchageModule* find_module(const ClientID& id, SignalDirection type); - PatchagePort* find_port(const PortID& id); + CanvasModule* find_module(const ClientID& id, SignalDirection type); + CanvasPort* find_port(const PortID& id); void remove_module(const ClientID& id); - void remove_module(PatchageModule* module); + void remove_module(CanvasModule* module); - void index_port(const PortID& id, PatchagePort* port) + void index_port(const PortID& id, CanvasPort* port) { _port_index.insert(std::make_pair(id, port)); } - void remove_ports(bool (*pred)(const PatchagePort*)); + void remove_ports(bool (*pred)(const CanvasPort*)); - void add_module(const ClientID& id, PatchageModule* module); + void add_module(const ClientID& id, CanvasModule* module); bool make_connection(Ganv::Node* tail, Ganv::Node* head); @@ -73,8 +73,8 @@ public: void clear() override; private: - using PortIndex = std::map<const PortID, PatchagePort*>; - using ModuleIndex = std::multimap<const ClientID, PatchageModule*>; + using PortIndex = std::map<const PortID, CanvasPort*>; + using ModuleIndex = std::multimap<const ClientID, CanvasModule*>; friend void disconnect_edge(GanvEdge*, void*); diff --git a/src/PatchageModule.cpp b/src/CanvasModule.cpp index 1931b3b..c049346 100644 --- a/src/PatchageModule.cpp +++ b/src/CanvasModule.cpp @@ -14,21 +14,21 @@ * along with Patchage. If not, see <http://www.gnu.org/licenses/>. */ -#include "PatchageModule.hpp" +#include "CanvasModule.hpp" +#include "Canvas.hpp" +#include "CanvasPort.hpp" #include "Patchage.hpp" -#include "PatchageCanvas.hpp" -#include "PatchagePort.hpp" #include "SignalDirection.hpp" namespace patchage { -PatchageModule::PatchageModule(Patchage* app, - const std::string& name, - SignalDirection type, - ClientID id, - double x, - double y) +CanvasModule::CanvasModule(Patchage* app, + const std::string& name, + SignalDirection type, + ClientID id, + double x, + double y) : Module(*app->canvas(), name, x, y) , _app(app) , _menu(nullptr) @@ -36,16 +36,15 @@ PatchageModule::PatchageModule(Patchage* app, , _type(type) , _id(std::move(id)) { - signal_event().connect(sigc::mem_fun(this, &PatchageModule::on_event)); + signal_event().connect(sigc::mem_fun(this, &CanvasModule::on_event)); - signal_moved().connect( - sigc::mem_fun(this, &PatchageModule::store_location)); + signal_moved().connect(sigc::mem_fun(this, &CanvasModule::store_location)); // Set as source by default, turned off if input ports added set_is_source(true); } -PatchageModule::~PatchageModule() +CanvasModule::~CanvasModule() { _app->canvas()->remove_module(this); delete _menu; @@ -53,7 +52,7 @@ PatchageModule::~PatchageModule() } void -PatchageModule::update_menu() +CanvasModule::update_menu() { if (!_menu) { return; @@ -79,28 +78,28 @@ PatchageModule::update_menu() } bool -PatchageModule::show_menu(GdkEventButton* ev) +CanvasModule::show_menu(GdkEventButton* ev) { _menu = new Gtk::Menu(); Gtk::Menu::MenuList& items = _menu->items(); if (_type == SignalDirection::duplex) { items.push_back(Gtk::Menu_Helpers::MenuElem( - "_Split", sigc::mem_fun(this, &PatchageModule::split))); + "_Split", sigc::mem_fun(this, &CanvasModule::split))); update_menu(); } else { items.push_back(Gtk::Menu_Helpers::MenuElem( - "_Join", sigc::mem_fun(this, &PatchageModule::join))); + "_Join", sigc::mem_fun(this, &CanvasModule::join))); } items.push_back(Gtk::Menu_Helpers::MenuElem( "_Disconnect All", - sigc::mem_fun(this, &PatchageModule::menu_disconnect_all))); + sigc::mem_fun(this, &CanvasModule::menu_disconnect_all))); _menu->popup(ev->button, ev->time); return true; } bool -PatchageModule::on_event(GdkEvent* ev) +CanvasModule::on_event(GdkEvent* ev) { if (ev->type == GDK_BUTTON_PRESS && ev->button.button == 3) { return show_menu(&ev->button); @@ -109,7 +108,7 @@ PatchageModule::on_event(GdkEvent* ev) } void -PatchageModule::load_location() +CanvasModule::load_location() { Coord loc; @@ -121,13 +120,13 @@ PatchageModule::load_location() } void -PatchageModule::store_location(double x, double y) +CanvasModule::store_location(double x, double y) { _app->conf().set_module_location(_name, _type, {x, y}); } void -PatchageModule::split() +CanvasModule::split() { assert(_type == SignalDirection::duplex); _app->conf().set_module_split(_name, true); @@ -135,7 +134,7 @@ PatchageModule::split() } void -PatchageModule::join() +CanvasModule::join() { assert(_type != SignalDirection::duplex); _app->conf().set_module_split(_name, false); @@ -143,18 +142,18 @@ PatchageModule::join() } void -PatchageModule::menu_disconnect_all() +CanvasModule::menu_disconnect_all() { for (Ganv::Port* p : *this) { p->disconnect(); } } -PatchagePort* -PatchageModule::get_port(const PortID& id) +CanvasPort* +CanvasModule::get_port(const PortID& id) { for (Ganv::Port* p : *this) { - auto* pport = dynamic_cast<PatchagePort*>(p); + auto* pport = dynamic_cast<CanvasPort*>(p); if (pport && pport->id() == id) { return pport; } diff --git a/src/PatchageModule.hpp b/src/CanvasModule.hpp index 378f35ed..c5ed699 100644 --- a/src/PatchageModule.hpp +++ b/src/CanvasModule.hpp @@ -34,26 +34,26 @@ namespace patchage { struct PortID; +class CanvasPort; class Patchage; -class PatchagePort; -class PatchageModule : public Ganv::Module +class CanvasModule : public Ganv::Module { public: - PatchageModule(Patchage* app, - const std::string& name, - SignalDirection type, - ClientID id, - double x = 0, - double y = 0); + CanvasModule(Patchage* app, + const std::string& name, + SignalDirection type, + ClientID id, + double x = 0, + double y = 0); - PatchageModule(const PatchageModule&) = delete; - PatchageModule& operator=(const PatchageModule&) = delete; + CanvasModule(const CanvasModule&) = delete; + CanvasModule& operator=(const CanvasModule&) = delete; - PatchageModule(PatchageModule&&) = delete; - PatchageModule& operator=(PatchageModule&&) = delete; + CanvasModule(CanvasModule&&) = delete; + CanvasModule& operator=(CanvasModule&&) = delete; - ~PatchageModule() override; + ~CanvasModule() override; void split(); void join(); @@ -61,7 +61,7 @@ public: bool show_menu(GdkEventButton* ev); void update_menu(); - PatchagePort* get_port(const PortID& id); + CanvasPort* get_port(const PortID& id); void load_location(); void menu_disconnect_all(); diff --git a/src/PatchagePort.hpp b/src/CanvasPort.hpp index 0ef6752..5bd581c 100644 --- a/src/PatchagePort.hpp +++ b/src/CanvasPort.hpp @@ -17,9 +17,9 @@ #ifndef PATCHAGE_PATCHAGEPORT_HPP #define PATCHAGE_PATCHAGEPORT_HPP +#include "Canvas.hpp" +#include "CanvasModule.hpp" #include "Configuration.hpp" -#include "PatchageCanvas.hpp" -#include "PatchageModule.hpp" #include "PortID.hpp" #include "warnings.hpp" @@ -35,19 +35,19 @@ PATCHAGE_RESTORE_WARNINGS namespace patchage { -/// A port on a PatchageModule -class PatchagePort : public Ganv::Port +/// A port on a CanvasModule +class CanvasPort : public Ganv::Port { public: - PatchagePort(Ganv::Module& module, - PortType type, - PortID id, - const std::string& name, - const std::string& human_name, - bool is_input, - uint32_t color, - bool show_human_name, - boost::optional<int> order = boost::optional<int>()) + CanvasPort(Ganv::Module& module, + PortType type, + PortID id, + const std::string& name, + const std::string& human_name, + bool is_input, + uint32_t color, + bool show_human_name, + boost::optional<int> order = boost::optional<int>()) : Port(module, (show_human_name && !human_name.empty()) ? human_name : name, is_input, @@ -58,28 +58,28 @@ public: , _human_name(human_name) , _order(order) { - signal_event().connect(sigc::mem_fun(this, &PatchagePort::on_event)); + signal_event().connect(sigc::mem_fun(this, &CanvasPort::on_event)); } - PatchagePort(const PatchagePort&) = delete; - PatchagePort& operator=(const PatchagePort&) = delete; + CanvasPort(const CanvasPort&) = delete; + CanvasPort& operator=(const CanvasPort&) = delete; - PatchagePort(PatchagePort&&) = delete; - PatchagePort& operator=(PatchagePort&&) = delete; + CanvasPort(CanvasPort&&) = delete; + CanvasPort& operator=(CanvasPort&&) = delete; - ~PatchagePort() override = default; + ~CanvasPort() override = default; /** Returns the name of the module/client this port is one */ std::string module_name() const { - auto* pmod = dynamic_cast<PatchageModule*>(get_module()); + auto* pmod = dynamic_cast<CanvasModule*>(get_module()); return std::string(pmod->name()); } /** Returns the full name of this port, as "modulename:portname" */ std::string full_name() const { - auto* pmod = dynamic_cast<PatchageModule*>(get_module()); + auto* pmod = dynamic_cast<CanvasModule*>(get_module()); return std::string(pmod->name()) + ":" + _name; } diff --git a/src/Driver.hpp b/src/Driver.hpp index 7873ef3..231b7a2 100644 --- a/src/Driver.hpp +++ b/src/Driver.hpp @@ -17,7 +17,7 @@ #ifndef PATCHAGE_DRIVER_HPP #define PATCHAGE_DRIVER_HPP -#include "PatchageEvent.hpp" +#include "Event.hpp" #include <functional> #include <utility> @@ -28,7 +28,7 @@ namespace patchage { class Driver { public: - using EventSink = std::function<void(const PatchageEvent&)>; + using EventSink = std::function<void(const Event&)>; explicit Driver(EventSink emit_event) : _emit_event{std::move(emit_event)} diff --git a/src/PatchageEvent.hpp b/src/Event.hpp index b98375c..aa485c1 100644 --- a/src/PatchageEvent.hpp +++ b/src/Event.hpp @@ -74,14 +74,14 @@ struct DisconnectionEvent }; /// An event from drivers that is processed by the GUI -using PatchageEvent = boost::variant<DriverAttachmentEvent, - DriverDetachmentEvent, - ClientCreationEvent, - ClientDestructionEvent, - PortCreationEvent, - PortDestructionEvent, - ConnectionEvent, - DisconnectionEvent>; +using Event = boost::variant<DriverAttachmentEvent, + DriverDetachmentEvent, + ClientCreationEvent, + ClientDestructionEvent, + PortCreationEvent, + PortDestructionEvent, + ConnectionEvent, + DisconnectionEvent>; } // namespace patchage diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index 9584901..1e276ef 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -17,8 +17,8 @@ #include "ClientType.hpp" #include "Driver.hpp" +#include "Event.hpp" #include "ILog.hpp" -#include "PatchageEvent.hpp" #include "PortNames.hpp" #include "PortType.hpp" #include "SignalDirection.hpp" diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp index 63054e5..a120b6c 100644 --- a/src/JackLibDriver.cpp +++ b/src/JackLibDriver.cpp @@ -18,8 +18,8 @@ #include "ClientID.hpp" #include "ClientInfo.hpp" #include "ClientType.hpp" +#include "Event.hpp" #include "ILog.hpp" -#include "PatchageEvent.hpp" #include "PortInfo.hpp" #include "PortNames.hpp" #include "PortType.hpp" diff --git a/src/Patchage.cpp b/src/Patchage.cpp index a7c5198..5cb0fa3 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -16,11 +16,11 @@ #include "Patchage.hpp" +#include "Canvas.hpp" +#include "CanvasPort.hpp" #include "Configuration.hpp" +#include "Event.hpp" #include "Legend.hpp" -#include "PatchageCanvas.hpp" -#include "PatchageEvent.hpp" -#include "PatchagePort.hpp" #include "UIFile.hpp" #include "event_to_string.hpp" #include "handle_event.hpp" @@ -92,8 +92,8 @@ configure_cb(GtkWindow*, GdkEvent*, gpointer data) int port_order(const GanvPort* a, const GanvPort* b, void*) { - const auto* pa = dynamic_cast<const PatchagePort*>(Glib::wrap(a)); - const auto* pb = dynamic_cast<const PatchagePort*>(Glib::wrap(b)); + const auto* pa = dynamic_cast<const CanvasPort*>(Glib::wrap(a)); + const auto* pb = dynamic_cast<const CanvasPort*>(Glib::wrap(b)); if (pa && pb) { if (pa->order() && pb->order()) { return *pa->order() - *pb->order(); @@ -161,8 +161,8 @@ Patchage::Patchage(Options options) , _pane_initialized(false) , _attach(true) { - _canvas = std::unique_ptr<PatchageCanvas>{ - new PatchageCanvas(_connector, 1600 * 2, 1200 * 2)}; + _canvas = + std::unique_ptr<Canvas>{new Canvas(_connector, 1600 * 2, 1200 * 2)}; Glib::set_application_name("Patchage"); _about_win->property_program_name() = "Patchage"; @@ -274,7 +274,7 @@ Patchage::Patchage(Options options) // Make Jack driver if possible _jack_driver = make_jack_driver( - _log, [this](const PatchageEvent& event) { on_driver_event(event); }); + _log, [this](const Event& event) { on_driver_event(event); }); if (_jack_driver) { _connector.add_driver(PortID::Type::jack, _jack_driver.get()); @@ -290,7 +290,7 @@ Patchage::Patchage(Options options) // Make ALSA driver if possible _alsa_driver = make_alsa_driver( - _log, [this](const PatchageEvent& event) { on_driver_event(event); }); + _log, [this](const Event& event) { on_driver_event(event); }); if (_alsa_driver) { _connector.add_driver(PortID::Type::alsa, _alsa_driver.get()); @@ -446,7 +446,7 @@ Patchage::zoom(double z) void Patchage::refresh() { - auto sink = [this](const PatchageEvent& event) { + auto sink = [this](const Event& event) { _log.info("Refresh: " + event_to_string(event)); handle_event(*this, event); }; @@ -473,9 +473,8 @@ Patchage::driver_attached(const ClientType type) _menu_jack_disconnect->set_sensitive(true); if (_jack_driver) { - _jack_driver->refresh([this](const PatchageEvent& event) { - handle_event(*this, event); - }); + _jack_driver->refresh( + [this](const Event& event) { handle_event(*this, event); }); } break; @@ -484,9 +483,8 @@ Patchage::driver_attached(const ClientType type) _menu_alsa_disconnect->set_sensitive(true); if (_alsa_driver) { - _alsa_driver->refresh([this](const PatchageEvent& event) { - handle_event(*this, event); - }); + _alsa_driver->refresh( + [this](const Event& event) { handle_event(*this, event); }); } break; @@ -502,7 +500,7 @@ Patchage::driver_detached(const ClientType type) _menu_jack_disconnect->set_sensitive(false); if (_jack_driver && !_jack_driver->is_attached()) { - _canvas->remove_ports([](const PatchagePort* port) { + _canvas->remove_ports([](const CanvasPort* port) { return (port->type() == PortType::jack_audio || port->type() == PortType::jack_midi || port->type() == PortType::jack_osc || @@ -516,7 +514,7 @@ Patchage::driver_detached(const ClientType type) _menu_alsa_connect->set_sensitive(true); _menu_alsa_disconnect->set_sensitive(false); - _canvas->remove_ports([](const PatchagePort* port) { + _canvas->remove_ports([](const CanvasPort* port) { return port->type() == PortType::alsa_midi; }); @@ -555,7 +553,7 @@ load_module_location(GanvNode* node, void*) { if (GANV_IS_MODULE(node)) { Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); - auto* pmod = dynamic_cast<PatchageModule*>(gmod); + auto* pmod = dynamic_cast<CanvasModule*>(gmod); if (pmod) { pmod->load_location(); } @@ -569,7 +567,7 @@ Patchage::update_state() } void -Patchage::on_driver_event(const PatchageEvent& event) +Patchage::on_driver_event(const Event& event) { std::lock_guard<std::mutex> lock{_events_mutex}; @@ -618,10 +616,10 @@ update_labels(GanvNode* node, void* data) const bool human_names = *static_cast<const bool*>(data); if (GANV_IS_MODULE(node)) { Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); - auto* pmod = dynamic_cast<PatchageModule*>(gmod); + auto* pmod = dynamic_cast<CanvasModule*>(gmod); if (pmod) { for (Ganv::Port* gport : *gmod) { - auto* pport = dynamic_cast<PatchagePort*>(gport); + auto* pport = dynamic_cast<CanvasPort*>(gport); if (pport) { pport->show_human_name(human_names); } @@ -720,13 +718,13 @@ update_port_colors(GanvNode* node, void* data) } Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); - auto* pmod = dynamic_cast<PatchageModule*>(gmod); + auto* pmod = dynamic_cast<CanvasModule*>(gmod); if (!pmod) { return; } for (Ganv::Port* p : *pmod) { - auto* port = dynamic_cast<PatchagePort*>(p); + auto* port = dynamic_cast<CanvasPort*>(p); if (port) { const uint32_t rgba = patchage->conf().get_port_color(port->type()); port->set_fill_color(rgba); @@ -741,7 +739,7 @@ update_edge_color(GanvEdge* edge, void* data) auto* patchage = static_cast<Patchage*>(data); Ganv::Edge* edgemm = Glib::wrap(edge); - auto* tail = dynamic_cast<PatchagePort*>((edgemm)->get_tail()); + auto* tail = dynamic_cast<CanvasPort*>((edgemm)->get_tail()); if (tail) { edgemm->set_color(patchage->conf().get_port_color(tail->type())); } diff --git a/src/Patchage.hpp b/src/Patchage.hpp index 80c3e84..51e6d99 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -39,11 +39,11 @@ #include "ClientType.hpp" #include "Connector.hpp" +#include "Event.hpp" #include "ILog.hpp" #include "Legend.hpp" #include "Metadata.hpp" #include "Options.hpp" -#include "PatchageEvent.hpp" #include "TextViewLog.hpp" #include "Widget.hpp" #include "patchage_config.h" @@ -56,7 +56,7 @@ namespace patchage { class AudioDriver; -class PatchageCanvas; +class Canvas; class Configuration; /// Main application class @@ -73,7 +73,7 @@ public: Patchage(Patchage&&) = delete; Patchage& operator=(Patchage&&) = delete; - const std::unique_ptr<PatchageCanvas>& canvas() const { return _canvas; } + const std::unique_ptr<Canvas>& canvas() const { return _canvas; } void attach(); void refresh(); @@ -108,7 +108,7 @@ protected: Gtk::TreeModelColumn<Glib::ustring> label; }; - void on_driver_event(const PatchageEvent& event); + void on_driver_event(const Event& event); void process_events(); void on_arrange(); @@ -147,12 +147,12 @@ protected: Glib::RefPtr<Gtk::Builder> _xml; - std::mutex _events_mutex; - std::queue<PatchageEvent> _driver_events; + std::mutex _events_mutex; + std::queue<Event> _driver_events; std::unique_ptr<Driver> _alsa_driver; - std::unique_ptr<PatchageCanvas> _canvas; + std::unique_ptr<Canvas> _canvas; std::unique_ptr<AudioDriver> _jack_driver; Configuration _conf; diff --git a/src/event_to_string.cpp b/src/event_to_string.cpp index 58d99ac..321ca4e 100644 --- a/src/event_to_string.cpp +++ b/src/event_to_string.cpp @@ -17,7 +17,7 @@ #include "event_to_string.hpp" #include "ClientType.hpp" -#include "PatchageEvent.hpp" +#include "Event.hpp" #include "warnings.hpp" PATCHAGE_DISABLE_FMT_WARNINGS @@ -138,14 +138,14 @@ struct EventPrinter } // namespace std::string -event_to_string(const PatchageEvent& event) +event_to_string(const Event& event) { EventPrinter printer; return boost::apply_visitor(printer, event); } std::ostream& -operator<<(std::ostream& os, const PatchageEvent& event) +operator<<(std::ostream& os, const Event& event) { return os << event_to_string(event); } diff --git a/src/event_to_string.hpp b/src/event_to_string.hpp index 0795bce..db55733 100644 --- a/src/event_to_string.hpp +++ b/src/event_to_string.hpp @@ -17,7 +17,7 @@ #ifndef PATCHAGE_EVENT_TO_STRING_HPP #define PATCHAGE_EVENT_TO_STRING_HPP -#include "PatchageEvent.hpp" +#include "Event.hpp" #include <iosfwd> #include <string> @@ -25,10 +25,10 @@ namespace patchage { std::string -event_to_string(const PatchageEvent& event); +event_to_string(const Event& event); std::ostream& -operator<<(std::ostream& os, const PatchageEvent& event); +operator<<(std::ostream& os, const Event& event); } // namespace patchage diff --git a/src/handle_event.cpp b/src/handle_event.cpp index b6412c2..40f6c22 100644 --- a/src/handle_event.cpp +++ b/src/handle_event.cpp @@ -16,11 +16,11 @@ #include "handle_event.hpp" +#include "Canvas.hpp" +#include "CanvasModule.hpp" +#include "CanvasPort.hpp" +#include "Event.hpp" #include "Patchage.hpp" -#include "PatchageCanvas.hpp" -#include "PatchageEvent.hpp" -#include "PatchageModule.hpp" -#include "PatchagePort.hpp" PATCHAGE_DISABLE_FMT_WARNINGS #include <fmt/core.h> @@ -83,8 +83,8 @@ public: void operator()(const ConnectionEvent& event) { - PatchagePort* port_1 = _patchage.canvas()->find_port(event.tail); - PatchagePort* port_2 = _patchage.canvas()->find_port(event.head); + CanvasPort* port_1 = _patchage.canvas()->find_port(event.tail); + CanvasPort* port_2 = _patchage.canvas()->find_port(event.head); if (!port_1) { _patchage.log().error(fmt::format( @@ -99,8 +99,8 @@ public: void operator()(const DisconnectionEvent& event) { - PatchagePort* port_1 = _patchage.canvas()->find_port(event.tail); - PatchagePort* port_2 = _patchage.canvas()->find_port(event.head); + CanvasPort* port_1 = _patchage.canvas()->find_port(event.tail); + CanvasPort* port_2 = _patchage.canvas()->find_port(event.head); if (!port_1) { _patchage.log().error(fmt::format( @@ -120,7 +120,7 @@ private: } // namespace void -handle_event(Patchage& patchage, const PatchageEvent& event) +handle_event(Patchage& patchage, const Event& event) { EventHandler handler{patchage}; boost::apply_visitor(handler, event); diff --git a/src/handle_event.hpp b/src/handle_event.hpp index 0993db1..975b3bb 100644 --- a/src/handle_event.hpp +++ b/src/handle_event.hpp @@ -17,7 +17,7 @@ #ifndef PATCHAGE_HANDLE_EVENT_HPP #define PATCHAGE_HANDLE_EVENT_HPP -#include "PatchageEvent.hpp" +#include "Event.hpp" namespace patchage { @@ -25,7 +25,7 @@ class Patchage; /// Handle an event in the GUI void -handle_event(Patchage& patchage, const PatchageEvent& event); +handle_event(Patchage& patchage, const Event& event); } // namespace patchage @@ -236,13 +236,13 @@ def build(bld): uselib = 'DBUS GANV DBUS_GLIB FMT GTKMM GTHREAD GTK_OSX', install_path = '${BINDIR}') prog.source = ''' + src/Canvas.cpp + src/CanvasModule.cpp src/Configuration.cpp src/Connector.cpp src/Legend.cpp src/Metadata.cpp src/Patchage.cpp - src/PatchageCanvas.cpp - src/PatchageModule.cpp src/TextViewLog.cpp src/event_to_string.cpp src/handle_event.cpp |