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
16typedef enum PortConnectionActionType
17{
18 PORT_CONNECTION_CONNECT,
19 PORT_CONNECTION_DISCONNECT,
20 PORT_CONNECTION_ENABLE,
21 PORT_CONNECTION_DISABLE,
22 PORT_CONNECTION_CHANGE_MULTIPLIER,
23} PortConnectionActionType;
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 PORT_CONNECTION_CONNECT, src_id, dest_id, 0.f, error)
58
59#define port_connection_action_new_disconnect(src_id, dest_id, error) \
60 port_connection_action_new ( \
61 PORT_CONNECTION_DISCONNECT, src_id, dest_id, 0.f, error)
62
63#define port_connection_action_new_enable(src_id, dest_id, enable, error) \
64 port_connection_action_new ( \
65 enable ? PORT_CONNECTION_ENABLE : PORT_CONNECTION_DISABLE, src_id, \
66 dest_id, 0.f, error)
67
68#define port_connection_action_new_change_multiplier( \
69 src_id, dest_id, new_multiplier, error) \
70 port_connection_action_new ( \
71 PORT_CONNECTION_CHANGE_MULTIPLIER, src_id, dest_id, new_multiplier, error)
72
74port_connection_action_clone (const PortConnectionAction * src);
75
76bool
77port_connection_action_perform (
78 PortConnectionActionType type,
79 PortIdentifier * src_id,
80 PortIdentifier * dest_id,
81 float new_val,
82 GError ** error);
83
84#define port_connection_action_perform_connect(src_id, dest_id, error) \
85 port_connection_action_perform ( \
86 PORT_CONNECTION_CONNECT, src_id, dest_id, 0.f, error)
87
88#define port_connection_action_perform_disconnect(src_id, dest_id, error) \
89 port_connection_action_perform ( \
90 PORT_CONNECTION_DISCONNECT, src_id, dest_id, 0.f, error)
91
92#define port_connection_action_perform_enable(src_id, dest_id, enable, error) \
93 port_connection_action_perform ( \
94 enable ? PORT_CONNECTION_ENABLE : PORT_CONNECTION_DISABLE, src_id, \
95 dest_id, 0.f, error)
96
97#define port_connection_action_perform_change_multiplier( \
98 src_id, dest_id, new_multiplier, error) \
99 port_connection_action_perform ( \
100 PORT_CONNECTION_CHANGE_MULTIPLIER, src_id, dest_id, new_multiplier, error)
101
102int
103port_connection_action_do (PortConnectionAction * self, GError ** error);
104
105int
106port_connection_action_undo (PortConnectionAction * self, GError ** error);
107
108char *
109port_connection_action_stringize (PortConnectionAction * self);
110
111void
112port_connection_action_free (PortConnectionAction * self);
113
118#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.