Revert "label: Never measure more than max-width-chars"

This reverts commit ba44e7a228.

The change was meant to revert to old GTK3 behavior but it actually
broke new GTK4 behavior that is in use where max-width-chars is used to
determine an ideal size, but where we don't want to limit the width to
that size.

So what happens is the reintroduction of GTK3-style lots of whitepsace
bugs, and we really don't want those.

We also don't want to break backwards compat if we can avoid it.

So let's revert this.

The reftest that was made for this purpose has been adapted.

Fixes #4399
This commit is contained in:
Benjamin Otte 2021-11-04 13:28:45 +01:00
parent 8c63244855
commit 53acff167b
2 changed files with 2 additions and 17 deletions

View File

@ -1045,20 +1045,7 @@ get_height_for_width (GtkLabel *self,
PangoLayout *layout; PangoLayout *layout;
int text_height, baseline; int text_height, baseline;
width *= PANGO_SCALE; layout = gtk_label_get_measuring_layout (self, NULL, width * PANGO_SCALE);
if (self->max_width_chars > -1)
{
int char_pixels, width_chars;
layout = gtk_label_get_measuring_layout (self, NULL, -1);
char_pixels = get_char_pixels (GTK_WIDGET (self), layout);
if (self->width_chars > self->max_width_chars)
width_chars = self->width_chars;
else
width_chars = self->max_width_chars;
width = MIN (char_pixels * width_chars, width);
}
layout = gtk_label_get_measuring_layout (self, NULL, width);
pango_layout_get_pixel_size (layout, NULL, &text_height); pango_layout_get_pixel_size (layout, NULL, &text_height);

View File

@ -8,9 +8,7 @@
<property name="halign">start</property> <property name="halign">start</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">ABCDE <property name="label" translatable="yes">ABCDE ABCD</property>
ABCD</property>
<property name="max_width_chars">4</property>
<attributes> <attributes>
<attribute name="font-desc" value="Monospace"></attribute> <attribute name="font-desc" value="Monospace"></attribute>
</attributes> </attributes>