tui/view.go
2022-04-01 20:10:51 +02:00

41 lines
1.1 KiB
Go

package tui
// View defines the behavior of any element displayable on screen
// To define custom Views, it is recommended to add ViewTmpl
// as the promoted anonymous field for your custom View struct.
// It implements the View interface with useful default behavior
type View interface {
Events
SetForeground(color Color)
Foreground() Color
SetBackground(color Color)
Background() Color
Style() Style
Draw(*ViewBuffer)
}
// Group defines the behavior of a View which can hold multiple sub views
// To define custom Groups, it is recommended to add GroupTmpl
// as the promoted anonymous field for your custom Wrapper struct.
// It implements the Group interface with useful default behavior
type Group interface {
View
Children() []View
}
// Wrapper defines the behavior of a GroupView which can hold exactly one sub view
// To define custom Wrappers, it is recommended to add WrapperTmpl
// as the promoted anonymous field for your custom Wrapper struct.
// It implements the Wrapper interface with useful default behavior
type Wrapper interface {
Group
SetView(View)
View() View
}