gem-graph-client/include/ui.h

156 lines
5.8 KiB
C

/*
* Gem-graph OpenGL experiments
*
* Desc: User interface header
*
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
*
* This file is part of Gem-graph.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <unistd.h>
#include <gtk-4.0/gtk/gtk.h>
#include "../include/base.h"
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())
G_DECLARE_FINAL_TYPE (GemGraphClientWindow,
gem_graph_client_window,
GEM_GRAPH_CLIENT,
WINDOW,
GtkApplicationWindow)
G_END_DECLS
G_BEGIN_DECLS
#define GEM_GRAPH_CLIENT_TYPE_APPLICATION (gem_graph_client_application_get_type())
G_DECLARE_FINAL_TYPE (GemGraphClientApplication,
gem_graph_client_application,
GEM_GRAPH_CLIENT,
APPLICATION,
GtkApplication)
GemGraphClientApplication *gem_graph_client_application_new(const char *application_id,
GApplicationFlags flags);
G_END_DECLS
void ui_enable_action (const char *name);
void ui_disable_action (const char *name);
// Actions
void on_about_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_quit_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_preferences_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_togglesidebar_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_editmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_runmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_presentmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_openfile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_closefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_savefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
void on_toast_close_action (GSimpleAction *action, GVariant *parameter, gpointer user_data);
static const GActionEntry app_actions[] = {
{ "quit", on_quit_action, NULL, NULL, NULL },
{ "about", on_about_action, NULL, NULL, NULL },
{ "preferences", on_preferences_action, NULL, NULL, NULL },
{ "togglesidebar", on_togglesidebar_action, NULL, NULL, NULL },
{ "editmode", on_editmode_action, NULL, NULL, NULL },
{ "runmode", on_runmode_action, NULL, NULL, NULL },
{ "presentmode", on_presentmode_action, NULL, NULL, NULL },
{ "openfile", on_openfile_action, NULL, NULL, NULL },
{ "closefile", on_closefile_action, NULL, NULL, NULL },
{ "savefile", on_savefile_action, NULL, NULL, NULL },
{ "toastclose", on_toast_close_action, NULL, NULL, NULL },
};
// Actions responses
void on_openfile_response(GtkNativeDialog *native,
int response,
GemGraphClientWindow *self);
void on_openfile_response_complete(GObject *source_object,
GAsyncResult *result,
GemGraphClientWindow *self);
// General events
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
gboolean on_render (GtkGLArea * area, GdkGLContext * context);
void on_realize (GtkWidget *widget);
void on_unrealize (GtkWidget *widget);
void on_close_window (GtkWidget *widget);
/* -------------------------------------------------------------------------- */
// Window primitives
void ui_set_stack (const char *mode);
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 ();
/* -------------------------------------------------------------------------- */
// Tree primitives
// struct _GemGraphClientWindow
// {
// GtkApplicationWindow parent_instance;
// /* Template widgets */
// GtkHeaderBar *main_titlebar;
// GtkStack *main_stack;
// GtkStack *side_stack;
// GtkPaned *main_paned;
// GtkMenuButton *main_button_mode;
// GtkToggleButton *main_button_sidebar;
// GtkRevealer *toast_revealer;
// GtkToggleButton *toast_close_button;
// GtkLabel *toast_text;
// GtkGLArea *run_glarea;
// GtkBox *run_controls;
// /* Stack objects */
// GtkStack *runlib_stack;
// GtkBox *runlib_objects;
// };
// G_DEFINE_FINAL_TYPE (GemGraphClientWindow,
// gem_graph_client_window,
// GTK_TYPE_APPLICATION_WINDOW)
void print_test_in_tree_dot_c(void);
//GtkWidget *create_tree_label(void);
//GtkWidget *create_a_button_to_click_on(void);
//GtkWidget *create_a_button_in_the_tab(GemGraphClientWindow *window);