diff options
Diffstat (limited to 'src/jalv_gtk.c')
-rw-r--r-- | src/jalv_gtk.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index 4a8930d..16cff34 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -48,10 +48,10 @@ static Jalv* s_jalv = NULL; static GtkCheckMenuItem* active_preset_item = NULL; static bool updating = false; -/// Widget for a control +/// Widget(s) for a control port or parameter typedef struct { - GtkSpinButton* spin; - GtkWidget* control; + GtkSpinButton* spin; ///< Spinner for numbers, or null + GtkWidget* control; ///< Primary value control } Controller; static float @@ -586,20 +586,21 @@ differ_enough(float a, float b) static void set_float_control(const ControlID* control, float value) { - if (control->value_type == control->forge->Int) { + const LV2_Atom_Forge* const forge = &s_jalv->forge; + if (control->value_type == forge->Int) { const int32_t ival = lrintf(value); - set_control(control, sizeof(ival), control->forge->Int, &ival); - } else if (control->value_type == control->forge->Long) { + set_control(control, sizeof(ival), forge->Int, &ival); + } else if (control->value_type == forge->Long) { const int64_t lval = lrintf(value); - set_control(control, sizeof(lval), control->forge->Long, &lval); - } else if (control->value_type == control->forge->Float) { - set_control(control, sizeof(value), control->forge->Float, &value); - } else if (control->value_type == control->forge->Double) { + set_control(control, sizeof(lval), forge->Long, &lval); + } else if (control->value_type == forge->Float) { + set_control(control, sizeof(value), forge->Float, &value); + } else if (control->value_type == forge->Double) { const double dval = value; - set_control(control, sizeof(dval), control->forge->Double, &dval); - } else if (control->value_type == control->forge->Bool) { + set_control(control, sizeof(dval), forge->Double, &dval); + } else if (control->value_type == forge->Bool) { const int32_t ival = value; - set_control(control, sizeof(ival), control->forge->Bool, &ival); + set_control(control, sizeof(ival), forge->Bool, &ival); } Controller* controller = (Controller*)control->widget; @@ -789,17 +790,13 @@ jalv_frontend_port_event(Jalv* jalv, return; } - if (protocol == 0 && (Controller*)jalv->ports[port_index].widget) { - control_changed(jalv, - (Controller*)jalv->ports[port_index].widget, - buffer_size, - jalv->forge.Float, - buffer); - return; - } - if (protocol == 0) { - return; // No widget (probably notOnGUI) + Controller* const controller = (Controller*)jalv->ports[port_index].widget; + if (controller) { + control_changed(jalv, controller, buffer_size, jalv->forge.Float, buffer); + } + + return; } if (protocol != jalv->urids.atom_eventTransfer) { @@ -905,7 +902,7 @@ string_changed(GtkEntry* widget, gpointer data) const ControlID* control = (const ControlID*)data; const char* string = gtk_entry_get_text(widget); - set_control(control, strlen(string) + 1, control->forge->String, string); + set_control(control, strlen(string) + 1, s_jalv->forge.String, string); } static void @@ -1211,7 +1208,7 @@ build_control_widget(Jalv* jalv, GtkWidget* window) record->widget = controller; if (record->type == PORT) { - jalv->ports[record->index].widget = controller; + jalv->ports[record->id.index].widget = controller; } if (controller) { // Add row to table for this controller |