diff --git a/include/fsm.h b/include/fsm.h index 55c55a9..66b4bf6 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -50,6 +50,9 @@ void fsm_set_exec_edit (int value); void fsm_set_state_rules_data (int value); void fsm_reset_all_objects_transparencies_at_value (int value); +void fsm_memorize_all_objects_transparencies_current_values (int value); +void fsm_reset_all_objects_transparencies_from_mem (int value); + void fsm_reset_all_situations_transparencies_at_value (int value); diff --git a/include/signal.h b/include/signal.h index ae6b87e..e387ac3 100644 --- a/include/signal.h +++ b/include/signal.h @@ -128,6 +128,9 @@ void on_clicked_search (GtkWidget *btt_menu, gpointer list_box); /******************************************************************************/ void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar); +void on_objects_box_do_memorize (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar); +void on_objects_box_do_reset_from_mem (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar); + void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar); diff --git a/src/fsm.c b/src/fsm.c index d0991ea..89e81a6 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -65,6 +65,17 @@ void fsm_set_state_rules_data (int value) } } + + + + + + + + + + + void fsm_reset_all_objects_transparencies_at_value (int value) { // if (choice_OBJECTS_box_RESET_VALUE != value) { << NON: Je veux pouvoir @@ -76,21 +87,41 @@ void fsm_reset_all_objects_transparencies_at_value (int value) widget_reset_all_objects_transparencies_to_value (value); } +void fsm_memorize_all_objects_transparencies_current_values (int value) +{ + debug_printing (value, 3); // OBJECTS_box_RESET_VALUE is sub_automaton 2 + choice_OBJECTS_box_RESET_VALUE = value; + widget_reset_all_objects_transparencies_to_value (value); +} + +void fsm_reset_all_objects_transparencies_from_mem (int value) +{ + debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2 + choice_OBJECTS_box_RESET_VALUE = value; + widget_reset_all_objects_transparencies_to_value (value); +} + void fsm_reset_all_situations_transparencies_at_value (int value) { -// if (choice_SITUATIONS_box_RESET_VALUE != value) { << NON: Je veux pouvoir -// d'emblée tout remettre à zéro sans avoir à manipuler le curseur auparavant. -// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé. - - debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3 + debug_printing (value, 4); // SITUATIONS_box_RESET_VALUE is sub_automaton 5 choice_SITUATIONS_box_RESET_VALUE = value; widget_reset_all_situations_transparencies_to_value (value); } + + + + + + + + + + void fsm_set_situations_box_reset_value (int value) { if (choice_SITUATIONS_box_RESET_VALUE != value) { - debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3 + debug_printing (value, 5); // SITUATIONS_box_RESET_VALUE is sub_automaton 5 choice_SITUATIONS_box_RESET_VALUE = value; } } @@ -127,7 +158,13 @@ static void debug_printing (int value, int sub_automaton) case (2) : printf("fsm_set_objects_box_reset_value : %3d > %3d\n", fsm_get_objects_box_reset_value(), value); break; - case (3) : printf("fsm_set_situations_box_reset_value : %3d > %3d\n", + case (3) : printf("fsm_set_objects_box_memorize : %3d > %3d\n", + fsm_get_objects_box_reset_value(), value); + break; + case (4) : printf("fsm_set_objects_box_restore : %3d > %3d\n", + fsm_get_objects_box_reset_value(), value); + break; + case (5) : printf("fsm_set_situations_box_reset_value : %3d > %3d\n", fsm_get_situations_box_reset_value(), value); break; default : printf("default in automaton.debug_printing()\n"); diff --git a/src/signal.c b/src/signal.c index 44c1895..46cfc3f 100644 --- a/src/signal.c +++ b/src/signal.c @@ -297,12 +297,26 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) } } + + void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) { GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar); fsm_reset_all_objects_transparencies_at_value (gtk_adjustment_get_value (adj_obj)); } +void on_objects_box_do_memorize (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) +{ + GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar); + fsm_memorize_all_objects_transparencies_current_values (gtk_adjustment_get_value (adj_obj)); +} + +void on_objects_box_do_reset_from_mem (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) +{ + GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar); + fsm_reset_all_objects_transparencies_from_mem (gtk_adjustment_get_value (adj_obj)); +} + void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) { GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar); diff --git a/src/widget/state/top.c b/src/widget/state/top.c index db876d8..85b59bc 100644 --- a/src/widget/state/top.c +++ b/src/widget/state/top.c @@ -33,19 +33,9 @@ #define UPPER_COMPARTMENT_PARTITION 600 -/* L'image de l'état de l'espace (au centre) fait partie d'un panneau "milieu", - * qui est encadré par les deux panneaux: "haut" et "bas". - * La partie droite du panneau "milieu" est elle-même un panneau de commandes. - * - * Si l'on nomme ces panneaux selon leur fonction, on trouvera: - * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer. - * ce panneau peut avoir deux apparences (et fonctions) différentes: - * - en mode EDIT, seuls les outils d'édition de l'état sont disponibles - * - en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles - * - CAMERA à droite permet de choisir la position de la caméra - * - CONTRAST en haut permet de modifier un à un les contrastes des objets et des situations - * afin de mieux mettre en évidence l'objet ou le phénomène d'intérêt */ - +/******************************************************************************/ +/* O B J E C T S */ +/******************************************************************************/ static GtkScrollbar *object_bar [n_objects]; static GtkAdjustment *object_adjust [n_objects]; @@ -58,17 +48,58 @@ void widget_reset_all_objects_transparencies_to_value (int value) else gtk_adjustment_set_value (object_adjust [i], rand() % 127); } -static GtkBox *rec_OBJECTS_box() +static void *get_objects_box() { GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); GtkAdjustment *reset_value = gtk_adjustment_new (0, 0, 127, 1, 0, 0); - GtkScrollbar *reset_scrollbar = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, reset_value)); + GtkScrollbar *reset_scrollbar = + GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, reset_value)); + gtk_box_append (objects_box, gtk_label_new (" ")); // AD HOC (pour "centrer") gtk_box_append (objects_box, GTK_WIDGET (reset_scrollbar)); + + + GtkBox *reset_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + + GtkWidget *btt_store_this = gtk_toggle_button_new (); + const char *btt_store_this_tip = " store current transparencies values.\n\n\ + warning : this action will delete \n previous storage of these values"; + char tooltip_text_for_btt_store [140]; + sprintf(tooltip_text_for_btt_store, btt_store_this_tip); + gtk_widget_set_tooltip_text (GTK_WIDGET (btt_store_this), btt_store_this_tip); + gtk_button_set_icon_name (GTK_BUTTON (btt_store_this), + "view-restore-symbolic"); + g_signal_connect (btt_store_this, "toggled", + G_CALLBACK (on_objects_box_do_memorize), reset_scrollbar); + + GtkWidget *btt_restore = gtk_toggle_button_new (); + const char *btt_restore_this_tip = " restore transparencies\n\ + from previous storage"; // from the last storage ? + char tooltip_text_for_btt_restore [140]; + sprintf(tooltip_text_for_btt_restore, btt_restore_this_tip); + gtk_widget_set_tooltip_text (GTK_WIDGET (btt_restore), btt_restore_this_tip); + gtk_button_set_icon_name (GTK_BUTTON (btt_restore), + "view-fullscreen-symbolic"); + g_signal_connect (btt_restore, "toggled", + G_CALLBACK (on_objects_box_do_reset_from_mem), reset_scrollbar); + GtkWidget *btt_reset = gtk_toggle_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); - g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_objects_box_do_reset), reset_scrollbar); - gtk_box_append (objects_box, btt_reset); + const char *btt_reset_all = "reset all transparencies to the value\n\ + currently set by the left bar"; + char tooltip_text_for_btt_reset [140]; + sprintf(tooltip_text_for_btt_reset, btt_reset_all); + gtk_widget_set_tooltip_text (GTK_WIDGET (btt_reset), btt_reset_all); + gtk_button_set_icon_name (GTK_BUTTON (btt_reset), + "view-refresh-symbolic"); + g_signal_connect (btt_reset, "toggled", + G_CALLBACK (on_objects_box_do_reset), reset_scrollbar); + + gtk_box_append (reset_box, btt_store_this); + gtk_box_append (reset_box, btt_restore); + gtk_box_append (reset_box, btt_reset); + + gtk_box_append (objects_box, GTK_WIDGET (reset_box)); + // GtkAdjustment *object_adjust [n_objects]; // (value, lower, upper, step_increment, page_increment, page_size) for (int i = 0; i < n_objects; i++) @@ -91,6 +122,13 @@ static GtkBox *rec_OBJECTS_box() return objects_box; } + + +/******************************************************************************/ +/* S I T U A T I O N S */ +/******************************************************************************/ + + static GtkScrollbar *situation_bar [n_situations]; static GtkAdjustment *situation_adjust [n_situations]; @@ -102,7 +140,7 @@ void widget_reset_all_situations_transparencies_to_value (int value) else gtk_adjustment_set_value (situation_adjust [i], rand() % 127); } -static GtkBox *rec_SITUATIONS_box() +static void *get_situations_box() { GtkBox *situations_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); GtkAdjustment *reset_value = gtk_adjustment_new (0, 0, 127, 1, 0, 0); @@ -139,7 +177,7 @@ static GtkBox *rec_SITUATIONS_box() /******************************************************************************/ -/* S T A T E p a g e > t h r e e t o p l e v e l b o x e s */ +/* S T A T E p a g e > t o p l e v e l b o x */ /******************************************************************************/ void *widget_get_graph_view_control() @@ -148,15 +186,18 @@ void *widget_get_graph_view_control() gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency - gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (rec_OBJECTS_box())); + gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box())); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); + GtkWidget *scroll_situations = gtk_scrolled_window_new (); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification - gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (rec_SITUATIONS_box())); + gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box())); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); + GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_situations));