From b0a13d1a3c53d6c3101af4cb22d30413d55a05da Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 12 Dec 2020 14:41:44 +0100 Subject: [PATCH] ContainerBase now provides a DesiredSize (maximum of all children, if any). --- ui/containerbase.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/containerbase.go b/ui/containerbase.go index d528e2d..534a4b8 100644 --- a/ui/containerbase.go +++ b/ui/containerbase.go @@ -26,6 +26,15 @@ func (c *ContainerBase) Arrange(ctx Context, bounds geom.RectangleF32, offset ge c.ControlBase.Arrange(ctx, bounds, offset, parent) } +func (c *ContainerBase) DesiredSize(ctx Context, size geom.PointF32) geom.PointF32 { + var max geom.PointF32 + for _, child := range c.Children { + s := child.DesiredSize(ctx, size) + max = geom.MaxPtF32(max, s) + } + return max +} + func (c *ContainerBase) Handle(ctx Context, e Event) bool { if c.ControlBase.Handle(ctx, e) { return true