forked from AuroraMiddleware/gtk
Show alpha in the palette as well
This commit is contained in:
parent
9161119329
commit
8d1565df94
@ -88,6 +88,27 @@ swatch_finalize (GObject *object)
|
||||
|
||||
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
|
||||
|
||||
static cairo_pattern_t *
|
||||
get_checkered_pattern (void)
|
||||
{
|
||||
/* need to respect pixman's stride being a multiple of 4 */
|
||||
static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00 };
|
||||
static cairo_surface_t *checkered = NULL;
|
||||
cairo_pattern_t *pattern;
|
||||
|
||||
if (checkered == NULL)
|
||||
checkered = cairo_image_surface_create_for_data (data,
|
||||
CAIRO_FORMAT_A8,
|
||||
2, 2, 4);
|
||||
|
||||
pattern = cairo_pattern_create_for_surface (checkered);
|
||||
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
|
||||
cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
swatch_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
@ -118,6 +139,21 @@ swatch_draw (GtkWidget *widget,
|
||||
|
||||
if (swatch->priv->has_color)
|
||||
{
|
||||
cairo_pattern_t *pattern;
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
cairo_set_source_rgb (cr, 0.33, 0.33, 0.33);
|
||||
cairo_fill_preserve (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.66, 0.66, 0.66);
|
||||
|
||||
pattern = get_checkered_pattern ();
|
||||
cairo_matrix_init_scale (&matrix, 0.125, 0.125);
|
||||
cairo_pattern_set_matrix (pattern, &matrix);
|
||||
cairo_clip_preserve (cr);
|
||||
cairo_mask (cr, pattern);
|
||||
cairo_pattern_destroy (pattern);
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &swatch->priv->color);
|
||||
cairo_fill_preserve (cr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user