zntg/ui/stretch.go

22 lines
687 B
Go
Raw Normal View History

package ui
func newStretch(c Control, w, h bool) *Spacing {
return BuildSpacing(c, func(s *Spacing) {
if w {
s.Width = Infinite()
}
if h {
s.Height = Infinite()
}
})
}
// Stretch wraps the supplied control to stretch in both directions.
func Stretch(c Control) Control { return newStretch(c, true, true) }
// StretchHeight wraps the supplied control to stretch vertically. Width is taken from wrapped control.
func StretchHeight(c Control) Control { return newStretch(c, false, true) }
// StretchWidth wraps the supplied control to stretch horizontally. Height is taken from wrapped control.
func StretchWidth(c Control) Control { return newStretch(c, true, false) }