Zrythm v2.0.0-alpha.1+31.4967fd053471
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
edit_chord_object_command.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "commands/chord_pad_commands.h"
7#include "structure/arrangement/chord_object.h"
8
9#include <QPointer>
10#include <QUndoCommand>
11
12namespace zrythm::commands
13{
14
22class EditChordObjectCommand : public QUndoCommand
23{
24public:
25 EditChordObjectCommand (
27 const dsp::ChordDescriptor &new_descriptor)
28 : object_ (chord_object),
29 before_ (
30 ChordPadState::from_descriptor (*chord_object->chordDescriptor ())),
31 after_ (ChordPadState::from_descriptor (new_descriptor))
32 {
33 setText (QObject::tr ("Edit chord"));
34 }
35
36 int id () const override { return 1762954987; }
37
38 bool mergeWith (const QUndoCommand * other) override
39 {
40 if (other->id () != id ())
41 return false;
42 const auto * o = static_cast<const EditChordObjectCommand *> (other);
43 if (object_ == nullptr || o->object_ == nullptr)
44 return false;
45 if (object_.data () != o->object_.data ())
46 return false;
47 after_ = o->after_;
48 return true;
49 }
50
51 void undo () override
52 {
53 if (object_)
54 before_.apply_to (*object_->chordDescriptor ());
55 }
56
57 void redo () override
58 {
59 if (object_)
60 after_.apply_to (*object_->chordDescriptor ());
61 }
62
63private:
64 QPointer<structure::arrangement::ChordObject> object_;
65 ChordPadState before_;
66 ChordPadState after_;
67};
68
69} // namespace zrythm::commands
Describes a musical chord by its root note, type, accent, inversion, and optional bass note.
A chord placed inside a ChordRegion on the chord track.