mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
GtkTextDisplay: Use pango renderer alpha support
We don't need to store our own copy of the colors anymore, now that PangoRenderer can do alpha.
This commit is contained in:
parent
0de600c9dd
commit
e02acc7d71
@ -107,13 +107,10 @@ struct _GtkTextRenderer
|
|||||||
|
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
GdkRGBA *error_color; /* Error underline color for this widget */
|
GdkRGBA *error_color; /* Error underline color for this widget */
|
||||||
GList *widgets; /* widgets encountered when drawing */
|
GList *widgets; /* widgets encountered when drawing */
|
||||||
|
|
||||||
GdkRGBA rgba[4];
|
|
||||||
guint8 rgba_set[4];
|
|
||||||
|
|
||||||
guint state : 2;
|
guint state : 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -132,17 +129,23 @@ text_renderer_set_rgba (GtkTextRenderer *text_renderer,
|
|||||||
const GdkRGBA *rgba)
|
const GdkRGBA *rgba)
|
||||||
{
|
{
|
||||||
PangoRenderer *renderer = PANGO_RENDERER (text_renderer);
|
PangoRenderer *renderer = PANGO_RENDERER (text_renderer);
|
||||||
PangoColor dummy = { 0, };
|
PangoColor color = { 0, };
|
||||||
|
guint16 alpha;
|
||||||
|
|
||||||
if (rgba)
|
if (rgba)
|
||||||
{
|
{
|
||||||
text_renderer->rgba[part] = *rgba;
|
color.red = (guint16)(rgba->red * 65535);
|
||||||
pango_renderer_set_color (renderer, part, &dummy);
|
color.green = (guint16)(rgba->green * 65535);
|
||||||
|
color.blue = (guint16)(rgba->blue * 65535);
|
||||||
|
alpha = (guint16)(rgba->alpha * 65535);
|
||||||
|
pango_renderer_set_color (renderer, part, &color);
|
||||||
|
pango_renderer_set_alpha (renderer, part, alpha);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pango_renderer_set_color (renderer, part, NULL);
|
{
|
||||||
|
pango_renderer_set_color (renderer, part, NULL);
|
||||||
text_renderer->rgba_set[part] = (rgba != NULL);
|
pango_renderer_set_alpha (renderer, part, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkTextAppearance *
|
static GtkTextAppearance *
|
||||||
@ -267,10 +270,22 @@ static void
|
|||||||
set_color (GtkTextRenderer *text_renderer,
|
set_color (GtkTextRenderer *text_renderer,
|
||||||
PangoRenderPart part)
|
PangoRenderPart part)
|
||||||
{
|
{
|
||||||
|
PangoColor *color;
|
||||||
|
GdkRGBA rgba;
|
||||||
|
guint16 alpha;
|
||||||
|
|
||||||
cairo_save (text_renderer->cr);
|
cairo_save (text_renderer->cr);
|
||||||
|
|
||||||
if (text_renderer->rgba_set[part])
|
color = pango_renderer_get_color (PANGO_RENDERER (text_renderer), part);
|
||||||
gdk_cairo_set_source_rgba (text_renderer->cr, &text_renderer->rgba[part]);
|
alpha = pango_renderer_get_alpha (PANGO_RENDERER (text_renderer), part);
|
||||||
|
if (color)
|
||||||
|
{
|
||||||
|
rgba.red = color->red / 65535.;
|
||||||
|
rgba.green = color->green / 65535.;
|
||||||
|
rgba.blue = color->blue / 65535.;
|
||||||
|
rgba.alpha = alpha / 65535.;
|
||||||
|
gdk_cairo_set_source_rgba (text_renderer->cr, &rgba);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user