From 15f02d4d0e16da1eb942e9936f69686ce0ab9177 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 11 Apr 2019 20:05:30 +0200 Subject: [PATCH] Infinite margins should not be taken into account for DesiredSize. --- ui/spacing.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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) {