zntg/ui/stretch.go
Sander Schobers 3ea0d76efb Created unified spacing control.
Build control methods now accept nil as visitor method.
2019-03-12 21:11:43 +01:00

22 lines
687 B
Go

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) }