2024-04-27 08:46:17 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
2024-05-01 10:07:50 +02:00
|
|
|
//#include "warm.h"
|
2024-04-29 06:03:00 +02:00
|
|
|
#include "cold.h"
|
2024-04-27 08:46:17 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkScrolledWindow *get_scrolled_gl_area(){
|
|
|
|
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
|
2024-05-01 19:40:36 +02:00
|
|
|
gtk_scrolled_window_set_min_content_width (scrolled, W);
|
|
|
|
gtk_scrolled_window_set_min_content_height (scrolled, H);
|
2024-05-01 11:01:50 +02:00
|
|
|
// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
|
|
|
// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
|
|
|
// (value, lower, upper, step_increment, page_increment, page_size)
|
|
|
|
GtkWidget *GLarea = gtk_gl_area_new();
|
|
|
|
gtk_scrolled_window_set_child (scrolled, GLarea);
|
|
|
|
// https://docs.gtk.org/gtk4/class.GLArea.html
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
return scrolled;
|
2024-04-29 23:43:04 +02:00
|
|
|
}
|
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkWidget *get_space_page_new_2024_04_30 (){
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkBox *controls_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
|
|
|
gtk_box_append (controls_box, gtk_button_new_with_label ("RUN / STOP"));
|
|
|
|
// GtkLevelBar *slow_speed = GTK_LEVEL_BAR (gtk_level_bar_new ()); // or __new_for_interval(0,100);
|
|
|
|
// gtk_level_bar_set_mode (slow_speed, GTK_LEVEL_BAR_MODE_CONTINUOUS); //_DISCRETE
|
|
|
|
gtk_box_append (controls_box, gtk_button_new_with_label ("slow down / speed up")); // GTK_WIDGET(slow_speed));
|
|
|
|
gtk_box_append (controls_box, gtk_button_new_with_label ("step by step"));
|
|
|
|
GtkProgressBar *buffer = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
|
|
|
|
gtk_progress_bar_set_text (buffer, "<<-- BUFFER -->>");
|
|
|
|
gtk_progress_bar_set_show_text (buffer, TRUE);
|
|
|
|
gtk_box_append (controls_box, GTK_WIDGET(buffer));//gtk_button_new_with_label ("---- buffer ----"));
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkBox *XYZ_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2
|
|
|
|
// GtkWidget *scale_X = gtk_scale_button_new (0, 360, 10, NULL); < à étudier
|
|
|
|
// (double min, double max, double step, const char** icons)
|
|
|
|
GtkAdjustment *X_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkAdjustment *Y_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkAdjustment *Z_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkWidget *scroll_X = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, X_adjust);
|
|
|
|
GtkWidget *scroll_Y = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Y_adjust);
|
|
|
|
GtkWidget *scroll_Z = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Z_adjust);
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
gtk_box_append (XYZ_box, scroll_X);
|
|
|
|
gtk_box_append (XYZ_box, scroll_Y);
|
|
|
|
gtk_box_append (XYZ_box, scroll_Z);
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkWidget *bottom_grid = gtk_grid_new();
|
|
|
|
gtk_grid_attach (GTK_GRID(bottom_grid), GTK_WIDGET(controls_box), 0, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID(bottom_grid), gtk_button_new_with_label ("Objects / Situations (transparences, styles)"), 0, 1, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID(bottom_grid), gtk_button_new_with_label ("zoom, +/- grid,\npresentation,\nstyles,..."), 1, 0, 1, 2);
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
GtkWidget *space_grid = gtk_grid_new();
|
|
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_scrolled_gl_area()), 0, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(XYZ_box), 1, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(bottom_grid), 0, 1, 2, 1); // ?! échec x_size
|
|
|
|
// gtk_grid_attach (GTK_GRID(space_grid), gtk_button_new_with_label ("?"), 1, 1, 1, 1);
|
2024-04-29 23:43:04 +02:00
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
return space_grid;
|
2024-04-29 23:43:04 +02:00
|
|
|
}
|
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
/* void activate (GtkApplication *app, gpointer user_data) {
|
2024-04-29 06:03:00 +02:00
|
|
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
|
|
|
window_bar (window, "window");
|
|
|
|
GtkWidget *grid = gtk_grid_new();
|
|
|
|
gtk_window_set_child (window, grid);
|
|
|
|
|
|
|
|
click_print_do (NULL, grid, "(I)", "n°1\n", 0,0,1,1);
|
|
|
|
click_print_do (NULL, grid, "(II)", "n°2\n", 1,0,1,1);
|
|
|
|
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,1);
|
|
|
|
|
|
|
|
GtkWidget *grid_2 = gtk_grid_new();
|
|
|
|
GtkWidget* notebook = gtk_notebook_new ();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), notebook, 0, 3, 1, 1);
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), grid_2, gtk_label_new ("hello !"));
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), gtk_button_new_with_label ("me too !"), NULL);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid_2), gtk_button_new_with_label ("here am I !"), 0, 0, 1, 1);
|
|
|
|
|
|
|
|
GtkWidget *box_3 = gtk_box_new (0, 0);
|
|
|
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("30"));
|
|
|
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("31"));
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), box_3, 0, 2, 1, 1);
|
|
|
|
|
|
|
|
GtkWidget *grid_3 = gtk_grid_new();
|
|
|
|
GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
GtkWidget *frame1 = gtk_frame_new ("hello ?");
|
|
|
|
GtkWidget *frame2 = gtk_frame_new ("it's me !");
|
|
|
|
gtk_frame_set_child ( GTK_FRAME(frame2), grid_3);
|
|
|
|
gtk_paned_set_start_child (GTK_PANED(hpaned), GTK_WIDGET (frame1));
|
|
|
|
gtk_paned_set_end_child (GTK_PANED(hpaned), GTK_WIDGET (frame2));
|
|
|
|
gtk_widget_set_size_request (hpaned, 400, 200);
|
|
|
|
// gtk_widget_set_size_request (frame1, 50, 100); < utile seulement pour la largeur min/max
|
|
|
|
// gtk_widget_set_size_request (frame2, 50, 100);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), hpaned, 0, 4, 3, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid_3), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-29 23:43:04 +02:00
|
|
|
*
|
2024-04-29 06:03:00 +02:00
|
|
|
static void activate_old (GtkApplication *app, gpointer user_data) {
|
|
|
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
|
|
|
window_bar (window, "window");
|
|
|
|
GtkWidget *grid = gtk_grid_new();
|
|
|
|
gtk_window_set_child (window, grid);
|
|
|
|
|
|
|
|
click_print_do (NULL, grid, "(I)", "n°1\n", 0,0,1,1);
|
|
|
|
click_print_do (NULL, grid, "(II)", "n°2\n", 1,0,1,1);
|
|
|
|
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,1);
|
|
|
|
|
|
|
|
GtkWidget *switcher = gtk_stack_switcher_new();
|
|
|
|
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 1, 3, 1);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
GtkStack *stack = GTK_STACK (gtk_stack_new());
|
|
|
|
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
|
|
|
|
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
|
|
|
|
|
|
|
|
GtkWidget *box_0 = gtk_box_new (0, 0);
|
|
|
|
GtkWidget *box_1 = gtk_box_new (0, 0);
|
|
|
|
GtkWidget *box_2 = gtk_box_new (0, 0);
|
|
|
|
gtk_stack_add_titled (stack, box_0, "n°0", "A");
|
|
|
|
gtk_stack_add_titled (stack, box_1, "n°1", "B");
|
|
|
|
gtk_stack_add_titled (stack, box_2, "n°2", "C");
|
|
|
|
GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
|
|
|
|
gtk_selection_model_select_item (stack_selection_model, 1, 1);
|
|
|
|
printf("selected page name is [%s] \n", gtk_stack_get_visible_child_name (stack));
|
|
|
|
GtkWidget *grid_3 = gtk_grid_new();
|
|
|
|
gtk_grid_attach (GTK_GRID (grid_3), gtk_button_new_with_label ("0,0 1,1"), 0, 0, 1, 1);
|
|
|
|
gtk_stack_add_child (stack, grid_3);
|
|
|
|
// gtk_stack_page_set_visible (GTK_STACK_PAGE(stack_selection_model_get_item()), TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
GtkWidget *box_3 = gtk_box_new (0, 0);
|
|
|
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("30"));
|
|
|
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("31"));
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), box_3, 0, 2, 1, 1);
|
|
|
|
|
|
|
|
GtkWidget *grid_2 = gtk_grid_new();
|
|
|
|
GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
GtkWidget *frame1 = gtk_frame_new ("hello ?");
|
|
|
|
GtkWidget *frame2 = gtk_frame_new ("it's me !");
|
|
|
|
gtk_frame_set_child ( GTK_FRAME(frame2), grid_2);
|
|
|
|
gtk_paned_set_start_child (GTK_PANED(hpaned), GTK_WIDGET (frame1));
|
|
|
|
gtk_paned_set_end_child (GTK_PANED(hpaned), GTK_WIDGET (frame2));
|
|
|
|
gtk_widget_set_size_request (hpaned, 400, 200);
|
|
|
|
// gtk_widget_set_size_request (frame1, 50, 100); < utile seulement pour la largeur min/max
|
|
|
|
// gtk_widget_set_size_request (frame2, 50, 100);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), hpaned, 0, 3, 3, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid_2), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
|
|
|
}
|
|
|
|
*/
|