Compare commits

...

2 Commits

Author SHA1 Message Date
Jean Sirmai 89bde1d284
WIP: using 'preferences' < first step 2024-07-24 23:07:14 +02:00
Jean Sirmai 01b59ee7ac
WIP: cleaning, cleaning... 2024-07-24 18:22:59 +02:00
6 changed files with 61 additions and 86 deletions

View File

@ -42,15 +42,18 @@ enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor
#define n_objects 32
#define n_situations 128
int fsm_get_exec_edit (); int fsm_get_exec_edit ();
int fsm_get_state_rules_data (); int fsm_get_state_rules_data ();
int fsm_get_objects_box_reset_value (); int fsm_get_store_restore_reset ();
int fsm_get_situations_box_reset_value ();
void fsm_set_exec_edit (int value); void fsm_set_exec_edit (int value);
void fsm_set_state_rules_data (int value); void fsm_set_state_rules_data (int value);
void fsm_set_store_restore_reset (int target, int value); void fsm_set_store_restore_reset (int target, int value);
void fsm_reset_all_situations_transparencies_at_value (int value); void fsm_reset_all_situations_transparencies_at_value (int value);

View File

@ -33,3 +33,11 @@
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
void print_sth(char *msg); void print_sth(char *msg);
struct preferences {
int id;
};
void pref_store_objects_transparencies_values ();
void pref_restore_previous_objects_transparencies_values ();
void pref_reset_objects_transparencies_values();

View File

