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::vector<ArrangerObjectPtrVariant> get_timeline_objects () const;
136
142 void
144
145 std::optional<TrackUuidReference>
146 get_track_for_plugin (const plugins::Plugin::Uuid &plugin_id) const;
147
153 */
154 bool should_be_visible (const Track::Uuid &track_id) const;
155
157
159 bool is_track_pinned (int index) const
160 {
161 return index < pinned_tracks_cutoff_;
162 }
163
164 bool is_track_pinned (Track::Uuid track_id) const
165 {
166 return is_track_pinned (
167 static_cast<int> (collection ()->get_track_index (track_id)));
168 }
169
170 auto get_track_route_target (const TrackUuid &source_track) const
171 {
172 return track_routing_->get_output_track (source_track);
173 }
174
184 TrackPtrVariant track_var,
185 bool bounce,
186 bool mark_regions,
187 bool mark_children,
188 bool mark_parents);
189
190private:
191 static constexpr auto kPinnedTracksCutoffKey = "pinnedTracksCutoff"sv;
192 static constexpr auto kTracksKey = "tracks"sv;
193 friend void to_json (nlohmann::json &j, const Tracklist &t);
194 friend void from_json (const nlohmann::json &j, Tracklist &t);
195
196private:
197 auto &get_registry () const { return registry_; }
198 auto &get_registry () { return registry_; }
199
200private:
201 utils::IObjectRegistry &registry_;
202
221
223
225
231 int pinned_tracks_cutoff_ = 0;
232};
233}
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 regions.
Definition track_lane.h:27
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:153
bool should_be_visible(const Track::Uuid &track_id) const
Returns whether the track should be visible.
void clear_selections_for_object_siblings(const ArrangerObject::Uuid &object_id)
Clears either the timeline selections or the clip editor selections.
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.
void mark_track_for_bounce(TrackPtrVariant track_var, bool bounce, bool mark_regions, bool mark_children, bool mark_parents)
Marks the track for bouncing.
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