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:
@@ -100,6 +100,22 @@ public class PanelComponent implements LayoutableRenderableEntity
|
|||||||
preferredSize.width - border.x - border.width,
|
preferredSize.width - border.x - border.width,
|
||||||
preferredSize.height - border.y - border.height);
|
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
|
// Render all children
|
||||||
for (final LayoutableRenderableEntity child : children)
|
for (final LayoutableRenderableEntity child : children)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user