zori.go 894 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package zori
  2. // import "fmt"
  3. // import "gitlab.com/beoran/ebsgo/monolog"
  4. import "gitlab.com/beoran/ebsgo/zori/event"
  5. import _ "gitlab.com/beoran/ebsgo/zori/types"
  6. import "gitlab.com/beoran/ebsgo/zori/backend"
  7. import _ "gitlab.com/beoran/ebsgo/zori/state"
  8. import "gitlab.com/beoran/ebsgo/zori/style"
  9. import "gitlab.com/beoran/ebsgo/zori/widget"
  10. type UI struct {
  11. * widget.Root
  12. backend.Backend
  13. }
  14. func New(be backend.Backend, theme * style.Theme ) *UI {
  15. res := &UI{}
  16. res.Backend = be
  17. res.Root = widget.NewRoot(res.Backend, theme)
  18. return res
  19. }
  20. func (ui * UI) Dispatch(ev event.Event) event.Result {
  21. return ui.Root.Dispatch(ev)
  22. }
  23. func (ui * UI) Draw() event.Result {
  24. ev := event.Draw{}
  25. return ui.Root.Dispatch(ev)
  26. }
  27. func (ui * UI) Update(dt float64) event.Result {
  28. ev := event.Update{}
  29. ev.TimePassed = dt
  30. return ui.Root.Dispatch(ev)
  31. }