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 }