Added default style if style is not set on Run{,Wait}.

Exposed Resources in Context as well.
This commit is contained in:
Sander Schobers 2020-05-17 07:54:54 +02:00
parent b78f215c8c
commit e2472cffef
2 changed files with 6 additions and 0 deletions

View File

@ -12,6 +12,7 @@ type Context interface {
Overlays() *Overlays
Quit()
Renderer() Renderer
Resources() Resources
ShowTooltip(t string)
Style() *Style
Textures() *Textures
@ -71,6 +72,8 @@ func (c *context) Overlays() *Overlays { return c.overlays }
func (c *context) Renderer() Renderer { return c.renderer }
func (c *context) Resources() Resources { return c.renderer.Resources() }
func (c *context) ShowTooltip(t string) {
c.tooltip.Text = t
}

View File

@ -13,6 +13,9 @@ func Run(r Renderer, s *Style, view Control) error {
// RunWait runs the application loop and conditionally waits on events before rendering.
func RunWait(r Renderer, s *Style, view Control, wait bool) error {
if s == nil {
s = DefaultStyle()
}
ctx := newContext(r, s, view)
defer ctx.Destroy()