Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
ruler_grid_canvas_renderer.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "gui/qquick/grid_line_computer.h"
7
8#include <QFont>
9#include <QtCanvasPainter/qcanvaspainter.h>
10#include <QtCanvasPainter/qcanvaspainteritemrenderer.h>
11
12namespace zrythm::gui::qquick
13{
14
16
23class RulerGridCanvasRenderer : public QCanvasPainterItemRenderer
24{
25public:
26 RulerGridCanvasRenderer () = default;
27 Q_DISABLE_COPY_MOVE (RulerGridCanvasRenderer)
28
29 void synchronize (QCanvasPainterItem * item) override;
30 void paint (QCanvasPainter * painter) override;
31
32private:
33 // Cached visual state from the item
34 QColor text_color_;
35 float scroll_x_{ 0.0f };
36 float px_per_tick_{ 0.0f };
37 float bar_line_opacity_{ 0.8f };
38 float beat_line_opacity_{ 0.6f };
39 float sixteenth_line_opacity_{ 0.4f };
40 float detail_measure_px_threshold_{ 32.0f };
41 float detail_measure_label_px_threshold_{ 64.0f };
42 float canvas_height_{ 0.0f };
43 QFont bar_label_font_;
44 QFont beat_label_font_;
45 QFont sixteenth_label_font_;
46
47 // Pre-computed grid lines (computed in synchronize)
48 ComputedGridLines grid_lines_;
49};
50
51} // namespace zrythm::gui::qquick
QML-visible canvas item that renders the ruler grid lines and labels.
Pre-computed sets of grid lines for a visible region.