Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
port_connection_action.h
1// SPDX-FileCopyrightText: © 2020-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __ACTION_PORT_CONNECTION_ACTION_H__
5#define __ACTION_PORT_CONNECTION_ACTION_H__
6
9
16enum class PortConnectionActionType
17{
18 PORT_CONNECTION_CONNECT,
19 PORT_CONNECTION_DISCONNECT,
20 PORT_CONNECTION_ENABLE,
21 PORT_CONNECTION_DISABLE,
22 PORT_CONNECTION_CHANGE_MULTIPLIER,
23};
24
26{
27 UndoableAction parent_instance;
28
29 PortConnectionActionType type;
30
31 PortConnection * connection;
32
38 float val;
40
41void
42port_connection_action_init_loaded (PortConnectionAction * self);
43
47WARN_UNUSED_RESULT UndoableAction *
49 PortConnectionActionType type,
50 PortIdentifier * src_id,
51 PortIdentifier * dest_id,
52 float new_val,
53 GError ** error);
54
55#define port_connection_action_new_connect(src_id, dest_id, error) \
56 port_connection_action_new ( \
57 PortConnectionActionType::PORT_CONNECTION_CONNECT, src_id, dest_id, 0.f, \
58 error)
59
60#define port_connection_action_new_disconnect(src_id, dest_id, error) \
61 port_connection_action_new ( \
62 PortConnectionActionType::PORT_CONNECTION_DISCONNECT, src_id, dest_id, \
63 0.f, error)
64
65#define port_connection_action_new_enable(src_id, dest_id, enable, error) \
66 port_connection_action_new ( \
67 enable \
68 ? PortConnectionActionType::PORT_CONNECTION_ENABLE \
69 : PortConnectionActionType::PORT_CONNECTION_DISABLE, \
70 src_id, dest_id, 0.f, error)
71
72#define port_connection_action_new_change_multiplier( \
73 src_id, dest_id, new_multiplier, error) \
74 port_connection_action_new ( \
75 PortConnectionActionType::PORT_CONNECTION_CHANGE_MULTIPLIER, src_id, \
76 dest_id, new_multiplier, error)
77
79port_connection_action_clone (const PortConnectionAction * src);
80
81bool
82port_connection_action_perform (
83 PortConnectionActionType type,
84 PortIdentifier * src_id,
85 PortIdentifier * dest_id,
86 float new_val,
87 GError ** error);
88
89#define port_connection_action_perform_connect(src_id, dest_id, error) \
90 port_connection_action_perform ( \
91 PortConnectionActionType::PORT_CONNECTION_CONNECT, src_id, dest_id, 0.f, \
92 error)
93
94#define port_connection_action_perform_disconnect(src_id, dest_id, error) \
95 port_connection_action_perform ( \
96 PortConnectionActionType::PORT_CONNECTION_DISCONNECT, src_id, dest_id, \
97 0.f, error)
98
99#define port_connection_action_perform_enable(src_id, dest_id, enable, error) \
100 port_connection_action_perform ( \
101 enable \
102 ? PortConnectionActionType::PORT_CONNECTION_ENABLE \
103 : PortConnectionActionType::PORT_CONNECTION_DISABLE, \
104 src_id, dest_id, 0.f, error)
105
106#define port_connection_action_perform_change_multiplier( \
107 src_id, dest_id, new_multiplier, error) \
108 port_connection_action_perform ( \
109 PortConnectionActionType::PORT_CONNECTION_CHANGE_MULTIPLIER, src_id, \
110 dest_id, new_multiplier, error)
111
112int
113port_connection_action_do (PortConnectionAction * self, GError ** error);
114
115int
116port_connection_action_undo (PortConnectionAction * self, GError ** error);
117
118char *
119port_connection_action_stringize (PortConnectionAction * self);
120
121void
122port_connection_action_free (PortConnectionAction * self);
123
128#endif
WARN_UNUSED_RESULT UndoableAction * port_connection_action_new(PortConnectionActionType type, PortIdentifier *src_id, PortIdentifier *dest_id, float new_val, GError **error)
Create a new action.
Port connection.
float val
Value before/after the change.
A connection between two ports.
Struct used to identify Ports in the project.
Base struct to be inherited by implementing undoable actions.
Undoable actions.