13
0

canvas: don't call ::size_allocate() for children unless there is just one child and it is "layout sensitive

the dumb/Item version of ::size_allocate_children() doesn't do anything but give its full allocation to children, and if there
was more than one child, this could not be done in a "dumb" way. Likewise, if the sole child is not layout sensitive, it
doesn't care about size allocation
This commit is contained in:
Paul Davis 2021-08-04 18:59:20 -06:00
parent b416caf1bb
commit 0296b0b0cb

View File

@ -625,19 +625,13 @@ Item::_size_allocate (Rect const & r)
void
Item::size_allocate_children (Rect const & r)
{
bool have_constraint_container = false;
/* this does nothing by default. Containers like Box or
* ConstraintPacker can override it to do "smart" layout based on this
* Item's allocation.
*/
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
(*i)->size_allocate (r);
if (dynamic_cast<ConstraintPacker*> (*i)) {
have_constraint_container = true;
}
}
if (have_constraint_container) {
_bounding_box_dirty = true;
if (_items.size() == 1 && _items.front()->layout_sensitive()) {
_items.front()->size_allocate (r);
}
}