Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
bar_slider.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __GUI_WIDGETS_BAR_SLIDER_H__
11#define __GUI_WIDGETS_BAR_SLIDER_H__
12
13#include "utils/types.h"
14#include "utils/ui.h"
15
16#include <gtk/gtk.h>
17
18#define BAR_SLIDER_WIDGET_TYPE (bar_slider_widget_get_type ())
19G_DECLARE_FINAL_TYPE (
21 bar_slider_widget,
22 Z,
23 BAR_SLIDER_WIDGET,
24 GtkWidget)
25
26typedef struct Port Port;
27
37typedef enum BarSliderType
38{
39 BAR_SLIDER_TYPE_NORMAL,
40
43
44 BAR_SLIDER_TYPE_CONTROL_PORT,
46
54typedef struct _BarSliderWidget
55{
56 GtkWidget parent_instance;
57
60
63 char suffix[600];
64
66 char prefix[600];
67
69 float max;
70
72 float min;
73
75 float zero;
76
79
82
85
88
91
94
96 int width;
97
99 int height;
100
102 void * object;
103
105 GtkGestureDrag * drag;
106
108 double last_x;
109
111 double start_x;
112
115
117 int hover;
118
121
125
128
131
133 PangoLayout * layout;
134
139 int last_width_extent;
140 int last_height_extent;
141 char last_extent_str[3000];
142
144
155 BarSliderType type,
156 float (*get_val) (void *),
157 void (*set_val) (void *, float),
158 void * object,
159 float min,
160 float max,
161 int w,
162 int h,
163 float zero,
164 int convert_to_percentage,
165 int decimals,
166 UiDragMode mode,
167 const char * prefix,
168 const char * suffix);
169
173#define bar_slider_widget_new( \
174 getter, setter, obj, min, max, w, h, zero, dec, mode, suffix) \
175 _bar_slider_widget_new ( \
176 BAR_SLIDER_TYPE_NORMAL, (float (*) (void *)) getter, \
177 (void (*) (void *, float)) setter, (void *) obj, min, max, w, h, zero, 0, \
178 dec, mode, "", suffix)
179
185#define bar_slider_widget_new_port_connection(conn, prefix) \
186 _bar_slider_widget_new ( \
187 BAR_SLIDER_TYPE_PORT_MULTIPLIER, NULL, NULL, (void *) conn, 0.f, 1.f, 160, \
188 20, 0.f, 1, 0, UI_DRAG_MODE_CURSOR, prefix, " %")
189
194#endif
float(* GenericFloatGetter)(void *object)
Getter prototype for float values.
Definition types.h:73
UiDragMode
Dragging modes for widgets that have click&drag.
Definition ui.h:368
void(* GenericFloatSetter)(void *object, float val)
Setter prototype for float values.
Definition types.h:78
BarSliderWidget * _bar_slider_widget_new(BarSliderType type, float(*get_val)(void *), void(*set_val)(void *, float), void *object, float min, float max, int w, int h, float zero, int convert_to_percentage, int decimals, UiDragMode mode, const char *prefix, const char *suffix)
Creates a bar slider widget for floats.
BarSliderType
Type of slider.
Definition bar_slider.h:38
@ BAR_SLIDER_TYPE_PORT_MULTIPLIER
Port connection multiplier.
Definition bar_slider.h:42
Draggable slider to adjust an amount (such as a percentage).
Definition bar_slider.h:55
int decimals
Number of decimal points to show.
Definition bar_slider.h:59
int height
Widget height.
Definition bar_slider.h:99
UiDragMode mode
Update mode.
Definition bar_slider.h:114
float last_real_val
Cache of text extents.
Definition bar_slider.h:138
int hover
Whether hovering or not.
Definition bar_slider.h:117
PangoLayout * layout
Cache layout.
Definition bar_slider.h:133
GenericFloatGetter snapped_getter
Float getter for snapped values (optional).
Definition bar_slider.h:81
Port * port
Port, if control port.
Definition bar_slider.h:93
float max
Maximum value.
Definition bar_slider.h:69
GenericFloatSetter setter
Float setter.
Definition bar_slider.h:84
float min
Minimum value.
Definition bar_slider.h:72
int editable
Whether the user can change the value.
Definition bar_slider.h:127
double last_x
Used in gesture drag.
Definition bar_slider.h:108
double start_x
Used in gesture drag.
Definition bar_slider.h:111
GenericFloatSetter end_setter
Float setter for drag end.
Definition bar_slider.h:90
int show_value
Whether to show the value in text or just the prefix + suffix.
Definition bar_slider.h:124
float zero
Zero point.
Definition bar_slider.h:75
BarSliderType type
The type of slider.
Definition bar_slider.h:120
GenericFloatSetter init_setter
Float setter for drag begin.
Definition bar_slider.h:87
void * object
Object to call get/set with.
Definition bar_slider.h:102
GtkGestureDrag * drag
Used when dragging.
Definition bar_slider.h:105
int width
Widget width.
Definition bar_slider.h:96
int convert_to_percentage
Multiply the value by 100 when showing it.
Definition bar_slider.h:130
GenericFloatGetter getter
Float getter.
Definition bar_slider.h:78
Must ONLY be created via port_new()
Definition port.h:139
Custom types.
User Interface utils.