Zrythm v2.0.0-DEV
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/snap_grid.h"
11#include "structure/arrangement/timeline.h"
12#include "structure/project/arranger_tool.h"
13#include "structure/project/clip_editor.h"
14#include "structure/project/project.h"
15#include "structure/tracks/track.h"
16#include "utils/qt.h"
17
18#include <QtQmlIntegration/qqmlintegration.h>
19
20#include <nlohmann/json_fwd.hpp>
21
22namespace zrythm::structure::project
23{
24
37class ProjectUiState : public QObject
38{
39 Q_OBJECT
40 Q_PROPERTY (
41 zrythm::structure::arrangement::Timeline * timeline READ timeline CONSTANT
42 FINAL)
43 Q_PROPERTY (
44 zrythm::structure::project::ArrangerTool * tool READ tool CONSTANT FINAL)
45 Q_PROPERTY (
46 zrythm::structure::project::ClipEditor * clipEditor READ clipEditor CONSTANT
47 FINAL)
48 Q_PROPERTY (
49 zrythm::dsp::SnapGrid * snapGridTimeline READ snapGridTimeline CONSTANT FINAL)
50 Q_PROPERTY (
51 zrythm::dsp::SnapGrid * snapGridEditor READ snapGridEditor CONSTANT FINAL)
52 QML_ELEMENT
53 QML_UNCREATABLE ("")
54
55public:
62 ProjectUiState (Project &project, utils::AppSettings &app_settings);
63
64 structure::project::ArrangerTool * tool () const;
65 structure::project::ClipEditor * clipEditor () const;
66 structure::arrangement::Timeline * timeline () const;
67 dsp::SnapGrid * snapGridTimeline () const;
68 dsp::SnapGrid * snapGridEditor () const;
69
70 Q_INVOKABLE dsp::AudioInputSelection *
71 audioInputSelectionForTrack (const structure::tracks::Track * track);
72
73 dsp::AudioInputSelection *
74 find_audio_input_selection (const structure::tracks::Track::Uuid &uuid) const;
75
76 static constexpr auto kAudioInputSelectionsKey = "audioInputSelections"sv;
77
78Q_SIGNALS:
79 void audioInputSelectionChanged ();
80
81private:
82 dsp::AudioInputSelection * get_or_create_audio_input_selection (
83 const structure::tracks::Track::Uuid &uuid);
84
85private:
86 static constexpr auto kSnapGridTimelineKey = "snapGridTimeline"sv;
87 static constexpr auto kSnapGridEditorKey = "snapGridEditor"sv;
88 friend void to_json (nlohmann::json &j, const ProjectUiState &p);
89 friend void from_json (const nlohmann::json &j, ProjectUiState &p);
90
91private:
92 Project &project_;
93 utils::AppSettings &app_settings_;
94
96 utils::QObjectUniquePtr<structure::project::ArrangerTool> tool_;
97
99 utils::QObjectUniquePtr<structure::project::ClipEditor> clip_editor_;
100
102 utils::QObjectUniquePtr<structure::arrangement::Timeline> timeline_;
103
105 utils::QObjectUniquePtr<dsp::SnapGrid> snap_grid_timeline_;
106
108 utils::QObjectUniquePtr<dsp::SnapGrid> snap_grid_editor_;
109
112 std::map<
113 structure::tracks::Track::Uuid,
114 utils::QObjectUniquePtr<dsp::AudioInputSelection>>
115 audio_input_selections_;
116};
117
118} // 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:22
ProjectUiState(Project &project, utils::AppSettings &app_settings)
Constructs ProjectUiState with references from the given Project.
Core functionality of a Zrythm project.
Definition project.h:52
String utilities.