Zrythm v2.0.0-alpha.1+31.4967fd053471
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
chord_region_segmenter.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <memory>
7#include <vector>
8
9#include <QObject>
10#include <QPointer>
11#include <QRangeModel>
12#include <QtQmlIntegration/qqmlintegration.h>
13
14namespace zrythm::structure::arrangement
15{
16class ChordRegion;
17class ChordObject;
18}
19
20namespace zrythm::gui::qquick
21{
22
35{
36 Q_GADGET
37 Q_PROPERTY (double absStartTicks MEMBER abs_start_ticks)
38 Q_PROPERTY (double absEndTicks MEMBER abs_end_ticks)
39 Q_PROPERTY (
41 Q_PROPERTY (int chordIndex MEMBER chord_index)
42
43public:
45 double abs_start_ticks = 0;
46
53 double abs_end_ticks = 0;
54
57
62 int chord_index = 0;
63};
64
65} // namespace zrythm::gui::qquick
66
70template <> struct QRangeModel::RowOptions<zrythm::gui::qquick::ChordSegment>
71{
72 static constexpr auto rowCategory = QRangeModel::RowCategory::MultiRoleItem;
73};
74
75namespace zrythm::gui::qquick
76{
77
94class ChordRegionSegmenter : public QObject
95{
96 Q_OBJECT
97 Q_PROPERTY (
98 zrythm::structure::arrangement::ChordRegion * region READ region WRITE
99 setRegion NOTIFY regionChanged REQUIRED)
100 Q_PROPERTY (QAbstractItemModel * segments READ segments NOTIFY segmentsChanged)
101 QML_ELEMENT
102
103public:
104 explicit ChordRegionSegmenter (QObject * parent = nullptr);
105
107 {
108 return region_;
109 }
110 void setRegion (zrythm::structure::arrangement::ChordRegion * region);
111
112 QAbstractItemModel * segments () const { return segments_model_.get (); }
113
114 Q_SIGNAL void regionChanged ();
115 Q_SIGNAL void segmentsChanged ();
116
117private:
120 void disconnectAll ();
121
124 void connectToRegion ();
125
130 void recalculate ();
131
132 QPointer<zrythm::structure::arrangement::ChordRegion> region_;
133
136 std::vector<ChordSegment> segments_data_;
137
140 std::unique_ptr<QRangeModel> segments_model_;
141
144 std::vector<QMetaObject::Connection> connections_;
145};
146
147} // namespace zrythm::gui::qquick
POD gadget carrying one (chord × visible loop iteration) tuple.
double abs_start_ticks
Absolute start position within the region, in ticks.
zrythm::structure::arrangement::ChordObject * chord_object
Pointer to the source chord object.
double abs_end_ticks
Absolute end position within the region, in ticks.
int chord_index
Index of the chord in the region's chordObjects list (insertion order, not sorted order).
A chord placed inside a ChordRegion on the chord track.