26 lines
535 B
Go
26 lines
535 B
Go
|
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)
|
||
|
}
|