Infinite margins should not be taken into account for DesiredSize.

This commit is contained in:
Sander Schobers 2019-04-11 20:05:30 +02:00
parent 70d9e23b0c
commit 15f02d4d0e

View File

@ -84,9 +84,16 @@ func (s *Spacing) Center() {
func (s *Spacing) DesiredSize(ctx Context) geom.PointF32 { func (s *Spacing) DesiredSize(ctx Context) geom.PointF32 {
var size = s.Proxy.DesiredSize(ctx) var size = s.Proxy.DesiredSize(ctx)
var w, h = s.Width.Zero(size.X), s.Height.Zero(size.Y) 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( return geom.PtF32(
s.Margin.Left.Value()+w+s.Margin.Right.Value(), margin(s.Margin.Left)+w+margin(s.Margin.Right),
s.Margin.Top.Value()+h+s.Margin.Bottom.Value()) margin(s.Margin.Top)+h+margin(s.Margin.Bottom))
} }
func (s *Spacing) SetSize(w, h float32) { func (s *Spacing) SetSize(w, h float32) {