tui/view.go

41 lines
1.1 KiB
Go
Raw Normal View History

2021-01-10 21:52:29 +01:00
package tui
2022-04-01 20:10:51 +02:00
// 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
2021-01-10 21:52:29 +01:00
type View interface {
Events
2022-04-01 20:10:51 +02:00
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
}
2021-01-10 21:52:29 +01:00
2022-04-01 20:10:51 +02:00
// 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
2021-01-10 21:52:29 +01:00
2022-04-01 20:10:51 +02:00
SetView(View)
View() View
2021-01-10 21:52:29 +01:00
}