Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
marker.h
1// SPDX-FileCopyrightText: © 2019-2021, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __AUDIO_MARKER_H__
5#define __AUDIO_MARKER_H__
6
12
13#include "gui/dsp/bounded_object.h"
14#include "gui/dsp/named_object.h"
15#include "gui/dsp/timeline_object.h"
16#include "utils/icloneable.h"
17
21class Marker final
22 : public QObject,
23 public TimelineObject,
24 public NamedObject,
25 public ICloneable<Marker>
26{
27 Q_OBJECT
28 QML_ELEMENT
29 DEFINE_ARRANGER_OBJECT_QML_PROPERTIES (Marker)
30 DEFINE_NAMEABLE_OBJECT_QML_PROPERTIES (Marker)
31
32public:
36 enum class Type
37 {
44 };
45
46 Marker (
47 ArrangerObjectRegistry &obj_registry,
48 TrackResolver track_resolver,
49 NameValidator name_validator,
50 QObject * parent = nullptr);
51
52 bool is_start () const { return marker_type_ == Type::Start; }
53 bool is_end () const { return marker_type_ == Type::End; }
54
55 bool is_deletable () const override
56 {
58 }
59
60 void
61 init_after_cloning (const Marker &other, ObjectCloneType clone_type) override;
62
63 ArrangerObjectPtrVariant
64 add_clone_to_project (bool fire_events) const override;
65
66 ArrangerObjectPtrVariant insert_clone_to_project () const override;
67
68 bool
69 validate (bool is_project, dsp::FramesPerTick frames_per_tick) const override;
70
71private:
72 static constexpr std::string_view kMarkerTypeKey = "markerType";
73 friend void to_json (nlohmann::json &j, const Marker &m)
74 {
75 to_json (j, static_cast<const ArrangerObject &> (m));
76 to_json (j, static_cast<const NamedObject &> (m));
77 j[kMarkerTypeKey] = m.marker_type_;
78 }
79 friend void from_json (const nlohmann::json &j, Marker &m)
80 {
81 from_json (j, static_cast<ArrangerObject &> (m));
82 from_json (j, static_cast<NamedObject &> (m));
83 j.at (kMarkerTypeKey).get_to (m.marker_type_);
84 }
85
86public:
89};
90
92 return fmt::format (
93 "Marker[name: {}, type: {}, position: {}]", m.get_name (),
94 ENUM_NAME (m.marker_type_), m.get_position ());
95})
96
100
101#endif
Base class for all objects in the arranger.
auto get_position() const
Getter.
Marker for the MarkerTrack.
Definition marker.h:26
void init_after_cloning(const Marker &other, ObjectCloneType clone_type) override
Initializes the cloned object.
Type
Marker type.
Definition marker.h:37
@ End
Song end Marker that cannot be deleted.
Definition marker.h:41
@ Custom
Custom Marker.
Definition marker.h:43
@ Start
Song start Marker that cannot be deleted.
Definition marker.h:39
ArrangerObjectPtrVariant add_clone_to_project(bool fire_events) const override
Appends the ArrangerObject to where it belongs in the project (eg, a Track), without taking into acco...
ArrangerObjectPtrVariant insert_clone_to_project() const override
Inserts the object where it belongs in the project (eg, a Track).
bool is_deletable() const override
Returns whether the given object is deletable or not (eg, start marker).
Definition marker.h:55
bool validate(bool is_project, dsp::FramesPerTick frames_per_tick) const override
Validates the arranger object.
Type marker_type_
Marker type.
Definition marker.h:88
Base class for objects that have a name.
utils::Utf8String get_name() const
Returns the name of the object.
#define DEFINE_OBJECT_FORMATTER(obj_type, function_prefix, formatter_func)
Defines a formatter for the given object type.
Definition format.h:80
ObjectCloneType
Definition icloneable.h:25