Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
range_action.h
1// SPDX-FileCopyrightText: © 2020-2021, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/transport.h"
7#include "gui/backend/backend/actions/undoable_action.h"
8#include "structure/arrangement/arranger_object_span.h"
9
10namespace zrythm::gui::actions
11{
12
13class RangeAction : public QObject, public UndoableAction
14{
15 Q_OBJECT
16 QML_ELEMENT
17 DEFINE_UNDOABLE_ACTION_QML_PROPERTIES (RangeAction)
18
19 using ArrangerObjectSpan = structure::arrangement::ArrangerObjectSpan;
20 using ArrangerObject = structure::arrangement::ArrangerObject;
21 using Transport = dsp::Transport;
22
23public:
24 enum class Type
25 {
26 InsertSilence,
27 Remove,
28 };
29
30public:
31 RangeAction (QObject * parent = nullptr);
32 RangeAction (
33 Type type,
34 signed_frame_t start_pos,
35 signed_frame_t end_pos,
36 QObject * parent = nullptr);
37
38 QString to_string () const override;
39
40 double get_range_size_in_ticks () const
41 {
42 throw std::runtime_error ("Not implemented");
43 // return end_pos_.ticks_ - start_pos_.ticks_;
44 }
45
46 friend void init_from (
47 RangeAction &obj,
48 const RangeAction &other,
49 utils::ObjectCloneType clone_type);
50
51private:
52 void init_loaded_impl () override;
53
54 void perform_impl () override;
55 void undo_impl () override;
56
57 ArrangerObjectSpan get_before_objects () const;
58
59public:
62 signed_frame_t end_pos_{};
63
65 Type type_ = Type::InsertSilence;
66
69 std::vector<ArrangerObject::Uuid> affected_objects_before_;
70
78 std::vector<ArrangerObject::Uuid> objects_removed_;
79
85 std::vector<ArrangerObject::Uuid> objects_added_;
86
94 std::vector<ArrangerObject::Uuid> objects_moved_;
95
97 // std::vector<ArrangerObject::Uuid> sel_after_;
98
100 std::unique_ptr<Transport> transport_;
101
103 bool first_run_ = false;
104};
105
106class RangeInsertSilenceAction : public RangeAction
107{
108public:
109 RangeInsertSilenceAction (signed_frame_t start_pos, signed_frame_t end_pos)
110 : RangeAction (Type::InsertSilence, start_pos, end_pos)
111 {
112 }
113};
114
115class RangeRemoveAction : public RangeAction
116{
117public:
118 RangeRemoveAction (signed_frame_t start_pos, signed_frame_t end_pos)
119 : RangeAction (Type::Remove, start_pos, end_pos)
120 {
121 }
122};
123
124}; // namespace zrythm::gui::actions
The Transport class represents the transport controls and state for an audio engine.
Definition transport.h:45
std::vector< ArrangerObject::Uuid > affected_objects_before_
Selections before the action, starting from objects intersecting with the start position and ending i...
signed_frame_t start_pos_
Range positions in frames.
std::vector< ArrangerObject::Uuid > objects_moved_
Objects moved (not added/removed) during the action.
QString to_string() const override
Stringizes the action to be used in Undo/Redo buttons.
std::vector< ArrangerObject::Uuid > objects_removed_
Objects removed from the project while performing the action.
std::unique_ptr< Transport > transport_
Selections after the action.
bool first_run_
Whether this is the first run.
std::vector< ArrangerObject::Uuid > objects_added_
Objects added to the project while performing the action.
Track span that offers helper methods on a range of tracks.
Base class for all objects in the arranger.
int_fast64_t signed_frame_t
Signed type for frame index.
Definition types.h:75