zntg/ui/rendererfactory.go

32 lines
733 B
Go
Raw Normal View History

package ui
import (
"errors"
"opslag.de/schobers/geom"
)
type RendererFactory interface {
New(title string, width, height int) (Renderer, error)
NewOptions(title string, width, height int, opts NewRendererOptions) (Renderer, error)
}
var rendererFactory RendererFactory
func NewRenderer(title string, width, height int) (Renderer, error) {
if rendererFactory == nil {
return nil, errors.New("no renderer factory registered")
}
return rendererFactory.New(title, width, height)
}
// SetRendererFactory sets the new factory that is used to create a new renderer.
func SetRendererFactory(factory RendererFactory) {
rendererFactory = factory
}
type NewRendererOptions struct {
Location *geom.PointF32
Resizable bool
}