6#include "structure/arrangement/audio_region.h"
7#include "structure/arrangement/midi_region.h"
8#include "structure/tracks/track.h"
9#include "structure/tracks/track_lane.h"
10#include "structure/tracks/track_lane_list.h"
12#define DEFINE_LANED_TRACK_QML_PROPERTIES(ClassType) \
18 bool lanesVisible READ getLanesVisible WRITE setLanesVisible NOTIFY \
19 lanesVisibleChanged) \
20 bool getLanesVisible () const \
22 return lanes_visible_; \
24 void setLanesVisible (bool visible) \
26 if (lanes_visible_ == visible) \
29 lanes_visible_ = visible; \
30 Q_EMIT lanesVisibleChanged (visible); \
33 Q_SIGNAL void lanesVisibleChanged (bool visible); \
38 Q_PROPERTY (TrackLaneList * lanes READ getLanes CONSTANT) \
39 TrackLaneList * getLanes () const \
41 return const_cast<TrackLaneList *> (&lanes_); \
44namespace zrythm::structure::tracks
49class LanedTrack :
virtual public Track
52 ~LanedTrack ()
noexcept override =
default;
60 LanedTrack () noexcept { }
88template <
typename TrackLaneT>
class LanedTrackImpl :
public LanedTrack
91 using RegionT =
typename TrackLaneT::RegionT;
92 using TrackLaneType = TrackLaneT;
96 ~LanedTrackImpl ()
override =
default;
115 return std::ranges::any_of (
lanes_, [] (
const auto &lane) {
116 return std::get<TrackLaneT *> (lane)->get_soloed ();
135 std::vector<arrangement::ArrangerObjectUuidReference> ®ions,
136 std::optional<signed_frame_t> p1,
137 std::optional<signed_frame_t> p2)
override;
139 int get_lane_index (
const TrackLaneT &lane)
const
141 return std::ranges::find_if (
143 [&] (
const auto &lane_var) {
144 return std::get<TrackLaneT *> (lane_var) == std::addressof (lane);
149 TrackLaneT &get_lane_at (
const size_t index)
151 return *std::get<TrackLaneT *> (
lanes_.at (index));
155 friend void init_from (
157 const LanedTrackImpl &other,
160 init_from (obj.lanes_, other.lanes_, clone_type);
161 for (
auto &lane_var : obj.lanes_)
163 auto lane = std::get<TrackLaneT *> (lane_var);
166 obj.lanes_visible_ = other.lanes_visible_;
172 static constexpr std::string_view kLanesVisibleKey =
"lanesVisible";
173 static constexpr std::string_view kLanesListKey =
"lanesList";
174 friend void to_json (nlohmann::json &j,
const LanedTrackImpl &track)
177 j[kLanesListKey] = track.
lanes_;
179 friend void from_json (
const nlohmann::json &j,
LanedTrackImpl &track)
182 j.at (kLanesListKey).get_to (track.
lanes_);
197using LanedTrackVariant = std::variant<MidiTrack, InstrumentTrack, AudioTrack>;
198using LanedTrackPtrVariant = to_pointer_variant<LanedTrackVariant>;
Interface for a track that has lanes.
void get_regions_in_range(std::vector< arrangement::ArrangerObjectUuidReference > ®ions, std::optional< signed_frame_t > p1, std::optional< signed_frame_t > p2) override
Returns all the regions inside the given range, or all the regions if both p1 and p2 are NULL.
void generate_lanes()
Generates lanes for the track.
bool has_soloed_lanes() const
Returns whether the track has any soloed lanes.
void clear_objects() override
Removes all objects recursively from the track.
void remove_empty_last_lanes()
Removes the empty last lanes of the Track (except the last one).
bool create_missing_lanes(int pos)
Creates missing TrackLane's until pos.
double get_visible_lane_heights() const
Gets the total height of all visible lanes (if any).
TrackLaneList lanes_
Lanes in this track containing Regions.
std::vector< std::unique_ptr< TrackLaneT > > lane_snapshots_
Snapshots used during playback.
void set_playback_caches() override
Set the playback caches for a track.
void set_lanes_visible(bool visible)
Set lanes visible and fire events.
int last_lane_created_
Last lane created during this drag.
bool lanes_visible_
Flag to set lanes visible or not.
bool block_auto_creation_and_deletion_
Block auto-creating or deleting lanes.
int last_lane_idx_
Lane index of region before recording paused.
Track(Type type, PortType in_signal_type, PortType out_signal_type, BaseTrackDependencies dependencies)
Constructor to be used by subclasses.