tui/wrappertmpl.go
Timon Ringwald dfa00f5fe3 more views
2022-04-02 13:01:41 +02:00

58 lines
946 B
Go

package tui
type WrapperTmpl struct {
ViewTmpl
view View
}
var _ Wrapper = &WrapperTmpl{}
func (v *WrapperTmpl) Draw(buf *ViewBuffer) {
if v.view != nil {
v.view.Draw(buf)
} else {
v.ViewTmpl.Draw(buf)
}
}
func (v *WrapperTmpl) Layout() (prefWidth, prefHeight int) {
if v.view != nil {
return v.view.Layout()
}
return v.ViewTmpl.Layout()
}
func (v *WrapperTmpl) OnKeyPressed(event *KeyEvent) (consumed bool) {
if v.view != nil {
return v.view.OnKeyPressed(event)
}
return v.ViewTmpl.OnKeyPressed(event)
}
func (v *WrapperTmpl) SetStyle(s Style) {
if v.view != nil {
v.view.SetStyle(s)
return
}
v.ViewTmpl.SetStyle(s)
}
func (v *WrapperTmpl) Style() Style {
if v.view != nil {
return v.view.Style()
}
return v.ViewTmpl.Style()
}
func (v *WrapperTmpl) Views() []View {
return []View{v.view}
}
func (v *WrapperTmpl) View() View {
return v.view
}
func (v *WrapperTmpl) SetView(view View) {
v.view = view
}