Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
clip_editor.h
1// SPDX-FileCopyrightText: © 2019-2021, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/arrangement/audio_clip_editor.h"
7#include "structure/arrangement/automation_editor.h"
8#include "structure/arrangement/chord_editor.h"
9#include "structure/arrangement/piano_roll.h"
10#include "structure/tracks/track.h"
11#include "structure/tracks/track_fwd.h"
12#include "utils/iobject_registry.h"
13
14class ArrangerSelections;
15
16namespace zrythm::structure::project
17{
18
22class ClipEditor : public QObject
23{
24 Q_OBJECT
25 Q_PROPERTY (QVariant region READ region NOTIFY regionChanged)
26 Q_PROPERTY (QVariant track READ track NOTIFY regionChanged)
27 Q_PROPERTY (
28 zrythm::structure::arrangement::PianoRoll * pianoRoll READ getPianoRoll
29 CONSTANT FINAL)
30 Q_PROPERTY (
32 getChordEditor CONSTANT FINAL)
33 Q_PROPERTY (
35 getAudioClipEditor CONSTANT FINAL)
36 Q_PROPERTY (
38 getAutomationEditor CONSTANT FINAL)
39 QML_ELEMENT
40 QML_UNCREATABLE ("")
41
42 using TrackUuid = structure::tracks::TrackUuid;
43 using ArrangerObject = structure::arrangement::ArrangerObject;
44 using Track = structure::tracks::Track;
45
46public:
47 ClipEditor (utils::IObjectRegistry &reg, QObject * parent = nullptr);
48
49 // ============================================================================
50 // QML Interface
51 // ============================================================================
52
53 structure::arrangement::PianoRoll * getPianoRoll () const
54 {
55 return piano_roll_.get ();
56 }
57 structure::arrangement::ChordEditor * getChordEditor () const
58 {
59 return chord_editor_.get ();
60 }
61 structure::arrangement::AudioClipEditor * getAudioClipEditor () const
62 {
63 return audio_clip_editor_.get ();
64 }
65 structure::arrangement::AutomationEditor * getAutomationEditor () const
66 {
67 return automation_editor_.get ();
68 }
69
70 QVariant region () const;
71 QVariant track () const;
72 Q_INVOKABLE void setRegion (QVariant region, QVariant track);
73 Q_INVOKABLE void unsetRegion ();
74 Q_SIGNAL void regionChanged (QVariant region);
75
76 // ============================================================================
77
81 void init_loaded ();
82
86 void init ();
87
91 void set_region (ArrangerObject::Uuid region_id, TrackUuid track_id);
92
93 bool has_region () const { return region_id_.has_value (); }
94
95 std::optional<std::pair<ArrangerObject *, Track *>>
96 get_region_and_track () const;
97
98 friend void init_from (
99 ClipEditor &obj,
100 const ClipEditor &other,
101 utils::ObjectCloneType clone_type);
102
103private:
104 static constexpr auto kRegionIdKey = "regionId"sv;
105 static constexpr auto kPianoRollKey = "pianoRoll"sv;
106 static constexpr auto kAutomationEditorKey = "automationEditor"sv;
107 static constexpr auto kChordEditorKey = "chordEditor"sv;
108 static constexpr auto kAudioClipEditorKey = "audioClipEditor"sv;
109 friend void to_json (nlohmann::json &j, const ClipEditor &editor);
110 friend void from_json (const nlohmann::json &j, ClipEditor &editor);
111
112private:
113 utils::IObjectRegistry &object_registry_;
114
116 std::optional<std::pair<ArrangerObject::Uuid, TrackUuid>> region_id_;
117
120 audio_clip_editor_;
122 automation_editor_;
124};
125
126} // namespace zrythm::structure::project
Base class for all objects in the arranger.
Audio clip editor serializable backend.
Backend for the chord editor.
Piano roll serializable backend.
Definition piano_roll.h:76
Backend for the clip editor part of the UI.
Definition clip_editor.h:23
void set_region(ArrangerObject::Uuid region_id, TrackUuid track_id)
Sets the track and refreshes the piano roll widgets.
void init()
Inits the clip editor.
void init_loaded()
Inits the ClipEditor after a Project is loaded.
Represents a track in the project.
Definition track.h:60
Abstract interface for a UUID-keyed object registry.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:36