From f0c8d919336a29acf14c5c814b2b11ca0505eec7 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 29 Jul 2024 15:15:08 +0200 Subject: [PATCH] A pilot box to control the user rules tree, the rules use and the comparator (TODO) --- include/fsm.h | 2 +- src/widget/rules/select_one.c | 4 +-- src/widget/rules/user_tree.c | 49 ++++++++++++++++++++++------------- src/widget/tree.c | 2 ++ 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index b3bd3ba..800df8b 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -43,7 +43,7 @@ enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor -#define n_rules 64 // arbitrary +#define n_rules 128 // arbitrary #define n_objects 32 // arbitrary too, #define n_situations 128 // and so on... diff --git a/src/widget/rules/select_one.c b/src/widget/rules/select_one.c index fd3724d..ab52b4b 100644 --- a/src/widget/rules/select_one.c +++ b/src/widget/rules/select_one.c @@ -60,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 / 1.46); + gtk_widget_set_size_request (GTK_WIDGET (rule_before), W_IMAGE_LOCAL / 4, H_IMAGE_LOCAL / 3); return GTK_WIDGET (rule_before); } @@ -85,7 +85,7 @@ void *widget_get_selected_rule() { gtk_paned_set_shrink_start_child (before_vs_after, TRUE); gtk_paned_set_shrink_end_child (before_vs_after, TRUE); - gtk_paned_set_position (before_vs_after, 785); // WARNING : c'est une position "absolue" + gtk_paned_set_position (before_vs_after, 770); // WARNING : c'est une position "absolue" // gtk_widget_set_size_request (GTK_WIDGET (before_vs_after), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return GTK_WIDGET (before_vs_after); diff --git a/src/widget/rules/user_tree.c b/src/widget/rules/user_tree.c index ed04c0a..cd8ab4f 100644 --- a/src/widget/rules/user_tree.c +++ b/src/widget/rules/user_tree.c @@ -38,9 +38,18 @@ 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)); + GtkWidget *scroll_rules_use = gtk_scrolled_window_new (); +// gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_rules_use), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + +// GtkWidget *frame_rules_use = gtk_frame_new (" Rules use"); +// gtk_frame_set_child (GTK_FRAME (frame_rules_use), GTK_WIDGET (scroll_rules_use)); + gtk_widget_set_size_request (GTK_WIDGET (scroll_rules_use), W_IMAGE_LOCAL * 2, 0);//H_IMAGE_LOCAL); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_rules_use), GTK_WIDGET (rules_use_box)); + + for (int i = 0; i < n_rules; i++) { - rule_adjust [i] = gtk_adjustment_new (exp(i), 0, 127, 1, 0, 0); + rule_adjust [i] = gtk_adjustment_new (- rand() % 16 + n_rules - i, 0, 127, 1, 0, 0); rule_bar [i] = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, rule_adjust [i])); char tooltip_text[8]; @@ -53,27 +62,31 @@ static void *static_widget_get_rules_use () gtk_box_append (rules_use_box, GTK_WIDGET (rule_bar [i])); } - return rules_use_box; + return scroll_rules_use; +} + +static void *deprec_widget_get_rules_tree () +{ + GtkPaned *rules_tree_paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); + gtk_paned_set_start_child (rules_tree_paned, GTK_WIDGET (widget_get_user_rules_tree())); + gtk_paned_set_end_child (rules_tree_paned, GTK_WIDGET (static_widget_get_rules_use ())); +// (get_an_impression_of_what_a_rules_comparator_could_be())); + gtk_paned_set_position (rules_tree_paned, 200); + gtk_paned_set_wide_handle (rules_tree_paned, TRUE); + gtk_widget_set_size_request (GTK_WIDGET (rules_tree_paned), W_IMAGE_LOCAL, H_IMAGE_LOCAL); + gtk_paned_set_shrink_start_child (rules_tree_paned, FALSE); + gtk_paned_set_resize_end_child (rules_tree_paned, FALSE); + gtk_paned_set_shrink_end_child (rules_tree_paned, FALSE); + return GTK_WIDGET (rules_tree_paned); } void *widget_get_rules_tree () { - GtkPaned *H_tree_vs_comparison = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - - // GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre"); - // GtkWidget *comparaison_des_règles_sélectionnées = gtk_frame_new ("Sélection"); - // 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 - (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); - gtk_paned_set_shrink_start_child (H_tree_vs_comparison, FALSE); - gtk_paned_set_resize_end_child (H_tree_vs_comparison, FALSE); - gtk_paned_set_shrink_end_child (H_tree_vs_comparison, FALSE); - return GTK_WIDGET (H_tree_vs_comparison); + GtkBox *rules_tree_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_user_rules_tree())); + gtk_box_append (rules_tree_box, GTK_WIDGET (static_widget_get_rules_use ())); + gtk_box_append (rules_tree_box, GTK_WIDGET (get_an_impression_of_what_a_rules_comparator_could_be())); + return GTK_WIDGET (rules_tree_box); } diff --git a/src/widget/tree.c b/src/widget/tree.c index 0250a2c..dc02824 100644 --- a/src/widget/tree.c +++ b/src/widget/tree.c @@ -115,6 +115,8 @@ void *widget_get_user_rules_tree () gtk_widget_set_vexpand (GTK_WIDGET (scrolled_window), TRUE); gtk_widget_set_visible (GTK_WIDGET (scrolled_window), TRUE); gtk_widget_set_visible (GTK_WIDGET (list_view), TRUE); + + gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), W_IMAGE_LOCAL * 3, 0); return scrolled_window; }