Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
automation_mode.h
1// SPDX-FileCopyrightText: © 2019-2020, 2022, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __GUI_WIDGETS_AUTOMATION_MODE_H__
5#define __GUI_WIDGETS_AUTOMATION_MODE_H__
6
7#include "common/dsp/automation_point.h"
8#include "common/utils/color.h"
10#include "gui/backend/gtk_widgets/gtk_wrapper.h"
11
17
18constexpr int AUTOMATION_MODE_HPADDING = 3;
19constexpr int AUTOMATION_MODE_HSEPARATOR_SIZE = 1;
20
25{
26public:
30 AutomationModeWidget (int height, PangoLayout * layout, AutomationTrack * owner);
32
33 void init ();
34
35 void draw (
36 GtkSnapshot * snapshot,
37 double x,
38 double y,
39 double x_cursor,
41
42private:
43 AutomationMode get_hit_mode (double x) const;
44
51 void get_color_for_state (
53 AutomationMode mode,
54 GdkRGBA * c);
55
60 void draw_bg (
61 GtkSnapshot * snapshot,
62 double x,
63 double y,
64 int draw_frame,
65 bool keep_clip);
66
67public:
69 double x_;
70 double y_;
71
73 int width_;
74 int height_;
75
77
78 int text_widths_[static_cast<int> (AutomationMode::NUM_AUTOMATION_MODES)];
79 int text_heights_[static_cast<int> (AutomationMode::NUM_AUTOMATION_MODES)];
80 int max_text_height_;
81
82 int has_hit_mode_;
83
85 AutomationMode hit_mode_;
86
88 GdkRGBA def_color_;
89
92
94 std::array<GdkRGBA, NUM_AUTOMATION_MODES> toggled_colors_;
95
97 std::array<GdkRGBA, NUM_AUTOMATION_MODES> held_colors_;
98
100 double aspect_;
101
105
107 std::array<CustomButtonWidget::State, NUM_AUTOMATION_MODES> last_states_;
108
110 std::array<CustomButtonWidget::State, NUM_AUTOMATION_MODES> current_states_;
111
113 std::array<GdkRGBA, NUM_AUTOMATION_MODES> last_colors_;
114
116 PangoLayout * layout_;
117
119 AutomationTrack * owner_;
120
123};
124
128
129#endif
int transition_frames_
Frames left for a transition in color.
GdkRGBA hovered_color_
Hovered color.
GdkRGBA def_color_
Default color.
double corner_radius_
Corner curvature radius for the rounded rectangle.
AutomationModeWidget(int height, PangoLayout *layout, AutomationTrack *owner)
Creates a new track widget from the given track.
double aspect_
Aspect ratio for the rounded rectangle.
std::array< CustomButtonWidget::State, NUM_AUTOMATION_MODES > current_states_
Used during drawing.
int width_
Total width/height.
AutomationMode hit_mode_
Currently hit mode.
std::array< GdkRGBA, NUM_AUTOMATION_MODES > toggled_colors_
Toggled color.
PangoLayout * layout_
Cache layout for drawing text.
int text_widths_[static_cast< int >(AutomationMode::NUM_AUTOMATION_MODES)]
Width of each button, including padding.
std::array< GdkRGBA, NUM_AUTOMATION_MODES > last_colors_
Used during transitions.
AutomationTrack * owner_
Owner.
std::array< GdkRGBA, NUM_AUTOMATION_MODES > held_colors_
Held color (used after clicking and before releasing).
double x_
X/y relative to parent drawing area.
std::array< CustomButtonWidget::State, NUM_AUTOMATION_MODES > last_states_
Used to update caches if state changed.
Custom button to be drawn inside drawing areas.