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) {
vw, vh := v.View().Layout() if v.View() == nil {
return min(vw, v.MaxWidth), min(vh, v.MaxHeight) return v.MaxWidth, v.MaxHeight
}
vw, vh := v.View().Layout()
prefWidth = iff(vw >= 0, min(vw, v.MaxWidth), v.MaxWidth)
prefHeight = iff(vh >= 0, min(vh, v.MaxHeight), v.MaxHeight)
return
} }