Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
grid_line_computer.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <optional>
7#include <vector>
8
9namespace zrythm::dsp
10{
11class TempoMapWrapper;
12}
13
14namespace zrythm::gui::qquick
15{
16
21{
22 float x{ 0.0f };
23 int bar{ 0 };
24 int beat{ 0 };
25 int sixteenth{ 0 };
26};
27
32{
33 std::vector<GridLine> bar_lines;
34 std::vector<GridLine> beat_lines;
35 std::vector<GridLine> sixteenth_lines;
36 // Beat lines whose labels are visible (empty if label threshold was not
37 // requested).
38 std::vector<GridLine> beat_label_lines;
39 // True when sixteenth lines are wide enough for labels (only set when label
40 // threshold was requested)
41 bool show_sixteenth_labels{ false };
42
43 void clear ()
44 {
45 bar_lines.clear ();
46 beat_lines.clear ();
47 sixteenth_lines.clear ();
48 beat_label_lines.clear ();
49 show_sixteenth_labels = false;
50 }
51};
52
73void
74compute_grid_lines (
75 const dsp::TempoMapWrapper &tempo_map,
76 float px_per_tick,
77 float visible_start_tick,
78 float visible_end_tick,
79 float detail_measure_px_threshold,
80 std::optional<float> detail_measure_label_px_threshold,
81 ComputedGridLines &result);
82
83} // namespace zrythm::gui::qquick
Pre-computed sets of grid lines for a visible region.
A single grid line with its pixel position and musical coordinates.
int sixteenth
1-indexed sixteenth number
float x
Pixel position in content space.
int beat
1-indexed beat number
int bar
1-indexed bar number