Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
undoable_action.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UNDO_UNDOABLE_ACTION_H__
11#define __UNDO_UNDOABLE_ACTION_H__
12
13#include <stdbool.h>
14
15#include "utils/types.h"
16#include "utils/yaml.h"
17
18typedef struct AudioClip AudioClip;
20
27#define UNDOABLE_ACTION_SCHEMA_VERSION 2
28
33{
34 /* ---- Track/Channel ---- */
35 UA_TRACKLIST_SELECTIONS,
36
37 UA_CHANNEL_SEND,
38
39 /* ---- end ---- */
40
41 UA_MIXER_SELECTIONS,
42 UA_ARRANGER_SELECTIONS,
43
44 /* ---- connections ---- */
45
46 UA_MIDI_MAPPING,
47 UA_PORT_CONNECTION,
48 UA_PORT,
49
50 /* ---- end ---- */
51
52 /* ---- range ---- */
53
54 UA_RANGE,
55
56 /* ---- end ---- */
57
58 UA_TRANSPORT,
59
60 UA_CHORD,
61
63
64static const cyaml_strval_t undoable_action_type_strings[] = {
65 {"Tracklist selections", UA_TRACKLIST_SELECTIONS},
66 { "Channel send", UA_CHANNEL_SEND },
67 { "Mixer selections", UA_MIXER_SELECTIONS },
68 { "Arranger selections", UA_ARRANGER_SELECTIONS },
69 { "MIDI mapping", UA_MIDI_MAPPING },
70 { "Port connection", UA_PORT_CONNECTION },
71 { "Port", UA_PORT },
72 { "Range", UA_RANGE },
73 { "Transport", UA_TRANSPORT },
74 { "Chord", UA_CHORD },
75};
76
81typedef struct UndoableAction
82{
83 int schema_version;
84
87
91
99
106
118
119static const cyaml_schema_field_t undoable_action_fields_schema[] = {
120 YAML_FIELD_INT (UndoableAction, schema_version),
121 YAML_FIELD_ENUM (
123 type,
124 undoable_action_type_strings),
125 YAML_FIELD_FLOAT (UndoableAction, frames_per_tick),
126 YAML_FIELD_INT (UndoableAction, sample_rate),
127 YAML_FIELD_INT (UndoableAction, stack_idx),
128 YAML_FIELD_INT (UndoableAction, num_actions),
129
130 CYAML_FIELD_END
131};
132
133static const cyaml_schema_value_t undoable_action_schema = {
134 CYAML_VALUE_MAPPING (
135 CYAML_FLAG_POINTER,
137 undoable_action_fields_schema),
138};
139
140NONNULL void
141undoable_action_init_loaded (UndoableAction * self);
142
146NONNULL void
148 UndoableAction * self,
149 UndoableActionType type);
150
155NONNULL bool
157
166NONNULL bool
168
173NONNULL bool
175 UndoableAction * self,
176 AudioClip * clip);
177
178NONNULL void
179undoable_action_get_plugins (
180 UndoableAction * self,
181 GPtrArray * arr);
182
189NONNULL void
191 UndoableAction * self,
192 int num_actions);
193
203NONNULL_ARGS (1)
205 UndoableAction * self,
206 bool _do,
207 PortConnectionsManager ** before,
208 PortConnectionsManager ** after);
209
217NONNULL_ARGS (1)
218int undoable_action_do (UndoableAction * self, GError ** error);
219
225NONNULL_ARGS (1)
227 UndoableAction * self,
228 GError ** error);
229
230void
231undoable_action_free (UndoableAction * self);
232
239NONNULL char *
241
246#endif
int undoable_action_undo(UndoableAction *self, GError **error)
Undoes the action.
NONNULL char * undoable_action_to_string(UndoableAction *ua)
Stringizes the action to be used in Undo/Redo buttons.
NONNULL void undoable_action_set_num_actions(UndoableAction *self, int num_actions)
Sets the number of actions for this action.
void undoable_action_save_or_load_port_connections(UndoableAction *self, bool _do, PortConnectionsManager **before, PortConnectionsManager **after)
To be used by actions that save/load port connections.
NONNULL bool undoable_action_needs_pause(UndoableAction *self)
Returns whether the action requires pausing the engine.
UndoableActionType
Type of UndoableAction.
NONNULL void undoable_action_init(UndoableAction *self, UndoableActionType type)
Initializer to be used by implementing actions.
NONNULL bool undoable_action_contains_clip(UndoableAction *self, AudioClip *clip)
Checks whether the action actually contains or refers to the given audio clip.
NONNULL bool undoable_action_can_contain_clip(UndoableAction *self)
Checks whether the action can contain an audio clip.
int undoable_action_do(UndoableAction *self, GError **error)
Performs the action.
COLD NONNULL_ARGS(1) void automation_track_init_loaded(AutomationTrack *self
Inits a loaded AutomationTracklist.
uint32_t sample_rate_t
Sample rate.
Definition types.h:37
Audio clips for the pool.
Definition clip.h:33
Port connections manager.
Base struct to be inherited by implementing undoable actions.
int num_actions
Number of actions to perform.
UndoableActionType type
Undoable action type.
int stack_idx
Index in the stack.
double frames_per_tick
A snapshot of AudioEngine.frames_per_tick when the action is executed.
sample_rate_t sample_rate
Sample rate of this action.
Custom types.
YAML utils.