Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
ruler.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2022, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
9
10#ifndef __GUI_WIDGETS_RULER_H__
11#define __GUI_WIDGETS_RULER_H__
12
13#include "common/dsp/position.h"
14#include "common/utils/ui.h"
15#include "gui/backend/gtk_widgets/gtk_wrapper.h"
16
17constexpr int RW_RULER_MARKER_SIZE = 8;
18constexpr int RW_CUE_MARKER_HEIGHT = 12;
19constexpr int RW_CUE_MARKER_WIDTH = 7;
20constexpr int RW_PLAYHEAD_TRIANGLE_WIDTH = 12;
21constexpr int RW_PLAYHEAD_TRIANGLE_HEIGHT = 8;
22constexpr int RW_RANGE_HEIGHT_DIVISOR = 4;
23
24constexpr int RW_HEIGHT = 42;
25
27constexpr int RW_SCROLL_SPEED = 48;
28
32constexpr double RW_PX_TO_HIDE_BEATS = 40.0;
33
34#define RULER_WIDGET_TYPE (ruler_widget_get_type ())
35G_DECLARE_FINAL_TYPE (RulerWidget, ruler_widget, Z, RULER_WIDGET, GtkWidget)
36
37
42
43class Position;
44class EditorSettings;
45
51#define DEFAULT_PX_PER_TICK 0.03
52
56#define SPACE_BEFORE_START 10
57#define SPACE_BEFORE_START_F 10.f
58#define SPACE_BEFORE_START_D 10.0
59
61#define RULER_ZOOM_LEVEL_MULTIPLIER 1.28
62
63#define MIN_ZOOM_LEVEL 0.04
64#define MAX_ZOOM_LEVEL 1800.
65
69enum class RWTarget
70{
71 Playhead,
72 LoopStart,
73 LoopEnd,
74 PunchIn,
75 PunchOut,
76 ClipStart,
79};
80
81enum class RulerWidgetType
82{
83 Timeline,
84 Editor,
85};
86
99
100using RulerWidget = struct _RulerWidget
101{
102 GtkWidget parent_instance;
103
104 RulerWidgetType type;
105
106 double px_per_beat;
107 double px_per_bar;
108 double px_per_sixteenth;
109 double px_per_tick;
110 double px_per_min;
111 double px_per_10sec;
112 double px_per_sec;
113 double px_per_100ms;
114 double total_px;
115
119 UiOverlayAction action;
120
122 double start_x;
123 double start_y;
124 double last_offset_x;
125 double last_offset_y;
126
127 double hover_x;
128 double hover_y;
129 bool hovering;
130
131 bool vertical_panning_started;
132
133 GtkGestureDrag * drag;
134 GtkGestureClick * click;
135
137 RWTarget target;
138
142 int shift_held;
143
145 bool alt_held;
146
147 bool ctrl_held;
148
152 int last_playhead_px;
153
155 int redraw;
156
158 int range1_first;
159
161 int dragging;
162
168 Position range1_start_pos;
169 Position range2_start_pos;
170
177 Position last_set_pos;
178
180 Position drag_start_pos;
181
182 cairo_t * cached_cr;
183
184 cairo_surface_t * cached_surface;
185
187 graphene_rect_t last_rect;
188
189 /* layout for drawing text */
190 PangoLayout * layout_normal;
191 PangoLayout * monospace_layout_small;
192 PangoLayout * marker_layout;
193
195 GtkPopoverMenu * popover_menu;
196};
197
203bool
204ruler_widget_set_zoom_level (RulerWidget * self, double zoom_level);
205
209double
210ruler_widget_get_zoom_level (RulerWidget * self);
211
223void
225 RulerWidget * self,
226 double * x_pos,
227 double dy);
228
233int
235
240int
242
246int
248
252int
253ruler_widget_get_sec_interval (RulerWidget * self);
254
255bool
256ruler_widget_is_range_hit (
257 RulerWidget * self,
259 double x,
260 double y);
261
265bool
267 RulerWidget * self,
269 double x,
270 double y);
271
272void
273ruler_widget_px_to_pos (
274 RulerWidget * self,
275 double px,
276 Position * pos,
277 bool has_padding);
278
279int
280ruler_widget_pos_to_px (RulerWidget * self, Position * pos, int use_padding);
281
286EditorSettings *
288
292void
293ruler_widget_get_visible_rect (RulerWidget * self, GdkRectangle * rect);
294
302int
303ruler_widget_get_playhead_px (RulerWidget * self, bool after_loops);
304
305void
306ruler_widget_refresh (RulerWidget * self);
307
311
312#endif
#define RW_PX_TO_HIDE_BEATS
Minimum number of pixels between beat lines.
UiOverlayAction
Various overlay actions to be shared.
Definition ui.h:117
EditorSettings * ruler_widget_get_editor_settings(RulerWidget *self)
Gets the pointer to the EditorSettings associated with the arranger this ruler is for.
int ruler_widget_get_10sec_interval(RulerWidget *self)
Returns the 10 sec interval.
int ruler_widget_get_sec_interval(RulerWidget *self)
Returns the sec interval.
void ruler_widget_get_visible_rect(RulerWidget *self, GdkRectangle *rect)
Fills in the visible rectangle.
int ruler_widget_get_playhead_px(RulerWidget *self, bool after_loops)
Returns the playhead's x coordinate in absolute coordinates.
bool ruler_widget_set_zoom_level(RulerWidget *self, double zoom_level)
Sets zoom level and disables/enables buttons accordingly.
int ruler_widget_get_sixteenth_interval(RulerWidget *self)
Returns the sixteenth interval for drawing vertical lines.
bool ruler_widget_is_loop_range_hit(RulerWidget *self, RulerWidgetRangeType type, double x, double y)
Whether the loop range is hit.
int ruler_widget_get_beat_interval(RulerWidget *self)
Returns the beat interval for drawing vertical lines.
RulerWidgetRangeType
Range type.
Definition ruler.h:91
void ruler_widget_handle_horizontal_zoom(RulerWidget *self, double *x_pos, double dy)
Handle horizontal zoom.
RWTarget
The ruler widget target acting upon.
Definition ruler.h:70
double ruler_widget_get_zoom_level(RulerWidget *self)
Gets the zoom level associated with this RulerWidget from the backend.
@ End
Range end.
Definition ruler.h:97
@ Start
Range start.
Definition ruler.h:93
@ Full
Whole range.
Definition ruler.h:95
@ Range
for timeline only
Definition ruler.h:77
@ LoopRange
for timeline only
Definition ruler.h:78
constexpr int RW_SCROLL_SPEED
Mouse wheel scroll speed (number of pixels).
Definition ruler.h:27