summaryrefslogtreecommitdiffstats
path: root/src/CanvasModule.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-10 13:19:34 -0400
committerDavid Robillard <d@drobilla.net>2021-05-10 13:19:34 -0400
commitc1d99e42674d26a2699e5a7244dbaa988820b40d (patch)
tree29a103fdb8536c6c6e42dcc8013f146fedcc8e14 /src/CanvasModule.hpp
parenta280246c3043fc2ea1f50fa695539ac0bec44be1 (diff)
downloadpatchage-c1d99e42674d26a2699e5a7244dbaa988820b40d.tar.gz
patchage-c1d99e42674d26a2699e5a7244dbaa988820b40d.tar.bz2
patchage-c1d99e42674d26a2699e5a7244dbaa988820b40d.zip
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.
Diffstat (limited to 'src/CanvasModule.hpp')
-rw-r--r--src/CanvasModule.hpp29
1 files changed, 16 insertions, 13 deletions
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 <d@drobilla.net>
+ * Copyright 2007-2021 David Robillard <d@drobilla.net>
*
* 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<Gtk::Menu> _menu;
std::string _name;
SignalDirection _type;