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/clip.h"
7#include "structure/project/audio_clip_editor.h"
8#include "structure/project/automation_editor.h"
9#include "structure/project/chord_editor.h"
10#include "structure/project/midi_editor.h"
11#include "structure/tracks/track.h"
12#include "structure/tracks/track_fwd.h"
13#include "utils/iobject_registry.h"
14
15class ArrangerSelections;
16
17namespace zrythm::structure::project
18{
19
23class ClipEditor : public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY (
27 zrythm::structure::arrangement::Clip * clipObject READ clip NOTIFY
28 clipObjectChanged)
29 Q_PROPERTY (QVariant track READ track NOTIFY clipObjectChanged)
30 Q_PROPERTY (
31 zrythm::structure::project::MidiEditor * midiEditor READ midiEditor CONSTANT
32 FINAL)
33 Q_PROPERTY (
34 zrythm::structure::project::ChordEditor * chordEditor READ chordEditor
35 CONSTANT FINAL)
36 Q_PROPERTY (
38 audioClipEditor CONSTANT FINAL)
39 Q_PROPERTY (
41 automationEditor CONSTANT FINAL)
42 QML_ELEMENT
43 QML_UNCREATABLE ("")
44
45 using TrackUuid = structure::tracks::TrackUuid;
46 using ArrangerObject = structure::arrangement::ArrangerObject;
47 using Track = structure::tracks::Track;
48
49public:
50 ClipEditor (utils::IObjectRegistry &reg, QObject * parent = nullptr);
51
52 // ============================================================================
53 // QML Interface
54 // ============================================================================
55
56 MidiEditor * midiEditor () const { return midi_editor_.get (); }
57 ChordEditor * chordEditor () const { return chord_editor_.get (); }
58 AudioClipEditor * audioClipEditor () const
59 {
60 return audio_clip_editor_.get ();
61 }
62 AutomationEditor * automationEditor () const
63 {
64 return automation_editor_.get ();
65 }
66
67 arrangement::Clip * clip () const;
68 QVariant track () const;
69 Q_INVOKABLE void setClip (QVariant clip, QVariant track);
70 Q_INVOKABLE void unsetClip ();
71 Q_SIGNAL void clipObjectChanged ();
72
73 // ============================================================================
74
78 void init_loaded ();
79
83 void init ();
84
88 void set_clip (ArrangerObject::Uuid clip_id, TrackUuid track_id);
89
90 bool has_clip () const { return clip_id_.has_value (); }
91
92 std::optional<std::pair<ArrangerObject *, Track *>>
93 get_clip_and_track () const;
94
95 friend void init_from (
96 ClipEditor &obj,
97 const ClipEditor &other,
98 utils::ObjectCloneType clone_type);
99
100private:
101 static constexpr auto kClipIdKey = "clipId"sv;
102 static constexpr auto kMidiEditorKey = "midiEditor"sv;
103 static constexpr auto kAutomationEditorKey = "automationEditor"sv;
104 static constexpr auto kChordEditorKey = "chordEditor"sv;
105 static constexpr auto kAudioClipEditorKey = "audioClipEditor"sv;
106 friend void to_json (nlohmann::json &j, const ClipEditor &editor);
107 friend void from_json (const nlohmann::json &j, ClipEditor &editor);
108
109private:
110 utils::IObjectRegistry &object_registry_;
111
113 std::optional<std::pair<ArrangerObject::Uuid, TrackUuid>> clip_id_;
114
119};
120
121} // namespace zrythm::structure::project
Base class for all objects in the arranger.
Intermediate base class for all clip types.
Definition clip.h:37
View state for the chord editor lane.
Backend for the clip editor part of the UI.
Definition clip_editor.h:24
void init()
Inits the clip editor.
void set_clip(ArrangerObject::Uuid clip_id, TrackUuid track_id)
Sets the track and refreshes the piano roll widgets.
void init_loaded()
Inits the ClipEditor after a Project is loaded.
MIDI editor serializable backend.
Definition midi_editor.h:80
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