zntg/allg5ui/rendererfactory.go
Sander Schobers 2c9007ce9b Added renderer factory.
- Removes dependency on the specific backend from an application point-of-view.
2020-05-12 22:46:58 +02:00

28 lines
666 B
Go

package allg5ui
import (
"opslag.de/schobers/allg5"
"opslag.de/schobers/zntg/ui"
)
func init() {
ui.SetRendererFactory(&rendererFactory{})
}
type rendererFactory struct{}
func (f rendererFactory) New(title string, width, height int) (ui.Renderer, error) {
return f.NewOptions(title, width, height, ui.NewRendererOptions{Resizable: true})
}
func (f rendererFactory) NewOptions(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) {
renderer, err := NewRenderer(width, height, allg5.NewDisplayOptions{
Resizable: opts.Resizable,
})
if err != nil {
return nil, err
}
renderer.SetWindowTitle(title)
return renderer, nil
}