Zrythm v2.0.0-DEV
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 <utility>
7
8#include "structure/arrangement/arranger_object_all.h"
9#include "structure/arrangement/arranger_object_owner.h"
10
11#include <QUndoCommand>
12
13namespace zrythm::commands
14{
15
16template <structure::arrangement::FinalArrangerObjectSubclass ObjectT>
17class AddArrangerObjectCommand : public QUndoCommand
18{
19public:
20 AddArrangerObjectCommand (
22 structure::arrangement::ArrangerObjectUuidReference object_ref)
23 : QUndoCommand (QObject::tr ("Add Object")), object_owner_ (object_owner),
24 object_ref_ (std::move (object_ref))
25 {
26 }
27
28 void undo () override { object_owner_.remove_object (object_ref_.id ()); }
29 void redo () override { object_owner_.add_object (object_ref_); }
30
31private:
33 structure::arrangement::ArrangerObjectUuidReference object_ref_;
34};
35
41template <structure::arrangement::FinalArrangerObjectSubclass ObjectT>
43 : public AddArrangerObjectCommand<ObjectT>
44{
45public:
46 static constexpr auto CommandId = 1762954668;
47 using AddArrangerObjectCommand<ObjectT>::AddArrangerObjectCommand;
48
49 int id () const override { return CommandId; }
50};
51
52} // namespace zrythm::commands
Specialization of AddArrangerObjectCommand with a custom ID to be used for special handling by the un...