[gtk/1464-tree-view-expander-arrows-no-longer-positioned-vertically-centered-correctly] treeview: Prevent fuzzy centered expander arrows



commit 90a006b3621575d770941a7da09826a87c604ee2
Author: António Fernandes <antoniof gnome org>
Date:   Thu Feb 13 19:30:38 2020 +0000

    treeview: Prevent fuzzy centered expander arrows
    
    We want expander arrows to be vertically centered in their row, so we
    pass the cell area's height to the renderer.
    
    However, if the cell area's height is an odd number while the
    "expander-size" style property is an even number, or vice versa, the
    arrow will be centered in a half pixel, and fuzzily rendered.
    
    So, round the render height to the same parity as the expander-size.
    
    (This is not necessary for the arrow width because it's assumed equal
    to the "expander-size" style-property.)

 gtk/gtktreeview.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c81d26359f..20f09ef48d 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -10367,6 +10367,17 @@ gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
   gtk_style_context_set_state (context, state);
   gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
 
+  /* Make sure area.height has the same parity as the "expander-size" style
+   * property (which area.width is assumed to be exactly equal to). This is done
+   * to avoid the arrow being vertically centered in a half-pixel, which would
+   * result in a fuzzy rendering.
+   */
+  if (area.height % 2 != area.width % 2)
+    {
+      area.y += 1;
+      area.height -= 1;
+    }
+
   gtk_render_expander (context, cr,
                        area.x, area.y,
                        area.width, area.height);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]