58 lines
1019 B
Go
58 lines
1019 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) OnMouseEvent(event *MouseEvent) (consumed bool) {
|
|
if v.view != nil {
|
|
return v.view.OnMouseEvent(event)
|
|
}
|
|
return v.ViewTmpl.OnMouseEvent(event)
|
|
}
|
|
|
|
func (v *WrapperTmpl) SetStyle(s Style) {
|
|
v.ViewTmpl.SetStyle(s)
|
|
}
|
|
|
|
func (v *WrapperTmpl) Style() 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
|
|
}
|