func (l *LinearLayout) DesiredSize(min, max math.Size) math.Size { if l.sizeMode.Fill() { return max } bounds := min.Rect() children := l.outer.Children() horizontal := l.direction.Orientation().Horizontal() offset := math.Point{X: 0, Y: 0} for _, c := range children { cs := c.Control.DesiredSize(math.ZeroSize, max) cm := c.Control.Margin() cb := cs.Expand(cm).Rect().Offset(offset) if horizontal { offset.X += cb.W() } else { offset.Y += cb.H() } bounds = bounds.Union(cb) } return bounds.Size().Expand(l.outer.Padding()).Clamp(min, max) }