Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
transport_action.h
1// SPDX-FileCopyrightText: © 2020-2021, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __ACTIONS_TRANSPORT_ACTION_H__
5#define __ACTIONS_TRANSPORT_ACTION_H__
6
7#include "gui/backend/backend/actions/undoable_action.h"
8#include "utils/icloneable.h"
9#include "utils/types.h"
10
11namespace zrythm::gui::actions
12{
13
17class TransportAction : public QObject, public UndoableAction
18{
19 Q_OBJECT
20 QML_ELEMENT
21 DEFINE_UNDOABLE_ACTION_QML_PROPERTIES (TransportAction)
22
23public:
24 enum class Type
25 {
26 TempoChange,
27 BeatsPerBarChange,
28 BeatUnitChange,
29 };
30
31 TransportAction (QObject * parent = nullptr);
32
41 bpm_t bpm_before,
42 bpm_t bpm_after,
43 bool already_done,
44 QObject * parent = nullptr);
45
56 Type type,
57 int before,
58 int after,
59 bool already_done,
60 QObject * parent = nullptr);
61
62 friend void init_from (
63 TransportAction &obj,
64 const TransportAction &other,
65 utils::ObjectCloneType clone_type);
66
67 QString to_string () const override;
68
69private:
70 void init_loaded_impl () override { }
71 void undo_impl () override;
72 void perform_impl () override;
73
74 bool need_update_positions_from_ticks ()
75 {
76 return type_ == Type::TempoChange || type_ == Type::BeatsPerBarChange;
77 }
78
79 void do_or_undo (bool do_it);
80
81public:
82 Type type_ = Type::TempoChange;
83
84 bpm_t bpm_before_ = 0.0;
85 bpm_t bpm_after_ = 0.0;
86
87 int int_before_ = 0;
88 int int_after_ = 0;
89
91 bool already_done_ = false;
92
94 bool musical_mode_ = false;
95};
96
97}; // namespace zrythm::gui::actions
98
99#endif
TransportAction(Type type, int before, int after, bool already_done, QObject *parent=nullptr)
Construct a new Transport object for a beat unit/beats per bar change.
TransportAction(bpm_t bpm_before, bpm_t bpm_after, bool already_done, QObject *parent=nullptr)
Construct a new Transport Action object for a BPM change.
QString to_string() const override
Stringizes the action to be used in Undo/Redo buttons.
bool musical_mode_
Whether musical mode was enabled when this action was made.
bool already_done_
Flag whether the action was already performed the first time.
float bpm_t
The BPM type.
Definition types.h:70