diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-01-06 02:29:18 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-01-06 02:31:42 +0900 |
commit | 9a80100e9ab2430ecc4375ba6bd2f66784ce34a9 (patch) | |
tree | 710b6b54d92e905bfc838c64fdfc05c1eb0ead68 /gtk/gtkcellrenderertext.c | |
parent | e41fb7703ca810db1f391dc3237f0465a93f9140 (diff) | |
download | gtk+-9a80100e9ab2430ecc4375ba6bd2f66784ce34a9.tar.gz |
Fixed get_size() for GtkCellRendererText to clip to the input area
For ellipsize cells it's important to clip the result of get_size()
so that the returned required rectangle is indeed less than or equal
to the input rectangle... this is done so that GtkCellArea can accurately
paint focus on cells by calling gtk_cell_renderer_get_aligned_area().
Patch also adds assertions to gtk_cell_renderer_get_aligned_area() to
ensure this keeps working correctly.
Diffstat (limited to 'gtk/gtkcellrenderertext.c')
-rw-r--r-- | gtk/gtkcellrenderertext.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 5f2c2c2f96..a54b274559 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -1736,18 +1736,15 @@ get_size (GtkCellRenderer *cell, pango_layout_get_pixel_extents (layout, NULL, &rect); - if (height) - *height = ypad * 2 + rect.height; - - if (width) - *width = xpad * 2 + rect.x + rect.width; - if (cell_area) { gfloat xalign, yalign; gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); + rect.height = MIN (rect.height, cell_area->height - 2 * ypad); + rect.width = MIN (rect.width, cell_area->width - (2 * xpad) - rect.x); + if (x_offset) { if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) @@ -1770,6 +1767,12 @@ get_size (GtkCellRenderer *cell, if (y_offset) *y_offset = 0; } + if (height) + *height = ypad * 2 + rect.height; + + if (width) + *width = xpad * 2 + rect.x + rect.width; + g_object_unref (layout); } |