Fix pane allocation and size constraints

Correctly divide the fractions of *available* requested child-space.

This fixes issue with Trigger Page bottom attachment not showing
Frame content.

When calculating constraints the divider width/height was ignored.
When setting child allocation, the divider girth was only
subtracted *after* the first child, and iteratively subtracted
after each subsequent child widget.
This over-allocated the first child and later child widgets
were increasingly too small (factor * remaining).
This commit is contained in:
Robin Gareus 2025-10-11 21:04:45 +02:00
parent b1841f9857
commit 882ed91f2f
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -257,6 +257,7 @@ Pane::reallocate (Gtk::Allocation const & alloc)
} else { } else {
remaining = alloc.get_height (); remaining = alloc.get_height ();
} }
remaining = max<int> (0, remaining - (children.size() - 1) * divider_width);
Children::iterator child; Children::iterator child;
Children::iterator next; Children::iterator next;
@ -298,8 +299,6 @@ Pane::reallocate (Gtk::Allocation const & alloc)
fract = (*div)->fract; fract = (*div)->fract;
} }
Gtk::Requisition cr = (*child)->w->size_request ();
if (horizontal) { if (horizontal) {
child_alloc.set_width ((gint) floor (remaining * fract)); child_alloc.set_width ((gint) floor (remaining * fract));
child_alloc.set_height (alloc.get_height()); child_alloc.set_height (alloc.get_height());
@ -319,6 +318,7 @@ Pane::reallocate (Gtk::Allocation const & alloc)
child_alloc.set_height (max (child_alloc.get_height(), (*child)->minsize)); child_alloc.set_height (max (child_alloc.get_height(), (*child)->minsize));
} }
} else if (!check_fract && (*child)->w->get_visible ()) { } else if (!check_fract && (*child)->w->get_visible ()) {
Gtk::Requisition cr = (*child)->w->size_request ();
if (horizontal) { if (horizontal) {
child_alloc.set_width (max (child_alloc.get_width(), cr.width)); child_alloc.set_width (max (child_alloc.get_width(), cr.width));
} else { } else {
@ -347,12 +347,10 @@ Pane::reallocate (Gtk::Allocation const & alloc)
if (horizontal) { if (horizontal) {
divider_allocation.set_width (divider_width); divider_allocation.set_width (divider_width);
divider_allocation.set_height (alloc.get_height()); divider_allocation.set_height (alloc.get_height());
remaining = max (0, remaining - divider_width);
xpos += divider_width; xpos += divider_width;
} else { } else {
divider_allocation.set_width (alloc.get_width()); divider_allocation.set_width (alloc.get_width());
divider_allocation.set_height (divider_width); divider_allocation.set_height (divider_width);
remaining = max (0, remaining - divider_width);
ypos += divider_width; ypos += divider_width;
} }
@ -433,7 +431,8 @@ Pane::constrain_fract (Dividers::size_type div, float fract)
if (children.size () <= div + 1) { return fract; } // XXX remove once hidden divs are skipped if (children.size () <= div + 1) { return fract; } // XXX remove once hidden divs are skipped
assert(children.size () > div + 1); assert(children.size () > div + 1);
const float size = horizontal ? get_allocation().get_width() : get_allocation().get_height(); float size = horizontal ? get_allocation().get_width() : get_allocation().get_height();
size = max<float> (0, size - (children.size() - 1) * divider_width);
// TODO: optimize: cache in Pane::on_size_request // TODO: optimize: cache in Pane::on_size_request
Gtk::Requisition prev_req(children.at (div)->w->size_request ()); Gtk::Requisition prev_req(children.at (div)->w->size_request ());