Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
tracklist.h
1// SPDX-FileCopyrightText: © 2018-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/arrangement/arranger_object.h"
7#include "structure/tracks/singleton_tracks.h"
8#include "structure/tracks/track.h"
9#include "structure/tracks/track_collection.h"
10#include "structure/tracks/track_routing.h"
11
12#include <QtQmlIntegration/qqmlintegration.h>
13
14namespace zrythm::structure::tracks
15{
16
21class Tracklist : public QObject
22{
23 Q_OBJECT
24 QML_ELEMENT
25 Q_PROPERTY (
26 zrythm::structure::tracks::TrackRouting * trackRouting READ trackRouting
27 CONSTANT)
28 Q_PROPERTY (
30 singletonTracks CONSTANT)
31 Q_PROPERTY (
32 zrythm::structure::tracks::TrackCollection * collection READ collection
33 CONSTANT)
34 Q_PROPERTY (
35 int pinnedTracksCutoff READ pinnedTracksCutoff WRITE setPinnedTracksCutoff
36 NOTIFY pinnedTracksCutoffChanged)
37 QML_UNCREATABLE ("")
38
39public:
40 using ArrangerObjectPtrVariant = arrangement::ArrangerObjectPtrVariant;
41 using ArrangerObject = arrangement::ArrangerObject;
42
43public:
44 explicit Tracklist (
45 utils::IObjectRegistry &registry,
46 QObject * parent = nullptr);
47 Q_DISABLE_COPY_MOVE (Tracklist)
48 ~Tracklist () override;
49
50 // ========================================================================
51 // QML Interface
52 // ========================================================================
53
54 TrackCollection * collection () const { return track_collection_.get (); }
55
56 SingletonTracks * singletonTracks () const
57 {
58 return singleton_tracks_.get ();
59 }
60
61 Q_INVOKABLE Track * getTrackForTimelineObject (
62 const arrangement::ArrangerObject * timelineObject) const;
63 Q_INVOKABLE TrackLane * getTrackLaneForObject (
64 const arrangement::ArrangerObject * timelineObject) const;
65
66 Q_INVOKABLE bool isTrackPinned (const Track * track) const
67 {
68 return is_track_pinned (track->get_uuid ());
69 }
70
71 Q_INVOKABLE bool shouldBeVisible (const Track * track) const
72 {
73 return should_be_visible (track->get_uuid ());
74 }
75
76 Q_INVOKABLE bool hasChannel (const Track * track) const
77 {
78 return track->channel () != nullptr;
79 }
80
81 TrackRouting * trackRouting () const { return track_routing_.get (); }
82
83 int pinnedTracksCutoff () const { return pinned_tracks_cutoff_; }
84 void setPinnedTracksCutoff (int index)
85 {
86 if (index == pinned_tracks_cutoff_)
87 return;
88
89 pinned_tracks_cutoff_ = index;
90 Q_EMIT pinnedTracksCutoffChanged (index);
91 }
92 Q_SIGNAL void pinnedTracksCutoffChanged (int index);
93
94 // ========================================================================
95
96 friend void init_from (
97 Tracklist &obj,
98 const Tracklist &other,
99 utils::ObjectCloneType clone_type);
100
101 Track * get_track (const TrackUuid &id) const
102 {
103 const auto &tracks = collection ()->tracks ();
104 auto it = std::ranges::find (tracks, id, &TrackUuidReference::id);
105 return it != tracks.end () ? it->get () : nullptr;
106 }
107
116 std::optional<TrackPtrVariant>
117 get_visible_track_after_delta (Track::Uuid track_id, int delta) const;
125 double multiplier,
126 bool visible_only,
127 bool check_only,
128 bool fire_events);
129
133 void handle_click (TrackUuid track_id, bool ctrl, bool shift, bool dragged);
134
135 std::optional<TrackUuidReference>
136 get_track_for_plugin (const plugins::Plugin::Uuid &plugin_id) const;
137
143 */
144 bool should_be_visible (const Track::Uuid &track_id) const;
145
147
149 bool is_track_pinned (int index) const
150 {
151 return index < pinned_tracks_cutoff_;
152 }
153
154 bool is_track_pinned (Track::Uuid track_id) const
155 {
156 return is_track_pinned (
157 static_cast<int> (collection ()->get_track_index (track_id)));
158 }
159
160 auto get_track_route_target (const TrackUuid &source_track) const
161 {
162 return track_routing_->get_output_track (source_track);
163 }
164
174 TrackPtrVariant track_var,
175 bool bounce,
176 bool mark_clips,
177 bool mark_children,
178 bool mark_parents);
179
180private:
181 static constexpr auto kPinnedTracksCutoffKey = "pinnedTracksCutoff"sv;
182 static constexpr auto kTracksKey = "tracks"sv;
183 friend void to_json (nlohmann::json &j, const Tracklist &t);
184 friend void from_json (const nlohmann::json &j, Tracklist &t);
185
186private:
187 auto &get_registry () const { return registry_; }
188 auto &get_registry () { return registry_; }
189
190private:
191 utils::IObjectRegistry &registry_;
192
211
213
215
221 int pinned_tracks_cutoff_ = 0;
222};
223}
Base class for all objects in the arranger.
References to tracks that are singletons.
A collection of tracks that provides a QAbstractListModel interface.
A container of MIDI or Audio clips.
Definition track_lane.h:28
Management of track-to-track connections.
Represents a track in the project.
Definition track.h:60
bool is_track_pinned(int index) const
Returns whether the track at index is pinned.
Definition tracklist.h:143
bool should_be_visible(const Track::Uuid &track_id) const
Returns whether the track should be visible.
void mark_track_for_bounce(TrackPtrVariant track_var, bool bounce, bool mark_clips, bool mark_children, bool mark_parents)
Marks the track for bouncing.
std::optional< TrackPtrVariant > get_visible_track_after_delta(Track::Uuid track_id, int delta) const
Returns the Track after delta visible Track's.
bool multiply_track_heights(double multiplier, bool visible_only, bool check_only, bool fire_events)
Multiplies all tracks' heights and returns if the operation was valid.
void handle_click(TrackUuid track_id, bool ctrl, bool shift, bool dragged)
Handle a click selection.
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