From c1d99e42674d26a2699e5a7244dbaa988820b40d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 10 May 2021 13:19:34 -0400 Subject: Add Action representation to isolate behaviour from canvas objects A step towards isolating the canvas and ultimately the entire UI away so it can be replaced. --- src/CanvasModule.hpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/CanvasModule.hpp') diff --git a/src/CanvasModule.hpp b/src/CanvasModule.hpp index 4f8412e..2dcdcc1 100644 --- a/src/CanvasModule.hpp +++ b/src/CanvasModule.hpp @@ -1,5 +1,5 @@ /* This file is part of Patchage. - * Copyright 2007-2020 David Robillard + * Copyright 2007-2021 David Robillard * * Patchage is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -17,6 +17,7 @@ #ifndef PATCHAGE_CANVASMODULE_HPP #define PATCHAGE_CANVASMODULE_HPP +#include "ActionSink.hpp" #include "ClientID.hpp" #include "SignalDirection.hpp" #include "warnings.hpp" @@ -38,18 +39,21 @@ namespace patchage { struct PortID; +class Configuration; +class Canvas; + class CanvasPort; -class Patchage; class CanvasModule : public Ganv::Module { public: - CanvasModule(Patchage* app, + CanvasModule(Canvas& canvas, + ActionSink& action_sink, const std::string& name, SignalDirection type, ClientID id, - double x = 0.0, - double y = 0.0); + double x, + double y); CanvasModule(const CanvasModule&) = delete; CanvasModule& operator=(const CanvasModule&) = delete; @@ -57,26 +61,25 @@ public: CanvasModule(CanvasModule&&) = delete; CanvasModule& operator=(CanvasModule&&) = delete; + ~CanvasModule() override = default; + bool show_menu(GdkEventButton* ev); void update_menu(); - void split(); - void join(); - void disconnect_all(); - CanvasPort* get_port(const PortID& id); - void load_location(); - void store_location(double x, double y); - SignalDirection type() const { return _type; } ClientID id() const { return _id; } const std::string& name() const { return _name; } protected: bool on_event(GdkEvent* ev) override; + void on_moved(double x, double y); + void on_split(); + void on_join(); + void on_disconnect(); - Patchage* _app; + ActionSink& _action_sink; std::unique_ptr _menu; std::string _name; SignalDirection _type; -- cgit v1.2.1