Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
mixer_selections_action.h
1// SPDX-FileCopyrightText: © 2019-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __UNDO_MIXER_SELECTIONS_ACTION_H__
5#define __UNDO_MIXER_SELECTIONS_ACTION_H__
6
7#include "dsp/port_connections_manager.h"
8#include "gui/backend/backend/actions/undoable_action.h"
9#include "gui/dsp/plugin_span.h"
10#include "plugins/plugin.h"
11#include "structure/tracks/automation_track.h"
12#include "structure/tracks/track.h"
13
14namespace zrythm::gui::actions
15{
16
22class MixerSelectionsAction : public QObject, public UndoableAction
23{
24 Q_OBJECT
25 QML_ELEMENT
26 DEFINE_UNDOABLE_ACTION_QML_PROPERTIES (MixerSelectionsAction)
27
28 using Track = structure::tracks::Track;
29 using AutomationTrack = structure::tracks::AutomationTrack;
30
31public:
32 enum class Type
33 {
40 Delete,
41 Move,
42 ChangeStatus,
43 ChangeLoadBehavior,
44 };
45
46 using PluginSlotType = plugins::PluginSlotType;
47 using Plugin = plugins::Plugin;
48 using PluginUuid = Plugin::Uuid;
49 using PluginPtrVariant = plugins::PluginPtrVariant;
50 using PluginConfiguration = plugins::PluginConfiguration;
51
52 MixerSelectionsAction (QObject * parent = nullptr);
53
65 std::optional<PluginSpan> ms,
66 const dsp::PortConnectionsManager * connections_mgr,
67 Type type,
68 std::optional<Track::Uuid> to_track_id,
69 std::optional<plugins::PluginSlot> to_slot,
70 const PluginConfiguration * setting,
71 int num_plugins,
72 int new_val,
73 zrythm::plugins::BridgeMode new_bridge_mode,
74 QObject * parent = nullptr);
75
76 QString to_string () const override;
77
78 void get_plugins (std::vector<Plugin *> &plugins) override
79 {
80// TODO
81#if 0
82 if (ms_before_)
83 PluginSpan{ *ms_before_ }.get_plugins (plugins);
84 if (deleted_ms_)
85 PluginSpan{ *deleted_ms_ }.get_plugins (plugins);
86#endif
87 }
88
89 friend void init_from (
90 MixerSelectionsAction &obj,
91 const MixerSelectionsAction &other,
92 utils::ObjectCloneType clone_type);
93
94private:
95 void init_loaded_impl () override;
96 void perform_impl () override;
97 void undo_impl () override;
98
105 void clone_ats (PluginSpan plugins, bool deleted, int start_slot);
106
107 void copy_at_regions (AutomationTrack &dest, const AutomationTrack &src);
108
109#if 0
115 void revert_automation (
118 bool deleted);
119#endif
120
126 void save_existing_plugin (
127 std::vector<PluginPtrVariant> tmp_plugins,
128 Track * from_tr,
129 plugins::PluginSlot from_slot,
130 Track * to_tr,
131 plugins::PluginSlot to_slot);
132
133 void revert_deleted_plugin (Track &to_tr, plugins::PluginSlot to_slot);
134
135 void do_or_undo_create_or_delete (bool do_it, bool create);
136 void do_or_undo_change_status (bool do_it);
137 void do_or_undo_change_load_behavior (bool do_it);
138 void do_or_undo_move_or_copy (bool do_it, bool copy);
139 void do_or_undo (bool do_it);
140
141public:
142 Type mixer_selections_action_type_ = Type ();
143
150 std::optional<plugins::PluginSlot> to_slot_;
151
153 std::optional<Track::Uuid> to_track_uuid_;
154
157 bool new_channel_ = false;
158
161
163 int new_val_ = 0;
164
166 zrythm::plugins::BridgeMode new_bridge_mode_ =
167 zrythm::plugins::BridgeMode::None;
168
172 std::unique_ptr<PluginConfiguration> setting_;
173
177 std::optional<std::vector<PluginPtrVariant>> ms_before_;
178
179 std::optional<std::vector<PluginUuid>> ms_before_simple_;
180
186 std::optional<std::vector<PluginPtrVariant>> deleted_ms_;
187
194 std::vector<std::unique_ptr<AutomationTrack>> deleted_ats_;
195
202 std::vector<std::unique_ptr<AutomationTrack>> ats_;
203};
204
205class MixerSelectionsCreateAction : public MixerSelectionsAction
206{
207public:
208 MixerSelectionsCreateAction (
209 const Track &to_track,
210 plugins::PluginSlot to_slot,
211 const PluginConfiguration &setting,
212 int num_plugins = 1)
213 : MixerSelectionsAction (
214 std::nullopt,
215 nullptr,
217 to_track.get_uuid (),
218 to_slot,
219 &setting,
220 num_plugins,
221 0,
222 zrythm::plugins::BridgeMode::None)
223 {
224 }
225};
226
227class MixerSelectionsTargetedAction : public MixerSelectionsAction
228{
229public:
230 MixerSelectionsTargetedAction (
231 PluginSpan plugins,
232 const dsp::PortConnectionsManager &connections_mgr,
234 const Track * to_track,
235 plugins::PluginSlot to_slot)
236 : MixerSelectionsAction (
237 plugins,
238 &connections_mgr,
239 type,
240 (to_track != nullptr)
241 ? std::make_optional (to_track->get_uuid ())
242 : std::nullopt,
243 to_slot,
244 nullptr,
245 0,
246 0,
247 zrythm::plugins::BridgeMode::None)
248 {
249 }
250};
251
252class MixerSelectionsCopyAction : public MixerSelectionsTargetedAction
253{
254public:
255 MixerSelectionsCopyAction (
256 PluginSpan plugins,
257 const dsp::PortConnectionsManager &connections_mgr,
258 const Track * to_track,
259 plugins::PluginSlot to_slot)
260 : MixerSelectionsTargetedAction (
261 plugins,
262 connections_mgr,
264 to_track,
265 to_slot)
266 {
267 }
268};
269
270class MixerSelectionsPasteAction : public MixerSelectionsTargetedAction
271{
272public:
273 MixerSelectionsPasteAction (
274 PluginSpan plugins,
275 const dsp::PortConnectionsManager &connections_mgr,
276 const Track * to_track,
277 plugins::PluginSlot to_slot)
278 : MixerSelectionsTargetedAction (
279 plugins,
280 connections_mgr,
282 to_track,
283 to_slot)
284 {
285 }
286};
287
288class MixerSelectionsMoveAction : public MixerSelectionsTargetedAction
289{
290public:
291 MixerSelectionsMoveAction (
292 PluginSpan plugins,
293 const dsp::PortConnectionsManager &connections_mgr,
294 const Track * to_track,
295 plugins::PluginSlot to_slot)
296 : MixerSelectionsTargetedAction (
297 plugins,
298 connections_mgr,
299 MixerSelectionsAction::Type::Move,
300 to_track,
301 to_slot)
302 {
303 }
304};
305
306class MixerSelectionsDeleteAction : public MixerSelectionsAction
307{
308public:
309 MixerSelectionsDeleteAction (
310 PluginSpan plugins,
311 const dsp::PortConnectionsManager &connections_mgr)
312 : MixerSelectionsAction (
313 plugins,
314 &connections_mgr,
315 MixerSelectionsAction::Type::Delete,
316 std::nullopt,
317 std::nullopt,
318 nullptr,
319 0,
320 0,
321 zrythm::plugins::BridgeMode::None)
322 {
323 }
324};
325
326class MixerSelectionsChangeStatusAction : public MixerSelectionsAction
327{
328public:
329 MixerSelectionsChangeStatusAction (PluginSpan plugins, int new_val)
330 : MixerSelectionsAction (
331 plugins,
332 nullptr,
333 MixerSelectionsAction::Type::ChangeStatus,
334 std::nullopt,
335 std::nullopt,
336 nullptr,
337 0,
338 new_val,
339 zrythm::plugins::BridgeMode::None)
340 {
341 }
342};
343
344class MixerSelectionsChangeLoadBehaviorAction : public MixerSelectionsAction
345{
346public:
347 MixerSelectionsChangeLoadBehaviorAction (
348 PluginSpan plugins,
349 zrythm::plugins::BridgeMode new_bridge_mode)
350 : MixerSelectionsAction (
351 plugins,
352 nullptr,
353 MixerSelectionsAction::Type::ChangeLoadBehavior,
354 std::nullopt,
355 std::nullopt,
356 nullptr,
357 0,
358 0,
359 new_bridge_mode)
360 {
361 }
362};
363
364}; // namespace zrythm::actions
365
366#endif
Span of plugins that offers helper methods.
Definition plugin_span.h:14
Action for manipulating plugins (plugin slot selections in the mixer).
std::optional< std::vector< PluginPtrVariant > > ms_before_
Clone of mixer selections at start.
int num_plugins_
Number of plugins to create, when creating new plugins.
std::unique_ptr< PluginConfiguration > setting_
PluginConfiguration to use when creating.
MixerSelectionsAction(std::optional< PluginSpan > ms, const dsp::PortConnectionsManager *connections_mgr, Type type, std::optional< Track::Uuid > to_track_id, std::optional< plugins::PluginSlot > to_slot, const PluginConfiguration *setting, int num_plugins, int new_val, zrythm::plugins::BridgeMode new_bridge_mode, QObject *parent=nullptr)
Create a new action.
bool new_channel_
Whether the plugins will be copied/moved into a new channel, if applicable.
std::optional< std::vector< PluginPtrVariant > > deleted_ms_
Deleted plugins (ie, plugins replaced during move/copy).
std::vector< std::unique_ptr< AutomationTrack > > deleted_ats_
Automation tracks associated with the deleted plugins.
std::optional< Track::Uuid > to_track_uuid_
To track position.
QString to_string() const override
Stringizes the action to be used in Undo/Redo buttons.
std::optional< plugins::PluginSlot > to_slot_
Starting target slot.
std::vector< std::unique_ptr< AutomationTrack > > ats_
Automation tracks associated with the plugins.
zrythm::plugins::BridgeMode new_bridge_mode_
Used when changing load behavior.
Configuration for instantiating a plugin descriptor.
DSP processing plugin.
Definition plugin.h:30
Represents a track in the project.
Definition track.h:54