Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
digital_meter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10
11#ifndef __GUI_WIDGETS_DIGITAL_METER_H__
12#define __GUI_WIDGETS_DIGITAL_METER_H__
13
14#include "common/dsp/transport.h"
15#include "common/utils/types.h"
16#include "gui/backend/gtk_widgets/gtk_wrapper.h"
17
18#define DIGITAL_METER_WIDGET_TYPE (digital_meter_widget_get_type ())
19G_DECLARE_FINAL_TYPE (
21 digital_meter_widget,
22 Z,
23 DIGITAL_METER_WIDGET,
24 GtkWidget)
25
26enum class NoteLength;
27enum class NoteType;
28class Position;
29
35
36enum class DigitalMeterType
37{
38 DIGITAL_METER_TYPE_BPM,
39 DIGITAL_METER_TYPE_POSITION,
40 DIGITAL_METER_TYPE_TIMESIG,
41 DIGITAL_METER_TYPE_NOTE_TYPE,
42 DIGITAL_METER_TYPE_NOTE_LENGTH,
43};
44
45class SnapGrid;
46
47typedef struct _DigitalMeterWidget
48{
49 GtkWidget parent_instance;
50
51 DigitalMeterType type;
52
53 bool is_transport;
54
55 GtkGestureDrag * drag;
56 double last_y;
57 double last_x;
58 int height_start_pos;
59 int height_end_pos;
60
61 /* ========= BPM ========= */
62 /* for BPM */
63 int num_part_start_pos;
64 int num_part_end_pos;
65 int dec_part_start_pos;
66 int dec_part_end_pos;
67
70
73
78
79 /* ========= BPM end ========= */
80
81 /* ========= position ========= */
82
83 int bars_start_pos;
84 int bars_end_pos;
85 int beats_start_pos;
86 int beats_end_pos;
87 int sixteenths_start_pos;
88 int sixteenths_end_pos;
89 int ticks_start_pos;
90 int ticks_end_pos;
91
94 int update_beats;
95 int update_sixteenths;
96 int update_ticks;
97
98 /* ========= position end ========= */
99
100 /* ========= time ========= */
101
104 int minutes_end_pos;
105 int seconds_start_pos;
106 int seconds_end_pos;
107 int ms_start_pos;
108 int ms_end_pos;
109
112 int update_seconds;
113 int update_ms;
114
115 /* ========= time end ========= */
116
117 /* for note length/type */
118 NoteLength * note_length;
119 NoteType * note_type;
124
125 /* for time sig */
126 int update_timesig_top;
127 /* ebeat unit */
128 int update_timesig_bot;
129
132 int beat_unit_at_start;
133
134 /* ---------- FOR POSITION ---------------- */
135 void * obj;
136
138 void (*getter) (void *, Position *);
140 void (*setter) (void *, Position *);
142 void (*on_drag_begin) (void *);
144 void (*on_drag_end) (void *);
145
146 /* ----------- position end --------------- */
147
148 double hover_x;
149 double hover_y;
150
153
155 char * caption;
156
158 PangoLayout * caption_layout;
159 PangoLayout * seg7_layout;
160 PangoLayout * normal_layout;
161
162 bool initialized;
163
164 GtkPopoverMenu * popover_menu;
165
172
173 bool scroll_started;
175
182 DigitalMeterType type,
183 NoteLength * note_length,
184 NoteType * note_type,
185 const char * caption);
186
187#define digital_meter_widget_new_for_position( \
188 obj, drag_begin, getter, setter, drag_end, caption) \
189 _digital_meter_widget_new_for_position ( \
190 (void *) obj, (void (*) (void *)) drag_begin, \
191 (void (*) (void *, Position *)) getter, \
192 (void (*) (void *, Position *)) setter, (void (*) (void *)) drag_end, \
193 caption)
194
212 void * obj,
213 void (*drag_begin) (void *),
214 void (*get_val) (void *, Position *),
215 void (*set_val) (void *, Position *),
216 void (*drag_end) (void *),
217 const char * caption);
218
219void
220digital_meter_set_draw_line (DigitalMeterWidget * self, int draw_line);
221
227void
229
233
234#endif
float bpm_t
The BPM type.
Definition types.h:70
void digital_meter_show_context_menu(DigitalMeterWidget *self, GMenu *menu)
Shows the widgets popover menu with the provided content.
DigitalMeterWidget * digital_meter_widget_new(DigitalMeterType type, NoteLength *note_length, NoteType *note_type, const char *caption)
Creates a digital meter with the given type ( bpm or position).
DigitalMeterWidget * _digital_meter_widget_new_for_position(void *obj, void(*drag_begin)(void *), void(*get_val)(void *, Position *), void(*set_val)(void *, Position *), void(*drag_end)(void *), const char *caption)
Creates a digital meter for an arbitrary position.
bool update_num
Flag to update BPM.
int start_note_length
start note length
int update_bars
Update flags.
int update_note_type
flag to update note type
int minutes_start_pos
For time.
void(* setter)(void *, Position *)
Setter for Position.
void(* getter)(void *, Position *)
Getter for Position.
void(* on_drag_begin)(void *)
Function to call on drag begin.
bool update_dec
Flag to update BPM decimal.
char * caption
Caption to show above, NULL to not show.
int start_note_type
start note type
PangoLayout * caption_layout
Cached layouts for drawing text.
bpm_t last_set_bpm
Used during update.
int beats_per_bar_at_start
Used when changing the time signature.
int update_note_length
flag to update note length
gint64 last_scroll_time
Last time a scroll event was received.
void(* on_drag_end)(void *)
Function to call on drag end.
int draw_line
Draw line above the meter or not.
int update_minutes
Update flags.
bpm_t bpm_at_start
Used when changing the BPM.