Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
automation_clip_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 "dsp/curve.h"
9#include "structure/arrangement/automation_point.h"
10
11#include <QColor>
12#include <QtCanvasPainter/qcanvaslineargradient.h>
13#include <QtCanvasPainter/qcanvaspainter.h>
14#include <QtCanvasPainter/qcanvaspainteritemrenderer.h>
15
16namespace zrythm::gui::qquick
17{
18
20
21class AutomationClipCanvasRenderer : public QCanvasPainterItemRenderer
22{
23public:
24 AutomationClipCanvasRenderer () = default;
25 Q_DISABLE_COPY_MOVE (AutomationClipCanvasRenderer)
26
27 void synchronize (QCanvasPainterItem * item) override;
28 void paint (QCanvasPainter * painter) override;
29
30private:
31 struct CachedControlPoint
32 {
34 float px{};
36 float py{};
38 float val{};
43 dsp::CurveOptions curve_opts;
44
45 // --- Source-segment sampling parameters ---
46 // The segment starting at this point is a (possibly partial) slice of a
47 // source automation segment seg_value_a -> seg_value_b, sampled over the
48 // t-range [seg_t_start, seg_t_max]. This lets loop boundaries cut a curve
49 // mid-segment without distorting non-linear curves: paint() always
50 // evaluates the original source segment over the correct t-subrange.
52 float seg_value_a = 0.0f;
55 float seg_value_b = 0.0f;
57 float seg_t_start = 0.0f;
58 float seg_t_max = 1.0f;
59
61 bool is_real_point = false;
62 };
63
64 std::vector<CachedControlPoint> points_;
65 QColor curve_color_;
66 float canvas_width_ = 0.0f;
67 float canvas_height_ = 0.0f;
68 qreal reference_width_ = 0;
69 qreal reference_x_ = 0;
70 bool draw_points_ = false;
73 bool apply_loops_ = true;
78 qreal hovered_x_ = -1.0;
79};
80
81} // namespace zrythm::gui::qquick
Curve options.
Definition curve.h:23