mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 09:00:34 +00:00
GtkCellRendererText: use PANGO_PIXELS_CEIL for text_width
Usually pango_layout_get_pixel_extents() is used, which uses PANGO_PIXELS_CEIL on the rectangle's width. This commit makes the new function gtk_cell_renderer_text_get_preferred_width() consistent with this. This fixes rounding errors on Mac OS X, where we were seeing tree views with a double height for a single line of text, while the usual single row height would have been sufficient.
This commit is contained in:
parent
31536736ea
commit
9ab2786991
@ -2157,19 +2157,19 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
|
|||||||
if ((priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) || priv->width_chars > 0)
|
if ((priv->ellipsize_set && priv->ellipsize != PANGO_ELLIPSIZE_NONE) || priv->width_chars > 0)
|
||||||
min_width =
|
min_width =
|
||||||
xpad * 2 +
|
xpad * 2 +
|
||||||
MIN (PANGO_PIXELS (text_width),
|
MIN (PANGO_PIXELS_CEIL (text_width),
|
||||||
(PANGO_PIXELS (char_width) * MAX (priv->width_chars, ellipsize_chars)));
|
(PANGO_PIXELS (char_width) * MAX (priv->width_chars, ellipsize_chars)));
|
||||||
/* If no width-chars set, minimum for wrapping text will be the wrap-width */
|
/* If no width-chars set, minimum for wrapping text will be the wrap-width */
|
||||||
else if (priv->wrap_width > -1)
|
else if (priv->wrap_width > -1)
|
||||||
min_width = xpad * 2 + rect.x + MIN (PANGO_PIXELS (text_width), priv->wrap_width);
|
min_width = xpad * 2 + rect.x + MIN (PANGO_PIXELS_CEIL (text_width), priv->wrap_width);
|
||||||
else
|
else
|
||||||
min_width = xpad * 2 + rect.x + PANGO_PIXELS (text_width);
|
min_width = xpad * 2 + rect.x + PANGO_PIXELS_CEIL (text_width);
|
||||||
|
|
||||||
if (priv->width_chars > 0)
|
if (priv->width_chars > 0)
|
||||||
nat_width = xpad * 2 +
|
nat_width = xpad * 2 +
|
||||||
MAX ((PANGO_PIXELS (char_width) * priv->width_chars), PANGO_PIXELS (text_width));
|
MAX ((PANGO_PIXELS (char_width) * priv->width_chars), PANGO_PIXELS_CEIL (text_width));
|
||||||
else
|
else
|
||||||
nat_width = xpad * 2 + PANGO_PIXELS (text_width);
|
nat_width = xpad * 2 + PANGO_PIXELS_CEIL (text_width);
|
||||||
|
|
||||||
|
|
||||||
nat_width = MAX (nat_width, min_width);
|
nat_width = MAX (nat_width, min_width);
|
||||||
|
Loading…
Reference in New Issue
Block a user