@ -80,7 +80,7 @@ void on_toggle_state_rules_data (GtkWidget *btt_STATE_RULES_DATA, gpointer user_
/******************************************************************************/ /*************n_objects*****************************************************************/
/* D I A L O G W I N D O W */ /* D I A L O G W I N D O W */
/******************************************************************************/ /******************************************************************************/

View File

@ -31,9 +31,6 @@
#pragma once #pragma once
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#define n_objects 32
#define n_situations 128
/******************************************************************************/ /******************************************************************************/
/* W I N D O W S */ /* W I N D O W S */
/******************************************************************************/ /******************************************************************************/

110
src/fsm.c
View File

@ -41,136 +41,92 @@ static int choice_EXEC_EDIT = EXEC;
static int choice_STATE_RULES_DATA = STATE; static int choice_STATE_RULES_DATA = STATE;
static int choice_STORE_RESTORE_RESET = STORE; static int choice_STORE_RESTORE_RESET = STORE;
static int choice_OBJECTS_box_RESET_VALUE = -1; int fsm_get_exec_edit () {return choice_EXEC_EDIT;}
static int choice_SITUATIONS_box_RESET_VALUE = -1; int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;}
int fsm_get_store_restore_reset () {return choice_STORE_RESTORE_RESET;}
/******************************************************************************/ /******************************************************************************/
/* T R A N S I T I O N S */ /* T R A N S I T I O N S */
/******************************************************************************/ /******************************************************************************/
static void debug_printing (int value, int sub_automaton); static void debug_printing (int choice, int value, int sub_automaton);
void fsm_set_exec_edit (int value) void fsm_set_exec_edit (int choice)
{ {
if (choice_EXEC_EDIT != value) { if (choice_EXEC_EDIT != choice) {
debug_printing (value, 0); // EXEC_EDIT is sub_automaton 0 debug_printing (choice, 0, 0); // EXEC_EDIT is sub_automaton 0
choice_EXEC_EDIT = value; choice_EXEC_EDIT = choice;
} }
} }
void fsm_set_state_rules_data (int value) void fsm_set_state_rules_data (int choice)
{ {
if (choice_STATE_RULES_DATA != value) { if (choice_STATE_RULES_DATA != choice) {
debug_printing (value, 1); // STATE_RULES_DATA is sub_automaton 1 debug_printing (choice, 0, 1); // STATE_RULES_DATA is sub_automaton 1
choice_STATE_RULES_DATA = value; choice_STATE_RULES_DATA = choice;
} }
} }
void fsm_set_store_restore_reset (int target, int value) void fsm_set_store_restore_reset (int choice, int value)
{ {
printf("fsm_set_store_restore_reset(%d,%3d) > ", target, value); choice_STORE_RESTORE_RESET = choice;
switch (target) {
case (STORE) : printf("STORE\n"); break; switch (choice) {
case (RESTORE) : printf("RESTORE\n"); break; case (STORE) : printf("STORE current values in MEM ");
case (RESET) : printf("RESET\n"); break; pref_store_objects_transparencies_values (); break;
case (RESTORE) : printf("RESTORE values from MEM "); break;
case (RESET) : printf("RESET current values from [value] "); break;
default : printf("default in signal.switch_store_restore_reset()\n"); default : printf("default in signal.switch_store_restore_reset()\n");
} }
// debug_printing (target, 2); // STORE_RESTORE_RESET is sub_automaton 2
// choice_STORE_RESTORE_RESET = value; debug_printing (choice, value, 2); // STORE_RESTORE_RESET is sub_automaton 2
} }
void fsm_restore_all_objects_transparencies_from_mem (int value)
{
print_sth("Officially introducing : ' P R E F E R E N C E S' !");
debug_printing (value, 2); // OBJECTS_box_RESET_VALUES is sub_automaton 2
}
void fsm_store_all_objects_transparencies_current_values (int value)
{
debug_printing (value, 3); // OBJECTS_box_STORE_VALUES is sub_automaton 3
}
void fsm_reset_all_objects_transparencies_at_value (int value)
{
// if (choice_OBJECTS_box_RESET_VALUE != value) { << NON: Je veux pouvoir
// d'emblée tout remettre à zéro sans avoir eu à manipuler le curseur auparavant.
// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé.
debug_printing (value, 4); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
widget_reset_all_objects_transparencies_to_value (value);
}
// ---------------------- S I T U A T I O N S ---------------------------// // ---------------------- S I T U A T I O N S ---------------------------//
static int choice_SITUATIONS_box_RESET_VALUE = -1;
void fsm_reset_all_situations_transparencies_at_value (int value) void fsm_reset_all_situations_transparencies_at_value (int value)
{ {
debug_printing (value, 5); // SITUATIONS_box_RESTORE_VALUES is sub_automaton 4 debug_printing (choice_SITUATIONS_box_RESET_VALUE, value, 3);
// SITUATIONS_box_RESTORE_VALUES is sub_automaton 3
choice_SITUATIONS_box_RESET_VALUE = value; choice_SITUATIONS_box_RESET_VALUE = value;
widget_reset_all_situations_transparencies_to_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, 5); // SITUATIONS_box_RESET_VALUE is sub_automaton 5
choice_SITUATIONS_box_RESET_VALUE = value;
}
}
int fsm_get_exec_edit () {return choice_EXEC_EDIT;}
int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;}
int fsm_get_objects_box_reset_value () {return choice_OBJECTS_box_RESET_VALUE;}
int fsm_get_situations_box_reset_value () {return choice_SITUATIONS_box_RESET_VALUE;}
/******************************************************************************/ /******************************************************************************/
/* D E B U G G E R S */ /* D E B U G G E R S */
/******************************************************************************/ /***************************************************************************ù***/
static char *tab_0 [] = { "EXEC", "EDIT" }; static char *tab_0 [] = { "EXEC", "EDIT" };
static char *tab_1 [] = { "STATE", "RULES", "DATA" }; static char *tab_1 [] = { "STATE", "RULES", "DATA" };
static char *tab_2 [] = { "STORE", "RESTORE", "RESET" }; static char *tab_2 [] = { "STORE", "RESTORE", "RESET" };
static void debug_printing (int value, int sub_automaton) static void debug_printing (int choice, int value, int sub_automaton)
{ {
switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and
// sub_automaton 1 is STATE_RULES_DATA // sub_automaton 1 is STATE_RULES_DATA
case (0) : printf("switch %5s x %5s > %5s x %5s\n", case (0) : printf("switch %5s x %5s > %5s x %5s\n",
tab_0 [choice_EXEC_EDIT], tab_0 [choice_EXEC_EDIT],
tab_1 [choice_STATE_RULES_DATA], tab_1 [choice_STATE_RULES_DATA],
tab_0 [value], tab_0 [choice],
tab_1 [choice_STATE_RULES_DATA]); tab_1 [choice_STATE_RULES_DATA]);
break; break;
case (1) : printf("switch %5s x %5s > %5s x %5s\n", case (1) : printf("switch %5s x %5s > %5s x %5s\n",
tab_0 [choice_EXEC_EDIT], tab_0 [choice_EXEC_EDIT],
tab_1 [choice_STATE_RULES_DATA], tab_1 [choice_STATE_RULES_DATA],
tab_0 [choice_EXEC_EDIT], tab_0 [choice_EXEC_EDIT],
tab_1 [value]); tab_1 [choice]);
break; break;
case (2) : printf("fsm_set_store_restore_reset <> target = %s\n", case (2) : printf("fsm_set_store_restore_reset <> choice = %s\n",
tab_2 [choice_STORE_RESTORE_RESET]); tab_2 [choice_STORE_RESTORE_RESET]);
break; break;
case (3) : printf("fsm_reset_all_situations_transparencies_at_value : %3d\n", value);
break;
default : printf("default in automaton.debug_printing()\n"); default : printf("default in automaton.debug_printing()\n");
} }

View File

@ -33,4 +33,15 @@
#include "../include/signal.h" #include "../include/signal.h"
#include "../include/widget.h" #include "../include/widget.h"
void print_sth(char *msg){printf("%s\n", msg);} void print_sth(char *msg) {printf("%s\n", msg);}
struct preferences *pref;
void pref_store_objects_transparencies_values()
{
printf("pref_store_objects_transparencies_values n_objects = %d\n", n_objects);
}
void pref_restore_previous_objects_transparencies_values() {}
void pref_reset_objects_transparencies_values() {}