Zrythm
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
11#ifndef __GUI_WIDGETS_DIGITAL_METER_H__
12#define __GUI_WIDGETS_DIGITAL_METER_H__
13
14#include <stdbool.h>
15
16#include "dsp/transport.h"
17#include "utils/types.h"
18
19#include <gtk/gtk.h>
20
21#define DIGITAL_METER_WIDGET_TYPE (digital_meter_widget_get_type ())
22G_DECLARE_FINAL_TYPE (
24 digital_meter_widget,
25 Z,
26 DIGITAL_METER_WIDGET,
27 GtkWidget)
28
29typedef enum NoteLength NoteLength;
30typedef enum NoteType NoteType;
31typedef struct Position Position;
32
39typedef enum DigitalMeterType
40{
41 DIGITAL_METER_TYPE_BPM,
42 DIGITAL_METER_TYPE_POSITION,
43 DIGITAL_METER_TYPE_TIMESIG,
44 DIGITAL_METER_TYPE_NOTE_TYPE,
45 DIGITAL_METER_TYPE_NOTE_LENGTH,
46} DigitalMeterType;
47
48typedef struct SnapGrid SnapGrid;
49
50typedef struct _DigitalMeterWidget
51{
52 GtkWidget parent_instance;
53
54 DigitalMeterType type;
55
56 bool is_transport;
57
58 GtkGestureDrag * drag;
59 double last_y;
60 double last_x;
61 int height_start_pos;
62 int height_end_pos;
63
64 /* ========= BPM ========= */
65 /* for BPM */
66 int num_part_start_pos;
67 int num_part_end_pos;
68 int dec_part_start_pos;
69 int dec_part_end_pos;
70
73
76
81
82 /* ========= BPM end ========= */
83
84 /* ========= position ========= */
85
86 int bars_start_pos;
87 int bars_end_pos;
88 int beats_start_pos;
89 int beats_end_pos;
90 int sixteenths_start_pos;
91 int sixteenths_end_pos;
92 int ticks_start_pos;
93 int ticks_end_pos;
94
97 int update_beats;
98 int update_sixteenths;
99 int update_ticks;
100
101 /* ========= position end ========= */
102
103 /* ========= time ========= */
104
107 int minutes_end_pos;
108 int seconds_start_pos;
109 int seconds_end_pos;
110 int ms_start_pos;
111 int ms_end_pos;
112
115 int update_seconds;
116 int update_ms;
117
118 /* ========= time end ========= */
119
120 /* for note length/type */
121 NoteLength * note_length;
122 NoteType * note_type;
127
128 /* for time sig */
129 int update_timesig_top;
130 /* ebeat unit */
131 int update_timesig_bot;
132
135 int beat_unit_at_start;
136
137 /* ---------- FOR POSITION ---------------- */
138 void * obj;
139
141 void (*getter) (void *, Position *);
143 void (*setter) (void *, Position *);
145 void (*on_drag_begin) (void *);
147 void (*on_drag_end) (void *);
148
149 /* ----------- position end --------------- */
150
151 double hover_x;
152 double hover_y;
153
156
158 char * caption;
159
161 PangoLayout * caption_layout;
162 PangoLayout * seg7_layout;
163 PangoLayout * normal_layout;
164
165 bool initialized;
166
167 GtkPopoverMenu * popover_menu;
168
175
176 bool scroll_started;
178
185 DigitalMeterType type,
186 NoteLength * note_length,
187 NoteType * note_type,
188 const char * caption);
189
190#define digital_meter_widget_new_for_position( \
191 obj, drag_begin, getter, setter, drag_end, caption) \
192 _digital_meter_widget_new_for_position ( \
193 (void *) obj, (void (*) (void *)) drag_begin, \
194 (void (*) (void *, Position *)) getter, \
195 (void (*) (void *, Position *)) setter, (void (*) (void *)) drag_end, \
196 caption)
197
215 void * obj,
216 void (*drag_begin) (void *),
217 void (*get_val) (void *, Position *),
218 void (*set_val) (void *, Position *),
219 void (*drag_end) (void *),
220 const char * caption);
221
222void
223digital_meter_set_draw_line (DigitalMeterWidget * self, int draw_line);
224
230void
232
237#endif
NoteType
Definition snap_grid.h:55
float bpm_t
The BPM type.
Definition types.h:50
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.
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.
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.
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:126
Transport API.
Custom types.