diff --git a/callback.c b/callback.c index 122fb24..9a8b691 100644 --- a/callback.c +++ b/callback.c @@ -130,6 +130,29 @@ void on_glarea_unrealize(GtkWidget *widget) } } +void on_axis_value_change(GtkAdjustment *adjustment, gpointer data) +{ + + GtkWidget *slider = gtk_widget_get_parent(GTK_WIDGET(data)); + GtkWidget *container_widget = gtk_widget_get_parent(GTK_WIDGET(slider)); + + const gchar *label_text = gtk_label_get_label(GTK_LABEL(data)); + + // THANKS ASCIIIII/Unicode/Whateverrr ! + int axis = label_text[0] - 'X'; + + g_assert(axis >= 0 && axis < N_AXIS); + + /* Update the rotation angle */ + ui_update_axis_stack(container_widget, + axis, + gtk_adjustment_get_value(adjustment)); + + /* Update the contents of the GL drawing area */ +} + + + /******************************************************************************/ /* B U T T O N S */ /******************************************************************************/ diff --git a/callback.h b/callback.h index 3fb290e..f157cf4 100644 --- a/callback.h +++ b/callback.h @@ -11,6 +11,8 @@ gboolean on_glarea_render(GtkGLArea *area, GdkGLContext *context); void on_glarea_realize(GtkWidget *widget); void on_glarea_unrealize(GtkWidget *widget); +void on_axis_value_change(GtkAdjustment *adjustment, gpointer data); + void ui_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, gpointer data); void ui_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data); diff --git a/graph_area.c b/graph_area.c index 8fe7d66..dffd2a0 100644 --- a/graph_area.c +++ b/graph_area.c @@ -231,7 +231,7 @@ GtkWidget *create_axis_slider(int axis) gtk_widget_set_visible (label, TRUE); adj = gtk_adjustment_new(0.0, 0.0, 360.0, 1.0, 12.0, 0.0); -////////////////////////// g_signal_connect (adj, "value-changed", G_CALLBACK(on_axis_value_change), (gpointer) label); + g_signal_connect (adj, "value-changed", G_CALLBACK(on_axis_value_change), (gpointer) label); slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adj); gtk_box_append(GTK_BOX(box), slider); gtk_widget_set_hexpand(slider, TRUE); diff --git a/graph_area.h b/graph_area.h index ccec84e..7365f96 100644 --- a/graph_area.h +++ b/graph_area.h @@ -119,6 +119,7 @@ bool graphics_init_shaders(const int stack_id); bool ui_init_graphic_stack(void *container_widget, GError *error_buffer); bool ui_shutdown_graphic_stack(void *container_widget, GError *error_buffer); +bool ui_update_axis_stack(GtkWidget *container_widget, int axis, int value); /* Initializes the buffer of a gl_area * Calls according to the user preferences