summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrenderertext.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-08-15 11:07:54 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-08-15 11:24:55 -0400
commit4453c4401f38e26a125b1f3d4bbf4bbeaa270d6d (patch)
treee865b5e104a3012236b9542765daa094be7d2ec2 /gtk/gtkcellrenderertext.c
parent87981c8894e2430f832871e1650eb4b6831d8352 (diff)
downloadgtk+-4453c4401f38e26a125b1f3d4bbf4bbeaa270d6d.tar.gz
Support alpha in text cell renderer colors
This is easily possible, now that Pango supports alpha.
Diffstat (limited to 'gtk/gtkcellrenderertext.c')
-rw-r--r--gtk/gtkcellrenderertext.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 18923e26a2..0f16d67fed 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1645,24 +1645,28 @@ get_layout (GtkCellRendererText *celltext,
&& (flags & GTK_CELL_RENDERER_SELECTED) == 0)
{
PangoColor color;
+ guint16 alpha;
- color.red = (guint16) (priv->foreground.red * 65535);
- color.green = (guint16) (priv->foreground.green * 65535);
- color.blue = (guint16) (priv->foreground.blue * 65535);
+ color.red = CLAMP (priv->foreground.red * 65535. + 0.5, 0, 65535);
+ color.green = CLAMP (priv->foreground.green * 65535. + 0.5, 0, 65535);
+ color.blue = CLAMP (priv->foreground.blue * 65535. + 0.5, 0, 65535);
+ alpha = CLAMP (priv->foreground.alpha * 65535. + 0.5, 0, 65535);
add_attr (attr_list,
pango_attr_foreground_new (color.red, color.green, color.blue));
+
+ add_attr (attr_list, pango_attr_foreground_alpha_new (alpha));
}
if (priv->strikethrough_set)
- add_attr (attr_list,
- pango_attr_strikethrough_new (priv->strikethrough));
+ add_attr (attr_list, pango_attr_strikethrough_new (priv->strikethrough));
}
else if (placeholder_layout)
{
PangoColor color;
+ guint16 alpha;
GtkStyleContext *context;
- GdkRGBA fg = { 0.5, 0.5, 0.5 };
+ GdkRGBA fg = { 0.5, 0.5, 0.5, 1.0 };
context = gtk_widget_get_style_context (widget);
gtk_style_context_lookup_color (context, "placeholder_text_color", &fg);
@@ -1670,9 +1674,12 @@ get_layout (GtkCellRendererText *celltext,
color.red = CLAMP (fg.red * 65535. + 0.5, 0, 65535);
color.green = CLAMP (fg.green * 65535. + 0.5, 0, 65535);
color.blue = CLAMP (fg.blue * 65535. + 0.5, 0, 65535);
+ alpha = CLAMP (fg.alpha * 65535. + 0.5, 0, 65535);
add_attr (attr_list,
pango_attr_foreground_new (color.red, color.green, color.blue));
+
+ add_attr (attr_list, pango_attr_foreground_alpha_new (alpha));
}
add_attr (attr_list, pango_attr_font_desc_new (priv->font));
@@ -1680,7 +1687,7 @@ get_layout (GtkCellRendererText *celltext,
if (priv->scale_set &&
priv->font_scale != 1.0)
add_attr (attr_list, pango_attr_scale_new (priv->font_scale));
-
+
if (priv->underline_set)
uline = priv->underline_style;
else
@@ -1688,7 +1695,7 @@ get_layout (GtkCellRendererText *celltext,
if (priv->language_set)
add_attr (attr_list, pango_attr_language_new (priv->language));
-
+
if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT)
{
switch (uline)