From c495a0f10d252a1c5b0b4e7c9c19d44c41ac9b9b Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:37:43 +0100 Subject: [PATCH] Apply size=minSize to some container children This works around children with no h-grow not updating their parents' size. The if is required because minSize does not always properly populate now. --- src/uilib/simplecontainer.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/uilib/simplecontainer.h b/src/uilib/simplecontainer.h index b585059e..648c4730 100644 --- a/src/uilib/simplecontainer.h +++ b/src/uilib/simplecontainer.h @@ -18,8 +18,14 @@ class SimpleContainer : public Container { Container::setSize(size); for (auto child : _children) { Size childSize = child->getSize(); - if (child->getHGrow()) childSize.width = _size.width-child->getLeft(); - if (child->getVGrow()) childSize.height = _size.height-child->getTop(); + if (child->getHGrow()) + childSize.width = _size.width-child->getLeft(); + else if (childSize.width < child->getMinWidth()) // FIXME: this also be done for HGrow + childSize.width = child->getMinWidth(); + if (child->getVGrow()) + childSize.height = _size.height-child->getTop(); + else if (childSize.height < child->getMinWidth()) // FIXME: this also be done for VGrow + childSize.height = child->getMinWidth(); child->setSize(childSize); break; // only the first child for now; TODO: only container-sized widgets? }