O B J E C T S T R A N S P A R E N C I E S << a first functionnal prototype

This commit is contained in:
Jean Sirmai 2024-07-26 12:26:24 +02:00
parent 4a271bc2d5
commit d8f8d39028
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 37 additions and 53 deletions

View File

@ -32,5 +32,5 @@
#pragma once #pragma once
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
void pref_set_store_restore_reset (int choice, int value, GtkScrollbar *scrollbar); void pref_set_store_restore_reset (int choice, int value);
int *pref_get_all_objects_transparencies();

View File

@ -74,9 +74,8 @@ void *widget_get_sequence_control(); // bottom
// called in : src/widget/state/top.c // called in : src/widget/state/top.c
void widget_reset_all_situations_transparencies_to_value (int value); // top void widget_reset_all_situations_transparencies_to_value (int value); // top
void widget_reset_objects_transparency_to_values (int *value); // top void widget_set_object_transparency_to_value (int rank, int value); // top
void *widget_get_objects_transparencies(); // top int widget_get_object_transparency (int i); // top
/******************************************************************************/ /******************************************************************************/
/* S T O C K */ /* S T O C K */

View File

@ -34,56 +34,39 @@
#include "../include/widget.h" #include "../include/widget.h"
struct preferences { struct preferences { int transparency [n_objects]; }; // may become a long, long list...
int transparency [n_objects]; // may become a long, long list... struct preferences *pref_jean = NULL; // TODO (voir graphics_init(...))
}; // pour remplacer p[i] par : pref_jean->transparency [i]
// en attendant:
static int p[n_objects] = {};
static int choice_STORE_RESTORE_RESET = STORE; static int choice_STORE_RESTORE_RESET = STORE;
static int p [n_objects];
void pref_set_all_objects_transparencies (int *q)
{
for (int i = 0; i < n_objects; i++) p [i] = q [i];
}
int *pref_get_all_objects_transparencies () { return p; }
static void print_p (int *abc) {
for (int i = 0; i < n_objects; i++) printf("%3d ", abc [i]); printf("\n");}
void pref_set_store_restore_reset (int choice, int value) void pref_set_store_restore_reset (int choice, int value)
{ {
choice_STORE_RESTORE_RESET = choice; choice_STORE_RESTORE_RESET = choice;
int ppp [n_objects];
switch (choice) { switch (choice) {
case (STORE) : printf("STORE current values in MEM [%d]\n", n_objects); case (STORE) :
// GtkScrollbar *reset_scrollbar = printf("STORE (value = %d)\n", value);
// GTK_SCROLLBAR (widget_get_objects_transparencies ()); for (int i = 0; i < n_objects; i++) {
for (int i = 0; i < n_objects; i++) ppp [i] = i * 4; p [i] = widget_get_object_transparency (i);
// widget_get_object_transparency_scrollbar (i); widget_set_object_transparency_to_value (i, p [i]);
pref_set_all_objects_transparencies (ppp); // print_p (ppp); }
widget_reset_objects_transparency_to_values (ppp);
fsm_set_preferences_state (TRUE);
break; break;
case (RESTORE) : printf("RESTORE values from MEM [%d]\n", n_objects); case (RESTORE) :
for (int i = 0; i < n_objects; i++) ppp [i] = i * 4; printf("RESTORE (value = %d)\n", value);
pref_set_all_objects_transparencies (ppp); // print_p (ppp); for (int i = 0; i < n_objects; i++)
widget_reset_objects_transparency_to_values (ppp); widget_set_object_transparency_to_value (i, p [i]);
fsm_set_preferences_state (TRUE);
break; break;
case (RESET) : printf("RESET \n"); case (RESET) :
for (int i = 0; i < n_objects; i++) ppp [i] = rand() % 127; printf("RESET (value = %d)\n", value);
pref_set_all_objects_transparencies (ppp); // print_p (ppp); for (int i = 0; i < n_objects; i++)
widget_reset_objects_transparency_to_values (ppp); widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127
fsm_set_preferences_state (TRUE);
break; break;
default : printf("default in signal.switch_store_restore_reset()\n"); default : printf("default in signal.switch_store_restore_reset()\n");
} }
fsm_set_preferences_state (TRUE);
} }

