Calculate child preferred size based on max size

If panel component child exceeds the preferred size, correctly send this
new max size to other children, so they can resize/reposition themselves
correctly.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-05-12 23:37:59 +02:00
parent 0829ea607b
commit 9a98671f83

View File

@@ -100,6 +100,22 @@ public class PanelComponent implements LayoutableRenderableEntity
preferredSize.width - border.x - border.width,
preferredSize.height - border.y - border.height);
// Adjust preferred size of children based on orientation and children
// sizes exceeding the parent size
switch (orientation)
{
case VERTICAL:
childPreferredSize.setSize(
Math.max(childDimensions.width, childPreferredSize.width),
childPreferredSize.height);
break;
case HORIZONTAL:
childPreferredSize.setSize(
childPreferredSize.width,
Math.max(childDimensions.height, childPreferredSize.height));
break;
}
// Render all children
for (final LayoutableRenderableEntity child : children)
{