Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
ui.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
9
10#pragma once
11
12#include <utility>
13
14#include "utils/color.h"
15#include "utils/format.h"
16
22
23#define UI_CACHES (zrythm_app->ui_caches_)
24#define UI_COLORS (&UI_CACHES->colors_)
25
26/* copied from css */
27constexpr const char * UI_COLOR_DARK_TEXT = "#323232";
28constexpr const char * UI_COLOR_BRIGHT_TEXT = "#cdcdcd";
29constexpr const char * UI_COLOR_YELLOW = "#F9CA1B";
30constexpr const char * UI_COLOR_PURPLE = "#9D3955";
31constexpr const char * UI_COLOR_BUTTON_NORMAL = "#343434";
32constexpr const char * UI_COLOR_BUTTON_HOVER = "#444444";
33constexpr const char * UI_COLOR_RECORD_CHECKED = "#ED2939";
34constexpr const char * UI_COLOR_RECORD_ACTIVE = "#FF2400";
35constexpr const char * UI_COLOR_BRIGHT_GREEN = "#1DD169";
36constexpr const char * UI_COLOR_DARKISH_GREEN = "#19664c";
37constexpr const char * UI_COLOR_DARK_ORANGE = "#D68A0C";
38constexpr const char * UI_COLOR_Z_YELLOW = "#F9CA1B";
39constexpr const char * UI_COLOR_BRIGHT_ORANGE = "#F79616";
40constexpr const char * UI_COLOR_Z_PURPLE = "#9D3955";
41constexpr const char * UI_COLOR_MATCHA = "#2eb398";
42constexpr const char * UI_COLOR_LIGHT_BLUEISH = "#1aa3ffcc";
43constexpr const char * UI_COLOR_PREFADER_SEND = "#D21E6D";
44constexpr const char * UI_COLOR_POSTFADER_SEND = "#901ed2";
45constexpr const char * UI_COLOR_SOLO_ACTIVE = UI_COLOR_MATCHA;
46constexpr const char * UI_COLOR_SOLO_CHECKED = UI_COLOR_DARKISH_GREEN;
47constexpr const char * UI_COLOR_HIGHLIGHT_SCALE_BG = "#662266";
48constexpr const char * UI_COLOR_HIGHLIGHT_CHORD_BG = "#BB22BB";
49constexpr const char * UI_COLOR_HIGHLIGHT_BASS_BG = UI_COLOR_LIGHT_BLUEISH;
50constexpr const char * UI_COLOR_HIGHLIGHT_BOTH_BG = "#FF22FF";
51constexpr const char * UI_COLOR_HIGHLIGHT_SCALE_FG = "#F79616";
52constexpr const char * UI_COLOR_HIGHLIGHT_CHORD_FG = UI_COLOR_HIGHLIGHT_SCALE_FG;
53constexpr const char * UI_COLOR_HIGHLIGHT_BASS_FG = "white";
54constexpr const char * UI_COLOR_HIGHLIGHT_BOTH_FG = "white";
55constexpr const char * UI_COLOR_FADER_FILL_END = UI_COLOR_Z_YELLOW;
56constexpr const char * UI_DELETE_ICON_NAME = "z-edit-delete";
57
58using Color = zrythm::utils::Color;
59
64{
65public:
66 Color dark_text;
67 Color dark_orange;
68 Color bright_orange;
69 Color bright_text;
70 Color matcha;
71 Color bright_green;
72 Color darkish_green;
73 Color prefader_send;
74 Color postfader_send;
75 Color record_active;
76 Color record_checked;
77 Color solo_active;
78 Color solo_checked;
79 Color fader_fill_start;
80 Color fader_fill_end;
81 Color highlight_scale_bg;
82 Color highlight_chord_bg;
83 Color highlight_bass_bg;
84 Color highlight_both_bg;
85 Color highlight_scale_fg;
86 Color highlight_chord_fg;
87 Color highlight_bass_fg;
88 Color highlight_both_fg;
89 Color z_yellow;
90 Color z_purple;
91};
92
97{
98};
99
104{
105 UI_CURSOR_STATE_DEFAULT,
106 UI_CURSOR_STATE_RESIZE_L,
107 UI_CURSOR_STATE_REPEAT_L,
108 UI_CURSOR_STATE_RESIZE_R,
109 UI_CURSOR_STATE_REPEAT_R,
110 UI_CURSOR_STATE_RESIZE_UP,
111};
112
117{
118 None,
119 CreatingResizingR,
120 CREATING_MOVING,
121 ResizingL,
122 ResizingLLoop,
123 ResizingLFade,
124 ResizingR,
125 ResizingRLoop,
126 ResizingRFade,
127 RESIZING_UP,
128 RESIZING_UP_FADE_IN,
129 RESIZING_UP_FADE_OUT,
130 StretchingL,
131 StretchingR,
132
133 STARTING_AUDITIONING,
134 AUDITIONING,
135
143
146 STARTING_ERASING,
147
152 STARTING_MOVING_COPY,
153 STARTING_MOVING_LINK,
154 MOVING,
155 MovingCopy,
156 MOVING_LINK,
157 STARTING_CHANGING_CURVE,
158 CHANGING_CURVE,
159
166 SELECTING,
167
171 DELETE_SELECTING,
172
173 STARTING_RAMP,
174 RAMPING,
175 CUTTING,
176
177 RENAMING,
178
179 StartingPanning,
180 Panning,
181 NUM_UI_OVERLAY_ACTIONS,
182};
183
187 "NONE",
188 "RESIZING_R",
189 "MOVING",
190 "RESIZING_L",
191 "RESIZING_L_LOOP",
192 "RESIZING_L_FADE",
193 "RESIZING_R",
194 "RESIZING_R_LOOP",
195 "RESIZING_R_FADE",
196 "RESIZING_UP",
197 "RESIZING_UP_FADE_IN",
198 "RESIZING_UP_FADE_OUT",
199 "STRETCHING_L",
200 "STRETCHING_R",
201 "STARTING_AUDITIONING",
202 "AUDITIONING",
203 "AUTOFILLING",
204 "ERASING",
205 "STARTING_ERASING",
206 "STARTING_MOVING",
207 "STARTING_MOVING_COPY",
208 "STARTING_MOVING_LINK",
209 "MOVING",
210 "MOVING_COPY",
211 "MOVING_LINK",
212 "STARTING_CHANGING_CURVE",
213 "CHANGING_CURVE",
214 "STARTING_SELECTION",
215 "SELECTING",
216 "STARTING_DELETE_SELECTION",
217 "DELETE_SELECTING",
218 "STARTING_RAMP",
219 "RAMPING",
220 "CUTTING",
221 "RENAMING",
222 "STARTING_PANNING",
223 "PANNING",
224 "--INVALID--")
225
226
229enum class UiDragMode
230{
232 UI_DRAG_MODE_CURSOR,
233
235 UI_DRAG_MODE_RELATIVE,
236
239 UI_DRAG_MODE_RELATIVE_WITH_MULTIPLIER,
240};
241
242#if 0
243void
244ui_set_pointer_cursor (GtkWidget * widget);
245
246# define ui_set_pencil_cursor(widget) \
247 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "edit-cursor", 2, 3);
248
249# define ui_set_brush_cursor(widget) \
250 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "brush-cursor", 2, 3);
251
252# define ui_set_cut_clip_cursor(widget) \
253 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "cut-cursor", 9, 7);
254
255# define ui_set_eraser_cursor(widget) \
256 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "eraser-cursor", 4, 2);
257
258# define ui_set_line_cursor(widget) \
259 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "ramp-cursor", 2, 3);
260
261# define ui_set_speaker_cursor(widget) \
262 ui_set_cursor_from_icon_name ( \
263 GTK_WIDGET (widget), "audition-cursor", 10, 12);
264
265# define ui_set_hand_cursor(widget) \
266 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "move-cursor", 12, 11);
267
268# define ui_set_left_resize_cursor(widget) \
269 ui_set_cursor_from_icon_name ( \
270 GTK_WIDGET (widget), "w-resize-cursor", 14, 11);
271
272# define ui_set_left_stretch_cursor(widget) \
273 ui_set_cursor_from_icon_name ( \
274 GTK_WIDGET (widget), "w-stretch-cursor", 14, 11);
275
276# define ui_set_left_resize_loop_cursor(widget) \
277 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "w-loop-cursor", 14, 11);
278
279# define ui_set_right_resize_cursor(widget) \
280 ui_set_cursor_from_icon_name ( \
281 GTK_WIDGET (widget), "e-resize-cursor", 10, 11);
282
283# define ui_set_right_stretch_cursor(widget) \
284 ui_set_cursor_from_icon_name ( \
285 GTK_WIDGET (widget), "e-stretch-cursor", 10, 11);
286
287# define ui_set_right_resize_loop_cursor(widget) \
288 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "e-loop-cursor", 10, 11);
289
290# define ui_set_time_select_cursor(widget) \
291 ui_set_cursor_from_icon_name ( \
292 GTK_WIDGET (widget), "time-select-cursor", 10, 12);
293
294# define ui_set_fade_in_cursor(widget) \
295 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "fade-in-cursor", 3, 1);
296
297# define ui_set_fade_out_cursor(widget) \
298 ui_set_cursor_from_icon_name (GTK_WIDGET (widget), "fade-out-cursor", 3, 1);
299#endif
300
310double
312 double size,
313 double cur_val,
314 double start_px,
315 double cur_px,
316 double last_px,
317 double multiplier,
318 UiDragMode mode);
319
324std::string
326
Commonly used UI colors.
Definition ui.h:64
Commonly used UI textures.
Definition ui.h:97
double ui_get_normalized_draggable_value(double size, double cur_val, double start_px, double cur_px, double last_px, double multiplier, UiDragMode mode)
Gets a draggable value as a normalized value between 0 and 1.
std::string ui_get_db_value_as_string(float val)
Returns an appropriate string representation of the given dB value.
DEFINE_ENUM_FORMATTER(UiOverlayAction, UiOverlayAction, "NONE", "RESIZING_R", "MOVING", "RESIZING_L", "RESIZING_L_LOOP", "RESIZING_L_FADE", "RESIZING_R", "RESIZING_R_LOOP", "RESIZING_R_FADE", "RESIZING_UP", "RESIZING_UP_FADE_IN", "RESIZING_UP_FADE_OUT", "STRETCHING_L", "STRETCHING_R", "STARTING_AUDITIONING", "AUDITIONING", "AUTOFILLING", "ERASING", "STARTING_ERASING", "STARTING_MOVING", "STARTING_MOVING_COPY", "STARTING_MOVING_LINK", "MOVING", "MOVING_COPY", "MOVING_LINK", "STARTING_CHANGING_CURVE", "CHANGING_CURVE", "STARTING_SELECTION", "SELECTING", "STARTING_DELETE_SELECTION", "DELETE_SELECTING", "STARTING_RAMP", "RAMPING", "CUTTING", "RENAMING", "STARTING_PANNING", "PANNING", "--INVALID--") enum class UiDragMode
Dragging modes for widgets that have click&drag.
Definition ui.h:184
UiCursorState
Various cursor states to be shared.
Definition ui.h:104
UiOverlayAction
Various overlay actions to be shared.
Definition ui.h:117
@ AUTOFILLING
Auto-filling in edit mode.
Definition ui.h:142
@ STARTING_DELETE_SELECTION
Like selecting but it auto deletes whatever touches the selection.
Definition ui.h:170
@ ERASING
Erasing.
Definition ui.h:145
@ STARTING_SELECTION
To be set in drag_start.
Definition ui.h:165
@ STARTING_MOVING
To be set in drag_start.
Definition ui.h:151