Cleanup & refactor

This commit is contained in:
Adrien Bourmault 2023-01-26 01:56:54 +01:00
parent 8aae05fefc
commit ef901d4a48
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
4 changed files with 32 additions and 18 deletions

View File

@ -30,6 +30,8 @@
extern float rotation_angles[N_AXIS]; extern float rotation_angles[N_AXIS];
extern GtkWidget *gl_area;
G_BEGIN_DECLS G_BEGIN_DECLS
#define GEM_GRAPH_CLIENT_TYPE_WINDOW (gem_graph_client_window_get_type()) #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_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_send_internal_notification(const char *message);
void ui_close_internal_notification(void); void ui_close_internal_notification(void);
void ui_toggle_sidebar(); void ui_toggle_sidebar();
void ui_setup_glarea();

View File

@ -25,6 +25,7 @@
#include <stdio.h> #include <stdio.h>
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/graphics.h"
#include "../../include/ui.h" #include "../../include/ui.h"
void on_about_action(GSimpleAction *action, void on_about_action(GSimpleAction *action,

View File

@ -137,10 +137,16 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">presentation</property> <property name="name">presentation</property>
<property name="child"> <property name="child">
<object class="GtkLabel"> <object class="GtkBox">
<property name="halign">center</property> <property name="orientation">vertical</property>
<property name="label" translatable="yes">&lt;b&gt;Main zone: presentation mode&lt;/b&gt;</property> <child>
<property name="use-markup">True</property> <object class="GtkGlArea" id="presentation_glarea">
</object>
</child>
<child>
<object class="GtkBox" id="presentation_controls">
</object>
</child>
</object> </object>
</property> </property>
</object> </object>
@ -149,10 +155,16 @@
<object class="GtkStackPage"> <object class="GtkStackPage">
<property name="name">edition</property> <property name="name">edition</property>
<property name="child"> <property name="child">
<object class="GtkLabel"> <object class="GtkBox">
<property name="halign">center</property> <property name="orientation">vertical</property>
<property name="label" translatable="yes">&lt;b&gt;Main zone: edition mode&lt;/b&gt;</property> <child>
<property name="use-markup">True</property> <object class="GtkGlArea" id="edition_glarea">
</object>
</child>
<child>
<object class="GtkBox" id="edition_controls">
</object>
</child>
</object> </object>
</property> </property>
</object> </object>

View File

@ -27,14 +27,13 @@
#include <glib-2.0/glib.h> #include <glib-2.0/glib.h>
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/graphics.h"
#include "../../include/ui.h" #include "../../include/ui.h"
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
float rotation_angles[N_AXIS] = { 0.0 }; // Rotation angles on each axis float rotation_angles[N_AXIS] = { 0.0 }; // Rotation angles on each axis
static GtkWidget *gl_area = NULL; GtkWidget *gl_area = NULL;
static GemGraphClientWindow *window; static GemGraphClientWindow *window;
@ -122,7 +121,7 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self)
ui_toggle_sidebar(); ui_toggle_sidebar();
// Setup GLArea // 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; return box;
} }
void ui_setup_glarea() void ui_setup_glarea(GtkGLArea *target, GtkBox *target_controls)
{ {
int i, minor=4, major=0; int i, minor=4, major=0;
GtkWidget *controls; GtkWidget *controls;
gl_area = GTK_WIDGET(window->run_glarea); gl_area = GTK_WIDGET(target);
controls = GTK_WIDGET(window->run_controls); controls = GTK_WIDGET(target_controls);
gtk_widget_set_hexpand(gl_area, TRUE); gtk_widget_set_hexpand(gl_area, TRUE);
gtk_widget_set_vexpand(gl_area, TRUE); gtk_widget_set_vexpand(gl_area, TRUE);
gtk_widget_set_halign(gl_area, GTK_ALIGN_CENTER); gtk_widget_set_halign(gl_area, GTK_ALIGN_CENTER);
@ -270,7 +269,7 @@ void ui_setup_glarea()
for(i = 0; i < N_AXIS; i++) for(i = 0; i < N_AXIS; i++)
gtk_box_append(GTK_BOX(controls), create_axis_slider(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_widget_show(GTK_WIDGET(gl_area));
gtk_gl_area_set_required_version( GTK_GL_AREA(gl_area), minor, major); gtk_gl_area_set_required_version( GTK_GL_AREA(gl_area), minor, major);