From 768702af0b15186f8a9fbbc358b1170c56663170 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Wed, 4 May 2022 11:25:43 +0200 Subject: [PATCH] ConstraintView fixed with negative sizes --- views/view_constrain.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/views/view_constrain.go b/views/view_constrain.go index a647869..40d3125 100644 --- a/views/view_constrain.go +++ b/views/view_constrain.go @@ -25,6 +25,12 @@ func (v *ConstrainView) Constrain(maxWidth, maxHeight int) { } func (v *ConstrainView) Layout() (prefWidth, prefHeight int) { + if v.View() == nil { + return v.MaxWidth, v.MaxHeight + } + vw, vh := v.View().Layout() - return min(vw, v.MaxWidth), min(vh, v.MaxHeight) + prefWidth = iff(vw >= 0, min(vw, v.MaxWidth), v.MaxWidth) + prefHeight = iff(vh >= 0, min(vh, v.MaxHeight), v.MaxHeight) + return }