Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
add_arranger_object_command.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <type_traits>
7#include <utility>
8
9#include "structure/arrangement/arranger_object_all.h"
10#include "structure/arrangement/arranger_object_owner.h"
11
12#include <QUndoCommand>
13
14namespace zrythm::commands
15{
16
17template <structure::arrangement::FinalArrangerObjectSubclass ObjectT>
18class AddArrangerObjectCommand : public QUndoCommand
19{
20public:
30 static constexpr int CommandId =
31 (std::is_same_v<ObjectT, structure::arrangement::TempoObject>
32 || std::is_same_v<ObjectT, structure::arrangement::TimeSignatureObject>)
33 ? 1762954668
34 : -1;
35
36 AddArrangerObjectCommand (
38 structure::arrangement::ArrangerObjectUuidReference object_ref)
39 : QUndoCommand (QObject::tr ("Add Object")), object_owner_ (object_owner),
40 object_ref_ (std::move (object_ref))
41 {
42 }
43
44 void undo () override { object_owner_.remove_object (object_ref_.id ()); }
45 void redo () override { object_owner_.add_object (object_ref_); }
46
47 int id () const override { return CommandId; }
48
49private:
50 structure::arrangement::ArrangerObjectOwner<ObjectT> &object_owner_;
51 structure::arrangement::ArrangerObjectUuidReference object_ref_;
52};
53
54} // namespace zrythm::commands
static constexpr int CommandId
QUndoCommand id for this addition.