Clip to cell_area when rendering cell content

This fixes a GTK+ 3.0 regression.  In GTK+ 2, the render method
on GtkCellRenderer had a expose_area parameter, typically set to
cell_area.  This parameter was used for clipping cell content to be
rendered to the cell area (and thus clipping to within the focus
rectangle).  During the rendering clean up this parameter was removed
and no clipping put back into place.

Since expose_area was usually equal to cell_area anyway, it does not make
sense to reintroduce the expose_area parameter.  Instead, we do clipping at
two levels:
 - in gtk_cell_renderer_render() we clip to background_area.  We cannot
clip to cell_area here because we want to allow cell renderers to
render in the background area (e.g. background color/effect).
 - cell renderers should clip to clip_area when rendering cell
content individually (as they had to individually clip to expose_region
before).
This commit is contained in:
Kristian Rietveld 2010-12-16 00:07:08 +01:00
parent c8d130efa7
commit a28c11a27f
4 changed files with 24 additions and 0 deletions

View File

@ -698,6 +698,9 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
cairo_fill (cr);
}
gdk_cairo_rectangle (cr, background_area);
cairo_clip (cr);
GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
cr,
widget,

View File

@ -372,6 +372,11 @@ gtk_cell_renderer_spinner_render (GtkCellRenderer *cellr,
state = GTK_STATE_PRELIGHT;
}
cairo_save (cr);
gdk_cairo_rectangle (cr, cell_area);
cairo_clip (cr);
gtk_paint_spinner (gtk_widget_get_style (widget),
cr,
state,
@ -380,4 +385,6 @@ gtk_cell_renderer_spinner_render (GtkCellRenderer *cellr,
priv->pulse,
draw_rect.x, draw_rect.y,
draw_rect.width, draw_rect.height);
cairo_restore (cr);
}

View File

@ -1833,6 +1833,11 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
else if (priv->wrap_width == -1)
pango_layout_set_width (layout, -1);
cairo_save (cr);
gdk_cairo_rectangle (cr, cell_area);
cairo_clip (cr);
gtk_paint_layout (gtk_widget_get_style (widget),
cr,
state,
@ -1843,6 +1848,8 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
cell_area->y + y_offset + ypad,
layout);
cairo_restore (cr);
g_object_unref (layout);
}

View File

@ -372,6 +372,11 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
state = GTK_STATE_INSENSITIVE;
}
cairo_save (cr);
gdk_cairo_rectangle (cr, cell_area);
cairo_clip (cr);
if (priv->radio)
{
gtk_paint_option (gtk_widget_get_style (widget),
@ -392,6 +397,8 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
cell_area->y + y_offset + ypad,
width, height);
}
cairo_restore (cr);
}
static gint