Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
tempo_curve_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 <vector>
7
8#include <QtCanvasPainter/qcanvaslineargradient.h>
9#include <QtCanvasPainter/qcanvaspainter.h>
10#include <QtCanvasPainter/qcanvaspainteritemrenderer.h>
11
12namespace zrythm::gui::qquick
13{
14
16
27class TempoCurveCanvasRenderer : public QCanvasPainterItemRenderer
28{
29public:
30 TempoCurveCanvasRenderer () = default;
31 Q_DISABLE_COPY_MOVE (TempoCurveCanvasRenderer)
32
33 void synchronize (QCanvasPainterItem * item) override;
34 void paint (QCanvasPainter * painter) override;
35
36private:
38 struct CachedTempoEvent
39 {
40 double tick;
41 double bpm;
42 bool linear;
43 };
44
45 QColor curve_color_{ "#009DFF" };
46 float scroll_x_{ 0.0f };
47 float scroll_x_plus_width_{ 0.0f };
48 float px_per_tick_{ 0.0f };
49 float lane_height_{ 0.0f };
50 float min_bpm_{ 100.0f };
51 float max_bpm_{ 160.0f };
52 // Base tempo at tick 0 (governs the region from 0 up to the first object).
53 double base_bpm_{ 120.0 };
54 std::vector<CachedTempoEvent> cached_events_;
55};
56
57} // namespace zrythm::gui::qquick
QML-visible canvas item that renders the tempo automation curve in the background of the tempo lane.