From ef901d4a483537768ae61fa48ef1b34726bea493 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 26 Jan 2023 01:56:54 +0100 Subject: [PATCH] Cleanup & refactor --- include/ui.h | 6 ++++-- src/ui/events.c | 1 + src/ui/gemgraph.ui | 28 ++++++++++++++++++++-------- src/ui/window.c | 15 +++++++-------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/include/ui.h b/include/ui.h index 531d72e..d78d5dd 100644 --- a/include/ui.h +++ b/include/ui.h @@ -30,6 +30,8 @@ extern float rotation_angles[N_AXIS]; +extern GtkWidget *gl_area; + G_BEGIN_DECLS #define GEM_GRAPH_CLIENT_TYPE_WINDOW (gem_graph_client_window_get_type()) @@ -156,8 +158,8 @@ void on_close_window(GtkWidget *widget); void ui_set_stack(const char *mode); -void ui_send_notification(const char *message); +void ui_setup_glarea(GtkGLArea *target, GtkBox *target_controls); void ui_send_internal_notification(const char *message); void ui_close_internal_notification(void); void ui_toggle_sidebar(); -void ui_setup_glarea(); + diff --git a/src/ui/events.c b/src/ui/events.c index bd0e358..f9f7838 100644 --- a/src/ui/events.c +++ b/src/ui/events.c @@ -25,6 +25,7 @@ #include #include "../../include/base.h" +#include "../../include/graphics.h" #include "../../include/ui.h" void on_about_action(GSimpleAction *action, diff --git a/src/ui/gemgraph.ui b/src/ui/gemgraph.ui index 93bbd17..e37fbb9 100644 --- a/src/ui/gemgraph.ui +++ b/src/ui/gemgraph.ui @@ -137,10 +137,16 @@ presentation - - center - <b>Main zone: presentation mode</b> - True + + vertical + + + + + + + + @@ -149,10 +155,16 @@ edition - - center - <b>Main zone: edition mode</b> - True + + vertical + + + + + + + + diff --git a/src/ui/window.c b/src/ui/window.c index e874ac8..fef3a55 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -27,14 +27,13 @@ #include #include "../../include/base.h" -#include "../../include/graphics.h" #include "../../include/ui.h" /* -------------------------------------------------------------------------- */ float rotation_angles[N_AXIS] = { 0.0 }; // Rotation angles on each axis -static GtkWidget *gl_area = NULL; +GtkWidget *gl_area = NULL; static GemGraphClientWindow *window; @@ -122,7 +121,7 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self) ui_toggle_sidebar(); // Setup GLArea - ui_setup_glarea(); + ui_setup_glarea(window->run_glarea, window->run_controls); } /* -------------------------------------------------------------------------- */ @@ -242,13 +241,13 @@ static inline GtkWidget *create_axis_slider(int axis) return box; } -void ui_setup_glarea() +void ui_setup_glarea(GtkGLArea *target, GtkBox *target_controls) { int i, minor=4, major=0; - GtkWidget * controls; + GtkWidget *controls; - gl_area = GTK_WIDGET(window->run_glarea); - controls = GTK_WIDGET(window->run_controls); + gl_area = GTK_WIDGET(target); + controls = GTK_WIDGET(target_controls); gtk_widget_set_hexpand(gl_area, TRUE); gtk_widget_set_vexpand(gl_area, TRUE); gtk_widget_set_halign(gl_area, GTK_ALIGN_CENTER); @@ -270,7 +269,7 @@ void ui_setup_glarea() for(i = 0; i < N_AXIS; i++) gtk_box_append(GTK_BOX(controls), create_axis_slider(i)); - gtk_gl_area_set_auto_render(window->run_glarea, true); + gtk_gl_area_set_auto_render(target, true); gtk_widget_show(GTK_WIDGET(gl_area)); gtk_gl_area_set_required_version( GTK_GL_AREA(gl_area), minor, major);