summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2021-11-06 00:56:11 +0100
committerBenjamin Otte <otte@redhat.com>2021-11-06 00:56:55 +0100
commit4ffa60be50f1ba5e8f78039cb0f5ea41b414864a (patch)
tree3d512effc5efa4248e8d941a71f9791d774028ee
parentc4e5242be0664a5e94a40657c5644cdeadc0097e (diff)
downloadgtk+-4ffa60be50f1ba5e8f78039cb0f5ea41b414864a.tar.gz
boxlayout: Be more careful with what to consider natural size
Don't just use the natural size as the max size, the natural size is the ideal size, not necessarily the maximum size. Also check the nat size for opposite min size.
-rw-r--r--gtk/gtkboxlayout.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 99feca37e5..20b462eb40 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -327,6 +327,8 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
child != NULL;
child = _gtk_widget_get_next_sibling (child))
{
+ int min_opposite, nat_for_min;
+
if (!gtk_widget_should_layout (child))
continue;
@@ -335,6 +337,22 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
-1,
&sizes[i].minimum_size, &sizes[i].natural_size,
NULL, NULL);
+ /* Don't just use the natural size as the max size,
+ * the natural size is the ideal size, not necessarily
+ * the maximum size.
+ * Also check the nat size for opposite min size.
+ */
+ gtk_widget_measure (child,
+ OPPOSITE_ORIENTATION (self->orientation),
+ -1,
+ &min_opposite, NULL,
+ NULL, NULL);
+ gtk_widget_measure (child,
+ self->orientation,
+ min_opposite,
+ NULL, &nat_for_min,
+ NULL, NULL);
+ sizes[i].natural_size = MAX (sizes[i].natural_size, nat_for_min);
children_minimum_size += sizes[i].minimum_size;
i += 1;