From e11e60ac6944429a1ce9a3537167e91b6cb58942 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Tue, 30 Jul 2013 10:03:14 -0400 Subject: [PATCH] Bug 897404 - Port GTK2 to GTK3 - treeview rendering, expander fix. r=karlt --- widget/gtk2/gtk3drawing.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/widget/gtk2/gtk3drawing.c b/widget/gtk2/gtk3drawing.c index 324d3ba7f188..c3ef8e207fec 100644 --- a/widget/gtk2/gtk3drawing.c +++ b/widget/gtk2/gtk3drawing.c @@ -1570,6 +1570,8 @@ moz_gtk_tree_header_sort_arrow_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } +/* See gtk_expander_paint() for reference. + */ static gint moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, @@ -1577,6 +1579,7 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction) { GtkStyleContext *style; + GtkStateFlags state_flags; ensure_tree_view_widget(); gtk_widget_set_direction(gTreeViewWidget, direction); @@ -1584,12 +1587,25 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect, style = gtk_widget_get_style_context(gTreeViewWidget); gtk_style_context_save(style); gtk_style_context_add_class(style, GTK_STYLE_CLASS_EXPANDER); - /* Because the frame we get is of the entire treeview, we can't get the precise - * event state of one expander, thus rendering hover and active feedback useless. */ - gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state)); + + state_flags = GetStateFlagsFromGtkWidgetState(state); + + /* GTK_STATE_FLAG_ACTIVE controls expanded/colapsed state rendering + * in gtk_render_expander() + */ + if (expander_state == GTK_EXPANDER_EXPANDED) + state_flags |= GTK_STATE_FLAG_ACTIVE; + else + state_flags &= ~(GTK_STATE_FLAG_ACTIVE); + + gtk_style_context_set_state(style, state_flags); + gtk_render_expander(style, cr, - rect->x + rect->width / 2, rect->y + rect->height / 2, - rect->width, rect->height); + rect->x, + rect->y, + rect->width, + rect->height); + gtk_style_context_restore(style); return MOZ_GTK_SUCCESS; }