Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
add_clip_to_clip_slot_command.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <optional>
7#include <utility>
8
9#include "structure/arrangement/arranger_object_all.h"
10#include "structure/scenes/clip_slot.h"
11
12#include <QUndoCommand>
13
14namespace zrythm::commands
15{
16
17class AddClipToClipSlotCommand : public QUndoCommand
18{
19public:
20 AddClipToClipSlotCommand (
22 structure::arrangement::ArrangerObjectUuidReference object_ref)
23 : QUndoCommand (QObject::tr ("Add Clip")), slot_ (clip_slot),
24 object_ref_ (std::move (object_ref))
25 {
26 }
27
28 void redo () override
29 {
30 // Capture whatever the slot held before
31 if (!captured_previous_)
32 {
33 previous_clip_ = slot_.clipReference ();
34 captured_previous_ = true;
35 }
36 slot_.setClip (object_ref_.get_object_as<structure::arrangement::Clip> ());
37 }
38 void undo () override
39 {
40 if (previous_clip_.has_value ())
41 slot_.setClip (
42 previous_clip_->get_object_as<structure::arrangement::Clip> ());
43 else
44 slot_.clearClip ();
45 }
46
47private:
49 structure::arrangement::ArrangerObjectUuidReference object_ref_;
50 std::optional<structure::arrangement::ArrangerObjectUuidReference>
51 previous_clip_;
52 bool captured_previous_{ false };
53};
54
55} // namespace zrythm::commands
Intermediate base class for all clip types.
Definition clip.h:37