ConstraintView fixed with negative sizes

This commit is contained in:
Timon Ringwald 2022-05-04 11:25:43 +02:00
parent e9f5b6687e
commit 768702af0b

View File

@ -25,6 +25,12 @@ func (v *ConstrainView) Constrain(maxWidth, maxHeight int) {
} }
func (v *ConstrainView) Layout() (prefWidth, prefHeight int) { func (v *ConstrainView) Layout() (prefWidth, prefHeight int) {
if v.View() == nil {
return v.MaxWidth, v.MaxHeight
}
vw, vh := v.View().Layout() 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
} }