Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_region.h
1// SPDX-FileCopyrightText: © 2019-2021, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "gui/dsp/arranger_object_owner.h"
7#include "gui/dsp/chord_object.h"
8#include "gui/dsp/region.h"
9
15
16class ChordRegion final
17 : public QObject,
18 public RegionImpl<ChordRegion>,
19 public ArrangerObjectOwner<ChordObject>,
20 public ICloneable<ChordRegion>
21{
22 Q_OBJECT
23 QML_ELEMENT
24 DEFINE_ARRANGER_OBJECT_QML_PROPERTIES (ChordRegion)
25 DEFINE_REGION_QML_PROPERTIES (ChordRegion)
26 DEFINE_ARRANGER_OBJECT_OWNER_QML_PROPERTIES (
28 chordObjects,
30
31 friend class RegionImpl<ChordRegion>;
32
33public:
34 DECLARE_FINAL_ARRANGER_OBJECT_CONSTRUCTORS (ChordRegion)
35
36 using RegionT = RegionImpl<ChordRegion>;
37
38 bool
39 validate (bool is_project, dsp::FramesPerTick frames_per_tick) const override;
40
41 Location get_location (const ChordObject &) const override
42 {
43 return { .track_id_ = track_id_, .owner_ = get_uuid () };
44 }
45
46 std::string
47 get_field_name_for_serialization (const ChordObject *) const override
48 {
49 return "chordObjects";
50 }
51
52 void init_after_cloning (const ChordRegion &other, ObjectCloneType clone_type)
53 override;
54
55private:
56 friend void to_json (nlohmann::json &j, const ChordRegion &cr)
57 {
58 to_json (j, static_cast<const ArrangerObject &> (cr));
59 to_json (j, static_cast<const BoundedObject &> (cr));
60 to_json (j, static_cast<const LoopableObject &> (cr));
61 to_json (j, static_cast<const MuteableObject &> (cr));
62 to_json (j, static_cast<const NamedObject &> (cr));
63 to_json (j, static_cast<const ColoredObject &> (cr));
64 to_json (j, static_cast<const Region &> (cr));
65 to_json (j, static_cast<const ArrangerObjectOwner &> (cr));
66 }
67 friend void from_json (const nlohmann::json &j, ChordRegion &cr)
68 {
69 from_json (j, static_cast<ArrangerObject &> (cr));
70 from_json (j, static_cast<BoundedObject &> (cr));
71 from_json (j, static_cast<LoopableObject &> (cr));
72 from_json (j, static_cast<MuteableObject &> (cr));
73 from_json (j, static_cast<NamedObject &> (cr));
74 from_json (j, static_cast<ColoredObject &> (cr));
75 from_json (j, static_cast<Region &> (cr));
76 from_json (j, static_cast<ArrangerObjectOwner &> (cr));
77 }
78};
79
81 return fmt::format (
82 "ChordRegion[id: {}, {}]", cr.get_uuid (), static_cast<const Region &> (cr));
83})
84
Base class for all objects in the arranger.
std::optional< TrackUuid > track_id_
ID of the track this object belongs to.
Base class for all objects in the arranger that have a length.
The ChordObject class represents a chord inside a ChordRegion.
void init_after_cloning(const ChordRegion &other, ObjectCloneType clone_type) override
Initializes the cloned object.
bool validate(bool is_project, dsp::FramesPerTick frames_per_tick) const override
Validates the arranger object.
Base class for objects that have a name.
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:112
#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