2019-03-05 20:52:18 +00:00
|
|
|
package ui
|
|
|
|
|
2019-03-12 20:11:43 +00:00
|
|
|
func newStretch(c Control, w, h bool) *Spacing {
|
|
|
|
return BuildSpacing(c, func(s *Spacing) {
|
|
|
|
if w {
|
|
|
|
s.Width = Infinite()
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
2019-03-12 20:11:43 +00:00
|
|
|
if h {
|
|
|
|
s.Height = Infinite()
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
2019-03-12 20:11:43 +00:00
|
|
|
})
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) }
|