View File

@ -328,9 +328,9 @@ void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *sc
const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source));
int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar)); int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar));
if ( ! strcmp (btt_name, "view-restore-symbolic")) pref_set_store_restore_reset (STORE, value, scrollbar); if ( ! strcmp (btt_name, "document-revert-rtl-symbolic")) pref_set_store_restore_reset (STORE, value);
if ( ! strcmp (btt_name, "view-fullscreen-symbolic")) pref_set_store_restore_reset (RESTORE, value, scrollbar); if ( ! strcmp (btt_name, "edit-undo-symbolic")) pref_set_store_restore_reset (RESTORE, value);
if ( ! strcmp (btt_name, "view-refresh-symbolic")) pref_set_store_restore_reset (RESET, value, scrollbar); if ( ! strcmp (btt_name, "view-refresh-symbolic")) pref_set_store_restore_reset (RESET, value);
fsm_set_preferences_state (TRUE); // << à détailler TODO fsm_set_preferences_state (TRUE); // << à détailler TODO
} }

View File

@ -40,12 +40,14 @@
static GtkScrollbar *object_bar [n_objects]; static GtkScrollbar *object_bar [n_objects];
static GtkAdjustment *object_adjust [n_objects]; static GtkAdjustment *object_adjust [n_objects];
void *widget_get_objects_transparencies () {return object_bar;} int widget_get_object_transparency (int rank)
void widget_reset_objects_transparency_to_values (int *value)
{ {
for (int i = 0; i < n_objects; i++) return gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (object_bar [rank]));
gtk_adjustment_set_value (object_adjust [i], value [i]); }
void widget_set_object_transparency_to_value (int rank, int value)
{
gtk_adjustment_set_value (object_adjust [rank], value);
} }
static void *get_objects_box() static void *get_objects_box()
@ -69,7 +71,7 @@ static void *get_objects_box()
sprintf(tooltip_text_for_btt_store, btt_store_tip); sprintf(tooltip_text_for_btt_store, btt_store_tip);
gtk_widget_set_tooltip_text (GTK_WIDGET (btt_store), btt_store_tip); gtk_widget_set_tooltip_text (GTK_WIDGET (btt_store), btt_store_tip);
gtk_button_set_icon_name (GTK_BUTTON (btt_store), "view-restore-symbolic"); gtk_button_set_icon_name (GTK_BUTTON (btt_store), "document-revert-rtl-symbolic");
// gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_store), group_transparencies); // gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_store), group_transparencies);
g_signal_connect (btt_store, "toggled", g_signal_connect (btt_store, "toggled",
G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar); G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);
@ -80,7 +82,7 @@ static void *get_objects_box()
char tooltip_text_for_btt_restore [140]; char tooltip_text_for_btt_restore [140];
sprintf(tooltip_text_for_btt_restore, btt_restore_tip); sprintf(tooltip_text_for_btt_restore, btt_restore_tip);
gtk_widget_set_tooltip_text (GTK_WIDGET (btt_restore), btt_restore_tip); gtk_widget_set_tooltip_text (GTK_WIDGET (btt_restore), btt_restore_tip);
gtk_button_set_icon_name (GTK_BUTTON (btt_restore), "view-fullscreen-symbolic"); gtk_button_set_icon_name (GTK_BUTTON (btt_restore), "edit-undo-symbolic");//send to symbolic
// gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_restore), group_transparencies); // gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_restore), group_transparencies);
g_signal_connect (btt_restore, "toggled", g_signal_connect (btt_restore, "toggled",
G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar); G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);