gui/views/view_grow.go

26 lines
535 B
Go
Raw Normal View History

2023-01-22 12:38:03 +01:00
package views
import (
"git.milar.in/milarin/gui"
)
// GrowView is a gui.Wrapper which always demands all available space in the given axes
type GrowView struct {
gui.WrapperTmpl
growH, growV bool
}
var _ gui.View = &GrowView{}
func NewGrowView(view gui.View, growH, growV bool) *GrowView {
g := &GrowView{growH: growH, growV: growV}
g.SetView(view)
return g
}
func (v *GrowView) Layout(ctx gui.AppContext) (prefWidth, prefHeight int) {
w, h := v.WrapperTmpl.Layout(ctx)
return iff(v.growH, -1, w), iff(v.growV, -1, h)
}