Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
region.h
1// SPDX-FileCopyrightText: © 2018-2022, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/arrangement/colored_object.h"
7#include "structure/arrangement/loopable_object.h"
8#include "structure/arrangement/muteable_object.h"
9#include "structure/arrangement/named_object.h"
10
11namespace zrythm::structure::arrangement
12{
13
14class RegionMixin : public QObject
15{
16 Q_OBJECT
17 Q_PROPERTY (ArrangerObjectBounds * bounds READ bounds CONSTANT)
18 Q_PROPERTY (ArrangerObjectLoopRange * loopRange READ loopRange CONSTANT)
19 Q_PROPERTY (ArrangerObjectName * name READ name CONSTANT)
20 Q_PROPERTY (ArrangerObjectColor * color READ color CONSTANT)
21 Q_PROPERTY (ArrangerObjectMuteFunctionality * mute READ mute CONSTANT)
22 QML_ELEMENT
23 QML_UNCREATABLE ("")
24
25public:
26 RegionMixin (const dsp::AtomicPositionQmlAdapter &start_position);
27
28 // ========================================================================
29 // QML Interface
30 // ========================================================================
31
32 ArrangerObjectBounds * bounds () const { return bounds_.get (); }
33 ArrangerObjectLoopRange * loopRange () const { return loop_range_.get (); }
34 ArrangerObjectName * name () const { return name_.get (); }
35 ArrangerObjectColor * color () const { return color_.get (); }
36 ArrangerObjectMuteFunctionality * mute () const { return mute_.get (); }
37
38 // ========================================================================
39
40protected:
41 friend void init_from (
42 RegionMixin &obj,
43 const RegionMixin &other,
44 utils::ObjectCloneType clone_type)
45 {
46 init_from (*obj.bounds_, *other.bounds_, clone_type);
47 init_from (*obj.loop_range_, *other.loop_range_, clone_type);
48 init_from (*obj.name_, *other.name_, clone_type);
49 init_from (*obj.color_, *other.color_, clone_type);
50 init_from (*obj.mute_, *other.mute_, clone_type);
51 }
52
53private:
54 static constexpr auto kBoundsKey = "bounds"sv;
55 static constexpr auto kLoopRangeKey = "loop_range"sv;
56 static constexpr auto kNameKey = "name"sv;
57 static constexpr auto kColorKey = "color"sv;
58 static constexpr auto kMuteKey = "mute"sv;
59 friend void to_json (nlohmann::json &j, const RegionMixin &region)
60 {
61 j[kBoundsKey] = region.bounds_;
62 j[kLoopRangeKey] = region.loop_range_;
63 j[kNameKey] = region.name_;
64 j[kColorKey] = region.color_;
65 j[kMuteKey] = region.mute_;
66 }
67 friend void from_json (const nlohmann::json &j, RegionMixin &region)
68 {
69 j.at (kBoundsKey).get_to (*region.bounds_);
70 j.at (kLoopRangeKey).get_to (*region.loop_range_);
71 j.at (kNameKey).get_to (*region.name_);
72 j.at (kColorKey).get_to (*region.color_);
73 j.at (kMuteKey).get_to (*region.mute_);
74 }
75
76private:
82
83 BOOST_DESCRIBE_CLASS (
84 RegionMixin,
85 (),
86 (),
87 (),
88 (bounds_, loop_range_, mute_, color_, name_))
89};
90
91} // namespace arrangement
Adds length functionality to arranger objects.
Name functionality for arranger objects.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:38