diff --git a/ui/spacing.go b/ui/spacing.go index 93ec626..ddd198e 100644 --- a/ui/spacing.go +++ b/ui/spacing.go @@ -84,9 +84,16 @@ func (s *Spacing) Center() { func (s *Spacing) DesiredSize(ctx Context) geom.PointF32 { var size = s.Proxy.DesiredSize(ctx) var w, h = s.Width.Zero(size.X), s.Height.Zero(size.Y) + var margin = func(l *Length) float32 { + var v = l.Value() + if geom.IsNaN32(v) { + return 0 + } + return v + } return geom.PtF32( - s.Margin.Left.Value()+w+s.Margin.Right.Value(), - s.Margin.Top.Value()+h+s.Margin.Bottom.Value()) + margin(s.Margin.Left)+w+margin(s.Margin.Right), + margin(s.Margin.Top)+h+margin(s.Margin.Bottom)) } func (s *Spacing) SetSize(w, h float32) {