summaryrefslogtreecommitdiffstats
path: root/src/Action.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/Action.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/Action.hpp')
-rw-r--r--src/Action.hpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/Action.hpp b/src/Action.hpp
new file mode 100644
index 0000000..f843a14
--- /dev/null
+++ b/src/Action.hpp
@@ -0,0 +1,76 @@
+/* This file is part of Patchage.
+ * 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
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Patchage. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PATCHAGE_ACTION_HPP
+#define PATCHAGE_ACTION_HPP
+
+#include "ClientID.hpp"
+#include "PortID.hpp"
+#include "SignalDirection.hpp"
+
+#include <boost/variant/variant.hpp>
+
+namespace patchage {
+namespace action {
+
+struct ConnectPorts {
+ PortID tail;
+ PortID head;
+};
+
+struct DisconnectClient {
+ ClientID client;
+ SignalDirection direction;
+};
+
+struct DisconnectPort {
+ PortID port;
+};
+
+struct DisconnectPorts {
+ PortID tail;
+ PortID head;
+};
+
+struct MoveModule {
+ ClientID client;
+ SignalDirection direction;
+ double x;
+ double y;
+};
+
+struct SplitModule {
+ ClientID client;
+};
+
+struct UnsplitModule {
+ ClientID client;
+};
+
+} // namespace action
+
+/// A high-level action from the user
+using Action = boost::variant<action::ConnectPorts,
+ action::DisconnectClient,
+ action::DisconnectPort,
+ action::DisconnectPorts,
+ action::MoveModule,
+ action::SplitModule,
+ action::UnsplitModule>;
+
+} // namespace patchage
+
+#endif // PATCHAGE_ACTION_HPP