Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
project_ui_state.h
1// SPDX-FileCopyrightText: © 2018-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <map>
7#include <string_view>
8
9#include "dsp/audio_input_selection.h"
10#include "dsp/midi_input_selection.h"
11#include "dsp/snap_grid.h"
12#include "structure/arrangement/timeline.h"
13#include "structure/project/arranger_tool.h"
14#include "structure/project/clip_editor.h"
15#include "structure/project/project.h"
16#include "structure/tracks/track.h"
17#include "utils/qt.h"
18
19#include <QtQmlIntegration/qqmlintegration.h>
20
21#include <nlohmann/json_fwd.hpp>
22
23namespace zrythm::structure::project
24{
25
38class ProjectUiState : public QObject
39{
40 Q_OBJECT
41 Q_PROPERTY (
42 zrythm::structure::arrangement::Timeline * timeline READ timeline CONSTANT
43 FINAL)
44 Q_PROPERTY (
45 zrythm::structure::project::ArrangerTool * tool READ tool CONSTANT FINAL)
46 Q_PROPERTY (
47 zrythm::structure::project::ClipEditor * clipEditor READ clipEditor CONSTANT
48 FINAL)
49 Q_PROPERTY (
50 zrythm::dsp::SnapGrid * snapGridTimeline READ snapGridTimeline CONSTANT FINAL)
51 Q_PROPERTY (
52 zrythm::dsp::SnapGrid * snapGridEditor READ snapGridEditor CONSTANT FINAL)
53 QML_ELEMENT
54 QML_UNCREATABLE ("")
55
56public:
63 ProjectUiState (Project &project, utils::AppSettings &app_settings);
64
65 structure::project::ArrangerTool * tool () const;
66 structure::project::ClipEditor * clipEditor () const;
67 structure::arrangement::Timeline * timeline () const;
68 dsp::SnapGrid * snapGridTimeline () const;
69 dsp::SnapGrid * snapGridEditor () const;
70
71 Q_INVOKABLE dsp::AudioInputSelection *
72 audioInputSelectionForTrack (const structure::tracks::Track * track);
73
74 Q_INVOKABLE dsp::MidiInputSelection *
75 midiInputSelectionForTrack (const structure::tracks::Track * track);
76
77 dsp::AudioInputSelection *
78 find_audio_input_selection (const structure::tracks::Track::Uuid &uuid) const;
79
80 dsp::MidiInputSelection *
81 find_midi_input_selection (const structure::tracks::Track::Uuid &uuid) const;
82
83 static constexpr auto kAudioInputSelectionsKey = "audioInputSelections"sv;
84 static constexpr auto kMidiInputSelectionsKey = "midiInputSelections"sv;
85
86Q_SIGNALS:
87 void audioInputSelectionChanged ();
88 void midiInputDeviceChanged ();
89
90private:
91 dsp::AudioInputSelection * get_or_create_audio_input_selection (
92 const structure::tracks::Track::Uuid &uuid);
93
94 dsp::MidiInputSelection * get_or_create_midi_input_selection (
95 const structure::tracks::Track::Uuid &uuid);
96
97private:
98 static constexpr auto kSnapGridTimelineKey = "snapGridTimeline"sv;
99 static constexpr auto kSnapGridEditorKey = "snapGridEditor"sv;
100 friend void to_json (nlohmann::json &j, const ProjectUiState &p);
101 friend void from_json (const nlohmann::json &j, ProjectUiState &p);
102
103private:
104 Project &project_;
105 utils::AppSettings &app_settings_;
106
108 utils::QObjectUniquePtr<structure::project::ArrangerTool> tool_;
109
111 utils::QObjectUniquePtr<structure::project::ClipEditor> clip_editor_;
112
114 utils::QObjectUniquePtr<structure::arrangement::Timeline> timeline_;
115
117 utils::QObjectUniquePtr<dsp::SnapGrid> snap_grid_timeline_;
118
120 utils::QObjectUniquePtr<dsp::SnapGrid> snap_grid_editor_;
121
124 std::map<
125 structure::tracks::Track::Uuid,
126 utils::QObjectUniquePtr<dsp::AudioInputSelection>>
127 audio_input_selections_;
128
131 std::map<
132 structure::tracks::Track::Uuid,
133 utils::QObjectUniquePtr<dsp::MidiInputSelection>>
134 midi_input_selections_;
135};
136
137} // namespace zrythm::structure::project
Snap/grid information.
Definition snap_grid.h:23
Backend for the clip editor part of the UI.
Definition clip_editor.h:23
ProjectUiState(Project &project, utils::AppSettings &app_settings)
Constructs ProjectUiState with references from the given Project.
Core functionality of a Zrythm project.
Definition project.h:54
String utilities.