dive/runtime/ui/components/visible_primitive.go
dwillist ae89e3dc2c create constructors package, move viewmodel initialization into this package
Signed-off-by: dwillist <dthornton@vmware.com>
2021-02-14 17:23:30 -05:00

31 lines
573 B
Go

package components
import (
"github.com/rivo/tview"
)
type Visiblility interface {
Visible() bool
}
type VisiblePrimitive interface {
tview.Primitive
Visiblility
}
type VisibleFunc func(tview.Primitive) bool
func Always(alwaysVal bool) VisibleFunc {
return func (_ tview.Primitive) bool {
return alwaysVal
}
}
func MinHeightVisibility(minHeight int) VisibleFunc {
return func(p tview.Primitive) bool {
_, _, _, height := p.GetRect()
return height >= minHeight
}
}