From f11ab2e05edacc2edb1d154c7eaf8d3d67540663 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 29 Jul 2024 05:46:10 +0200 Subject: [PATCH] Introducing the 'View Rules Use' pane. This pane and the comparator can be masked --- include/fsm.h | 5 ++-- include/widget.h | 3 ++ src/main.c | 38 ++++++++++++++---------- src/widget/rules/distrib.c | 55 +++++++++++++++++++++++++---------- src/widget/rules/pilot_box | 47 ++++++++++++++++++++++++++++++ src/widget/rules/select_one.c | 16 ++++------ src/widget/rules/user_tree.c | 44 +++++++++++++++++----------- 7 files changed, 147 insertions(+), 61 deletions(-) create mode 100644 src/widget/rules/pilot_box diff --git a/include/fsm.h b/include/fsm.h index a6e3dbe..b3bd3ba 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -43,8 +43,9 @@ enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor -#define n_objects 32 // arbitrary... -#define n_situations 128 +#define n_rules 64 // arbitrary +#define n_objects 32 // arbitrary too, +#define n_situations 128 // and so on... diff --git a/include/widget.h b/include/widget.h index 0dbb6f8..c15986d 100644 --- a/include/widget.h +++ b/include/widget.h @@ -91,6 +91,9 @@ void *widget_get_rules_tree_and_pilot_box(); void *widget_get_rules_page(); void *widget_get_rule_edit_controls(); void *widget_get_rule_explore_controls(); +void *widget_rule_itself_vs_explore_edit_pane(); +void *widget_get_rules_pilot_box(); +void *widget_get_rules_tree(); /******************************************************************************/ diff --git a/src/main.c b/src/main.c index 480917a..6f9a9fc 100644 --- a/src/main.c +++ b/src/main.c @@ -39,15 +39,20 @@ * Le nom de toute fonction qui peut être appelée d'un autre module doit comporter : * - 1) le nom du module auquel elle appartient (widget, graphics, parse,...) * - 2) une indication sur son action (get, set, rec, fix, create, add,...) - * - 3) une indication sur l'objet de cette action (STATE, RULES, STACK,...) + * - 3) une indication sur l'objet de cette action (state, rules, stock,...) * - * ex: on_save_CURRENT_MODEL() - * model_get_DIM_VALUE() + * ex: on_save_current_model() + * model_get_dim_value() * - * Il est prévisible que 'state.c' devienne un dossier contenant - * les fichiers 'controls.c', 'camera.c', 'contrasts.c' et d'autres, - * Une fonction comme : get_ZOOM_box() - * devra alors être renommé : state_camera_get_ZOOM_box() (par exemple) + * Le fichier 'state.c' est devenu un dossier contenant + * les fichiers 'top.c', 'middle.c', 'bottom.c' et 'distrib.c' + * + * 'middle.c' deviendra, s'il est trop volumineux, un dossier 'middle' + * contenant, par exemple, les fichiers 'camera.c' ou 'contrasts.c' et d'autres + * et ainsi de suite ... + * + * Une fonction comme : get_zoom_box() + * devra alors être renommé : state_camera_get_zoom_box() (par exemple) * * _________________ * @@ -58,7 +63,8 @@ * -------------------------------- * * La description du 'design' des fenêtres se trouve dans le dossier 'widget' - * et s'organise naturellement en arborescence, comme les widgets eux-mêmes. + * et s'organise naturellement en arborescence, + * en se calquant sur l'arborescence des widgets eux-mêmes. * * Il sera donc facile de répartir cette description en dossiers et fichiers * au fur à mesure de son développement. @@ -67,10 +73,10 @@ * > une barre de titre (décrite dans 'topbar') et * > un widget 'child' (la partie sous la barre de titre) * qui peut prendre au moins trois apparences différentes : - * - STATE (montre l'état de l'espace et les commandes associées) - * - RULES (les règles et les commandes associées) - * - STOCK (les données provenant des mesures, les outils d'analyse, etc.) - * (mal défini à ce stade; sera très probablement réparti...) + * - state (montre l'état de l'espace et les commandes associées) + * - rules (les règles et les commandes associées) + * - stock (les données provenant des mesures, les outils d'analyse, etc.) + * (nom provisoire : mal défini à ce stade; fonctions à répartir...) * * La fenêtre principale s'ouvre sur la vue de l'état ('state.c') en mode 'EXEC'. * Cette vue comporte trois panneaux (widgets) principaux: @@ -86,7 +92,7 @@ * 2) Les structures transversales. * -------------------------------- * - * Les fonctions 'transversales' comme celles de 'graphics' 'parse', 'fsm', + * Les fonctions 'transversales' comme celles de 'graphics', 'parse', 'fsm', 'prefer' * doivent pouvoir être accédées directement * sans avoir à passer par la hiérarchie des widgets et/ou callbacks. * Elles restent à la racine: 'src/ @@ -111,9 +117,9 @@ * - analyses de données... * * - * Les préférences des utilisateurs devront être prises en compte. - * Leur recueil et leur mémorisation seront probablement des fonctions centrales - * mais leur mise en oeuvre suivra probalement les voies hiérarchiques. + * Leur recueil et la mémorisation des préférences des utilisateurs + * sont des fonctions centrales + * mais leur mise en oeuvre suivra probalement des voies hiérarchiques. * * On peut prévoir des préférences concernant l'apparence des widgets, * les traductions, les 'disabilities'; etc. diff --git a/src/widget/rules/distrib.c b/src/widget/rules/distrib.c index 1649a40..6970d4c 100644 --- a/src/widget/rules/distrib.c +++ b/src/widget/rules/distrib.c @@ -32,27 +32,27 @@ #include "../../../include/signal.h" -static void *static_widget_get_rule_explore_controls() +void *widget_get_rule_explore_controls() { return gtk_label_new ("________________\n RULE EXPLORE\n\ controls\n'''''''''''''''''''''''''''''"); } -static void *static_widget_get_rule_edit_controls() +void *widget_get_rule_edit_controls() { return gtk_label_new ("___________\n RULE EDIT\n controls\n''''''''''''''''''''"); } -static void *widget_rule_itself_vs_explore_edit_pane() +void *widget_rule_itself_vs_explore_edit_pane() { GtkPaned *rule_itself_vs_explore_edit_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); gtk_paned_set_start_child (rule_itself_vs_explore_edit_pane, GTK_WIDGET (widget_get_selected_rule())); if (fsm_get_exec_edit()) gtk_paned_set_end_child (rule_itself_vs_explore_edit_pane, - GTK_WIDGET (static_widget_get_rule_edit_controls())); + GTK_WIDGET (widget_get_rule_edit_controls())); else gtk_paned_set_end_child (rule_itself_vs_explore_edit_pane, - GTK_WIDGET (static_widget_get_rule_explore_controls())); - gtk_paned_set_position (rule_itself_vs_explore_edit_pane, 800); // WARNING : c'est une position "absolue" + GTK_WIDGET (widget_get_rule_explore_controls())); + gtk_paned_set_position (rule_itself_vs_explore_edit_pane, 660); // WARNING : c'est une position "absolue" gtk_paned_set_wide_handle (rule_itself_vs_explore_edit_pane, TRUE); gtk_paned_set_shrink_start_child (rule_itself_vs_explore_edit_pane, FALSE); gtk_paned_set_shrink_end_child (rule_itself_vs_explore_edit_pane, FALSE); @@ -60,16 +60,41 @@ static void *widget_rule_itself_vs_explore_edit_pane() return GTK_WIDGET (rule_itself_vs_explore_edit_pane); } -void *widget_get_rules_page() +static void *static_widget_get_rules_pilot_box () { - GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - gtk_paned_set_start_child (H_tree_vs_selected, GTK_WIDGET (widget_get_rules_tree_and_pilot_box())); - gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (widget_rule_itself_vs_explore_edit_pane())); - gtk_paned_set_position (H_tree_vs_selected, 340); // WARNING : c'est une position "absolue" - gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE); - gtk_paned_set_shrink_start_child (H_tree_vs_selected, FALSE); - gtk_paned_set_shrink_end_child (H_tree_vs_selected, FALSE); + GtkBox *rules_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + GtkButton *btt_show_rules_use = GTK_BUTTON (gtk_button_new_with_label ("rules use")); +// gtk_button_set_icon_name (btt_show_rules_use, "any-symbolic"); +// g_signal_connect (btt_show_rules_use, "clicked", G_CALLBACK (on_show_rules_use), no_local_data); + GtkButton *btt_show_rules_comparator = GTK_BUTTON (gtk_button_new_with_label ("comparator")); + GtkButton *btt_expand_tree = GTK_BUTTON (gtk_button_new_with_label ("tree")); - return GTK_WIDGET (H_tree_vs_selected); + gtk_box_append (rules_pilot_box, GTK_WIDGET (btt_expand_tree)); + gtk_box_append (rules_pilot_box, GTK_WIDGET (btt_show_rules_use)); + gtk_box_append (rules_pilot_box, GTK_WIDGET (btt_show_rules_comparator)); + return rules_pilot_box; +} + +void *widget_get_rules_tree_and_pilot_box () +{ + GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (static_widget_get_rules_pilot_box ())); + // TODO non static génère une erreur : "référence indéfinie" <> a linkage pb ? see Makefile ? + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_tree ())); + return rules_tree_and_pilot_box; +} + +void *widget_get_rules_page() +{ + GtkPaned *tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); + gtk_paned_set_start_child (tree_vs_selected, GTK_WIDGET (widget_get_rules_tree_and_pilot_box())); + gtk_paned_set_end_child (tree_vs_selected, GTK_WIDGET (widget_rule_itself_vs_explore_edit_pane())); + gtk_paned_set_position (tree_vs_selected, 340); // WARNING : c'est une position "absolue" + gtk_paned_set_wide_handle (tree_vs_selected, TRUE); + gtk_paned_set_shrink_start_child (tree_vs_selected, FALSE); + gtk_paned_set_shrink_end_child (tree_vs_selected, FALSE); + + return GTK_WIDGET (tree_vs_selected); } diff --git a/src/widget/rules/pilot_box b/src/widget/rules/pilot_box new file mode 100644 index 0000000..9dad4af --- /dev/null +++ b/src/widget/rules/pilot_box @@ -0,0 +1,47 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Rules * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2021 Jean Sirmai * +* * +* 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 . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +#include "../../../include/fsm.h" +#include "../../../include/widget.h" +#include "../../../include/signal.h" + + +void *widget_get_rules_pilot_box () +{ + GtkBox *rules_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + GtkButton *btt_show_rules_use = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (btt_show_rules_use, "go-home-symbolic"); +// g_signal_connect (btt_show_rules_use, "clicked", G_CALLBACK (on_show_rules_use), no_local_data); + gtk_box_append (rules_pilot_box, GTK_BUTTON (btt_show_rules_use)); + +// gtk_box_append (rules_pilot_box, +// GTK_WIDGET (gtk_label_new ("\n - - - - - - - (some widgets here) - - - - - - - \n"))); + return rules_pilot_box; +} + diff --git a/src/widget/rules/select_one.c b/src/widget/rules/select_one.c index 3c8dae7..fd3724d 100644 --- a/src/widget/rules/select_one.c +++ b/src/widget/rules/select_one.c @@ -36,11 +36,8 @@ static void *get_under_rule_before() { GtkBox *under_rule_before_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); gtk_box_append (under_rule_before_box, - GTK_WIDGET (gtk_label_new ("\n\n - - - - - - - (some widgets here) - - - - - - - "))); - gtk_box_append (under_rule_before_box, - GTK_WIDGET (gtk_label_new ("\n\n| [ rule_before ] |"))); - gtk_box_append (under_rule_before_box, - GTK_WIDGET (gtk_label_new ("\n\n - - - - - - - (some other widgets there) - - - - - - - "))); + GTK_WIDGET (gtk_label_new ("\n | - - - - - - (some widgets here) - - - - - - - |\ + [ rule_before ] | - - - - - - - - (some other widgets there) - - - - - - - |"))); return GTK_WIDGET (under_rule_before_box); } @@ -49,11 +46,8 @@ static void *get_under_rule_after() { GtkBox *under_rule_after_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); gtk_box_append (under_rule_after_box, - GTK_WIDGET (gtk_label_new ("\n\n - - - - - - - (some widgets here) - - - - - - - "))); - gtk_box_append (under_rule_after_box, - GTK_WIDGET (gtk_label_new ("\n\n| [ rule_after ] |"))); - gtk_box_append (under_rule_after_box, - GTK_WIDGET (gtk_label_new ("\n\n - - - - - - - (some other widgets there) - - - - - - - "))); + GTK_WIDGET (gtk_label_new ("\n | - - - - - - - (some widgets here) - - - - - - - |\ + [ rule_after ] | - - - - - - - - (some other widgets there) - - - - - - - - |"))); return GTK_WIDGET (under_rule_after_box); } @@ -66,7 +60,7 @@ static void *get_rule_before() ("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png"))); gtk_box_append (rule_before, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); gtk_box_append (rule_before, GTK_WIDGET (get_under_rule_before())); - gtk_widget_set_size_request (GTK_WIDGET (rule_before), W_IMAGE_LOCAL / 2, H_IMAGE_LOCAL / 2); + gtk_widget_set_size_request (GTK_WIDGET (rule_before), W_IMAGE_LOCAL / 2, H_IMAGE_LOCAL / 1.46); return GTK_WIDGET (rule_before); } diff --git a/src/widget/rules/user_tree.c b/src/widget/rules/user_tree.c index 5bf8b51..ed04c0a 100644 --- a/src/widget/rules/user_tree.c +++ b/src/widget/rules/user_tree.c @@ -32,7 +32,31 @@ #include "../../../include/signal.h" -static void *widget_get_rules_tree () +static GtkScrollbar *rule_bar [n_rules]; +static GtkAdjustment *rule_adjust [n_rules]; + +static void *static_widget_get_rules_use () +{ + GtkBox *rules_use_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + for (int i = 0; i < n_rules; i++) + { + rule_adjust [i] = gtk_adjustment_new (exp(i), 0, 127, 1, 0, 0); + rule_bar [i] = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, + rule_adjust [i])); + char tooltip_text[8]; + sprintf(tooltip_text, "\n%d\n", i); + if (0 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (rule_bar [i]), "move rule xyz"); + if (1 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (rule_bar [i]), "transform this"); + if (2 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (rule_bar [i]), "transport that"); + if (3 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (rule_bar [i]), "any rule name"); + if (4 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (rule_bar [i]), tooltip_text); + + gtk_box_append (rules_use_box, GTK_WIDGET (rule_bar [i])); + } + return rules_use_box; +} + +void *widget_get_rules_tree () { GtkPaned *H_tree_vs_comparison = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); @@ -41,7 +65,8 @@ static void *widget_get_rules_tree () // GTK_SCROLLED_WINDOW gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_get_user_rules_tree())); gtk_paned_set_end_child (H_tree_vs_comparison, GTK_WIDGET - (get_an_impression_of_what_a_rules_comparator_could_be())); + (static_widget_get_rules_use ())); +// (get_an_impression_of_what_a_rules_comparator_could_be())); gtk_paned_set_position (H_tree_vs_comparison, 200); gtk_paned_set_wide_handle (H_tree_vs_comparison, TRUE); gtk_widget_set_size_request (GTK_WIDGET (H_tree_vs_comparison), W_IMAGE_LOCAL, H_IMAGE_LOCAL); @@ -51,19 +76,4 @@ static void *widget_get_rules_tree () return GTK_WIDGET (H_tree_vs_comparison); } -static void *widget_get_rules_pilot_box () -{ - GtkBox *rules_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (rules_pilot_box, - GTK_WIDGET (gtk_label_new ("\n - - - - - - - (some widgets here) - - - - - - - \n"))); - return rules_pilot_box; -} -void *widget_get_rules_tree_and_pilot_box () -{ - GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_pilot_box ())); - gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_tree ())); - return rules_tree_and_pilot_box; -}