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 "dsp/transport.h"
15#include "utils/types.h"
16
17#include "gtk_wrapper.h"
18
19#define DIGITAL_METER_WIDGET_TYPE (digital_meter_widget_get_type ())
20G_DECLARE_FINAL_TYPE (
22 digital_meter_widget,
23 Z,
24 DIGITAL_METER_WIDGET,
25 GtkWidget)
26
27enum class NoteLength;
28enum class NoteType;
29typedef struct Position Position;
30
37enum class DigitalMeterType
38{
39 DIGITAL_METER_TYPE_BPM,
40 DIGITAL_METER_TYPE_POSITION,
41 DIGITAL_METER_TYPE_TIMESIG,
42 DIGITAL_METER_TYPE_NOTE_TYPE,
43 DIGITAL_METER_TYPE_NOTE_LENGTH,
44};
45
46typedef struct SnapGrid SnapGrid;
47
48typedef struct _DigitalMeterWidget
49{
50 GtkWidget parent_instance;
51
52 DigitalMeterType type;
53
54 bool is_transport;
55
56 GtkGestureDrag * drag;
57 double last_y;
58 double last_x;
59 int height_start_pos;
60 int height_end_pos;
61
62 /* ========= BPM ========= */
63 /* for BPM */
64 int num_part_start_pos;
65 int num_part_end_pos;
66 int dec_part_start_pos;
67 int dec_part_end_pos;
68
71
74
79
80 /* ========= BPM end ========= */
81
82 /* ========= position ========= */
83
84 int bars_start_pos;
85 int bars_end_pos;
86 int beats_start_pos;
87 int beats_end_pos;
88 int sixteenths_start_pos;
89 int sixteenths_end_pos;
90 int ticks_start_pos;
91 int ticks_end_pos;
92
95 int update_beats;
96 int update_sixteenths;
97 int update_ticks;
98
99 /* ========= position end ========= */
100
101 /* ========= time ========= */
102
105 int minutes_end_pos;
106 int seconds_start_pos;
107 int seconds_end_pos;
108 int ms_start_pos;
109 int ms_end_pos;
110
113 int update_seconds;
114 int update_ms;
115
116 /* ========= time end ========= */
117
118 /* for note length/type */
119 NoteLength * note_length;
120 NoteType * note_type;
125
126 /* for time sig */
127 int update_timesig_top;
128 /* ebeat unit */
129 int update_timesig_bot;
130
133 int beat_unit_at_start;
134
135 /* ---------- FOR POSITION ---------------- */
136 void * obj;
137
139 void (*getter) (void *, Position *);
141 void (*setter) (void *, Position *);
143 void (*on_drag_begin) (void *);
145 void (*on_drag_end) (void *);
146
147 /* ----------- position end --------------- */
148
149 double hover_x;
150 double hover_y;
151
154
156 char * caption;
157
159 PangoLayout * caption_layout;
160 PangoLayout * seg7_layout;
161 PangoLayout * normal_layout;
162
163 bool initialized;
164
165 GtkPopoverMenu * popover_menu;
166
173
174 bool scroll_started;
176
183 DigitalMeterType type,
184 NoteLength * note_length,
185 NoteType * note_type,
186 const char * caption);
187
188#define digital_meter_widget_new_for_position( \
189 obj, drag_begin, getter, setter, drag_end, caption) \
190 _digital_meter_widget_new_for_position ( \
191 (void *) obj, (void (*) (void *)) drag_begin, \
192 (void (*) (void *, Position *)) getter, \
193 (void (*) (void *, Position *)) setter, (void (*) (void *)) drag_end, \
194 caption)
195
213 void * obj,
214 void (*drag_begin) (void *),
215 void (*get_val) (void *, Position *),
216 void (*set_val) (void *, Position *),
217 void (*drag_end) (void *),
218 const char * caption);
219
220void
221digital_meter_set_draw_line (DigitalMeterWidget * self, int draw_line);
222
228void
230
235#endif
NoteType
Definition snap_grid.h:53
float bpm_t
The BPM type.
Definition types.h:54
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:124
Transport API.
Custom types.