Bug 897404 - Port GTK2 to GTK3 - treeview rendering, expander fix. r=karlt

This commit is contained in:
Martin Stransky 2013-07-30 10:03:14 -04:00
Родитель 66e243dd75
Коммит e11e60ac69
1 изменённых файлов: 21 добавлений и 5 удалений

Просмотреть файл

@ -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;
}