26class ClipEditor :
public QObject
29 Q_PROPERTY (QVariant region READ region NOTIFY regionChanged)
30 Q_PROPERTY (QVariant track READ track NOTIFY regionChanged)
36 getChordEditor CONSTANT FINAL)
39 getAudioClipEditor CONSTANT FINAL)
42 getAutomationEditor CONSTANT FINAL)
46 using ArrangerObjectRegistry = structure::arrangement::ArrangerObjectRegistry;
47 using TrackResolver = structure::tracks::TrackResolver;
48 using TrackPtrVariant = structure::tracks::TrackPtrVariant;
49 using TrackUuid = structure::tracks::TrackUuid;
51 using ArrangerObjectPtrVariant =
52 structure::arrangement::ArrangerObjectPtrVariant;
56 ArrangerObjectRegistry ®,
57 TrackResolver track_resolver,
58 QObject * parent =
nullptr);
66 return piano_roll_.get ();
70 return chord_editor_.get ();
74 return audio_clip_editor_.get ();
78 return automation_editor_.get ();
81 QVariant region ()
const
85 return QVariant::fromStdVariant (get_region_and_track ()->first);
90 QVariant track ()
const
94 return QVariant::fromStdVariant (get_region_and_track ()->second);
99 Q_INVOKABLE
void setRegion (QVariant region, QVariant track);
100 Q_INVOKABLE
void unsetRegion ();
101 Q_SIGNAL
void regionChanged (QVariant region);
124 Q_EMIT regionChanged (
125 QVariant::fromStdVariant (get_region_and_track ().value ().first));
128 bool has_region ()
const {
return region_id_.has_value (); }
130 std::optional<std::pair<ArrangerObjectPtrVariant, TrackPtrVariant>>
131 get_region_and_track ()
const;
133 friend void init_from (
135 const ClipEditor &other,
136 utils::ObjectCloneType clone_type)
140 init_from (*obj.audio_clip_editor_, *other.audio_clip_editor_, clone_type);
141 init_from (*obj.automation_editor_, *other.automation_editor_, clone_type);
142 init_from (*obj.chord_editor_, *other.chord_editor_, clone_type);
143 init_from (*obj.piano_roll_, *other.piano_roll_, clone_type);
147 static constexpr auto kRegionIdKey =
"regionId"sv;
148 static constexpr auto kPianoRollKey =
"pianoRoll"sv;
149 static constexpr auto kAutomationEditorKey =
"automationEditor"sv;
150 static constexpr auto kChordEditorKey =
"chordEditor"sv;
151 static constexpr auto kAudioClipEditorKey =
"audioClipEditor"sv;
152 friend void to_json (nlohmann::json &j,
const ClipEditor &editor)
155 j[kPianoRollKey] = editor.piano_roll_;
156 j[kAutomationEditorKey] = editor.automation_editor_;
157 j[kChordEditorKey] = editor.chord_editor_;
158 j[kAudioClipEditorKey] = editor.audio_clip_editor_;
160 friend void from_json (
const nlohmann::json &j, ClipEditor &editor)
162 j.at (kRegionIdKey).get_to (editor.
region_id_);
163 j.at (kPianoRollKey).get_to (*editor.piano_roll_);
164 j.at (kAutomationEditorKey).get_to (*editor.automation_editor_);
165 j.at (kChordEditorKey).get_to (*editor.chord_editor_);
166 j.at (kAudioClipEditorKey).get_to (*editor.audio_clip_editor_);
170 ArrangerObjectRegistry &object_registry_;
171 TrackResolver track_resolver_;
174 std::optional<std::pair<ArrangerObject::Uuid, TrackUuid>>
region_id_;
176 utils::QObjectUniquePtr<structure::arrangement::PianoRoll> piano_roll_;
177 utils::QObjectUniquePtr<structure::arrangement::AudioClipEditor>
179 utils::QObjectUniquePtr<structure::arrangement::AutomationEditor>
181 utils::QObjectUniquePtr<structure::arrangement::ChordEditor> chord_editor_;