[epiphany] gd-two-lines-renderer: use Pango alpha attribute
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] gd-two-lines-renderer: use Pango alpha attribute
- Date: Sat, 1 Jul 2017 23:45:57 +0000 (UTC)
commit e1bf1d4ecf4352e1f045e2cf88df9266ffc8305c
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 1 14:57:27 2017 -0700
gd-two-lines-renderer: use Pango alpha attribute
This code was previously trying to alter the color of the second
line by manipulating the foreground color. As Epiphany requires
GTK+ 3.22, we can rely on the Pango alpha attr working correctly
and therefore do not need this fallback.
The problem with the code previously is that it would not
respect the GTK_CELL_RENDERER_SELECTED state. It would draw the
altered non-selected state with a dim-level on top of a
selected row.
By simply avoiding the foreground color altogether (and
inheriting it from the PangoLayout state when rendering), we
get the appropriate color and also blend into the selected row
state properly.
https://bugzilla.gnome.org/show_bug.cgi?id=784431
lib/widgets/contrib/gd-two-lines-renderer.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
---
diff --git a/lib/widgets/contrib/gd-two-lines-renderer.c b/lib/widgets/contrib/gd-two-lines-renderer.c
index 9840527..5a029f7 100644
--- a/lib/widgets/contrib/gd-two-lines-renderer.c
+++ b/lib/widgets/contrib/gd-two-lines-renderer.c
@@ -87,15 +87,13 @@ apply_subtitle_style_to_layout (GtkStyleContext *context,
GtkStateFlags flags)
{
PangoFontDescription *desc;
- GdkRGBA rgba = {0.0, 0.0, 0.0, 0.0};
PangoAttrList *layout_attr;
- PangoAttribute *attr_color;
+ PangoAttribute *attr_alpha;
gtk_style_context_save (context);
gtk_style_context_set_state (context, flags);
gtk_style_context_get (context, gtk_style_context_get_state (context),
"font", &desc,
- "color", &rgba,
NULL);
gtk_style_context_restore (context);
@@ -104,16 +102,11 @@ apply_subtitle_style_to_layout (GtkStyleContext *context,
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
- /* Set the color */
- rgba.red = CLAMP(1.0 - ((1.0 - rgba.red) * SUBTITLE_DIM_PERCENTAGE), 0.0, 1.0);
- rgba.green = CLAMP(1.0 - ((1.0 - rgba.green) * SUBTITLE_DIM_PERCENTAGE), 0.0, 1.0);
- rgba.blue = CLAMP(1.0 - ((1.0 - rgba.blue) * SUBTITLE_DIM_PERCENTAGE), 0.0, 1.0);
-
+ /* Set the font alpha */
layout_attr = pango_attr_list_new ();
- attr_color = pango_attr_foreground_new (rgba.red * 65535,
- rgba.green * 65535,
- rgba.blue * 65535);
- pango_attr_list_insert (layout_attr, attr_color);
+ attr_alpha = pango_attr_foreground_alpha_new (SUBTITLE_DIM_PERCENTAGE * 65535);
+ pango_attr_list_insert (layout_attr, attr_alpha);
+
pango_layout_set_attributes (layout, layout_attr);
pango_attr_list_unref (layout_attr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]