tui/view.go

34 lines
872 B
Go
Raw Normal View History

2021-01-10 21:52:29 +01:00
package tui
2022-04-02 13:01:41 +02:00
// View defines the behavior of any element displayable on screen.
2022-04-01 20:10:51 +02:00
// 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-02 13:01:41 +02:00
SetStyle(s Style)
2022-04-01 20:10:51 +02:00
Style() Style
2022-04-02 13:01:41 +02:00
Layout() (prefWidth, prefHeight int)
Draw(buf *ViewBuffer)
2022-04-01 20:10:51 +02:00
}
// Group defines the behavior of a View which can hold multiple sub views
type Group interface {
View
2022-04-02 13:01:41 +02:00
Views() []View
2022-04-01 20:10:51 +02:00
}
2021-01-10 21:52:29 +01:00
2022-04-02 13:01:41 +02:00
// Wrapper defines the behavior of a GroupView which can hold exactly one sub view.
2022-04-01 20:10:51 +02:00
// 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
}