zntg/ui/context.go
Sander Schobers 19daffd110 Added UI elements.
Reversed order of operands when comparing with nil/0 .
2019-03-05 21:52:18 +01:00

41 lines
690 B
Go

package ui
type Context interface {
HasQuit() bool
Images() *Images
Quit()
Renderer() Renderer
Style() *Style
}
var _ Context = &context{}
var _ EventTarget = &context{}
type context struct {
quit bool
r Renderer
view Control
ims *Images
style *Style
}
func (c *context) HasQuit() bool { return c.quit }
func (c *context) Images() *Images { return c.ims }
func (c *context) Quit() { c.quit = true }
func (c *context) Renderer() Renderer { return c.r }
func (c *context) Style() *Style { return c.style }
// Handle implement EventTarget
func (c *context) Handle(e Event) {
switch e.(type) {
case *DisplayCloseEvent:
c.Quit()
return
}
c.view.Handle(c, e)
}