gui/view.go

32 lines
869 B
Go
Raw Normal View History

2023-01-22 12:38:03 +01:00
package gui
// 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
Style
Layout(ctx AppContext) (prefWidth, prefHeight int)
Draw(img *Image, ctx AppContext)
}
// Layout defines the behavior of a View which can hold multiple sub views
type Layout interface {
View
Views() []View
}
// Wrapper defines the behavior of a Layout 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 {
Layout
SetView(View)
View() View
}