void set_background_color (GdkRGBA color) { gdouble brightness; if (game_area == NULL) return; /* While the two colours are labelled "light" and "dark" which one is * which actually depends on how light or dark the base colour is. */ brightness = color.red + color.green + color.blue; if (brightness > (1.0 / 1.1)) { /* Darken light colours. */ light_background.red = 0.9 * color.red; light_background.green = 0.9 * color.green; light_background.blue = 0.9 * color.blue; } else if (brightness > 0.04) { /* Lighten darker colours. */ light_background.red = 1.1 * color.red; light_background.green = 1.1 * color.green; light_background.blue = 1.1 * color.blue; } else { /* Very dark colours, add rather than multiply. */ light_background.red += 0.04; light_background.green += 0.04; light_background.blue += 0.04; } light_background.alpha = 1.0; dark_background = color; clear_game_area (); }
static void bg_color_callback (GtkWidget * widget, gpointer data) { gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &properties.bgcolour); set_background_color (properties.bgcolour); clear_game_area (); conf_set_background_color (&properties.bgcolour); }
static void bg_color_callback (GtkWidget * widget, gpointer data) { gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &properties.bgcolour); set_background_color (properties.bgcolour); clear_game_area (); conf_set_background_color (&properties.bgcolour); }
/** * pmap_selection * @widget: widget * @data: callback data * * Description: * handles pixmap selection messages **/ static void pmap_selection (GtkWidget * widget, gpointer data) { gint n; n = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); /* FIXME: Should be de-suffixed. */ properties.themename = games_file_list_get_nth (theme_list, n); conf_set_theme (properties.themename); set_game_graphics (properties.themename); clear_game_area (); }
void set_background_color (GdkColor color) { GdkColormap *colormap; guint32 brightness; GdkColor color2; if (game_area == NULL) return; if (dark_bggc == NULL) { dark_bggc = gdk_gc_new (game_area->window); gdk_gc_copy (dark_bggc, game_area->style->black_gc); light_bggc = gdk_gc_new (game_area->window); gdk_gc_copy (light_bggc, game_area->style->white_gc); } /* While the two colours are labelled "light" and "dark" which one is * which actually depends on how light or dark the base colour is. */ brightness = color.red + color.green + color.blue; if (brightness > 0xe8ba) { /* 0xe8ba = 0x10000/1.1 */ /* Darken light colours. */ color2.red = 0.9 * color.red; color2.green = 0.9 * color.green; color2.blue = 0.9 * color.blue; } else if (brightness > 0xa00) { /* Lighten darker colours. */ color2.red = 1.1 * color.red; color2.green = 1.1 * color.green; color2.blue = 1.1 * color.blue; } else { /* Very dark colours, add ratehr than multiply. */ color2.red += 0xa00; color2.green += 0xa00; color2.blue += 0xa00; } colormap = gtk_widget_get_colormap (game_area); gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE); gdk_gc_set_foreground (dark_bggc, &color); gdk_colormap_alloc_color (colormap, &color2, FALSE, TRUE); gdk_gc_set_foreground (light_bggc, &color2); clear_game_area (); }