Sander Schobers
cdfb863ab0
Added Action{,s}. List of actions that can be used to defer cleanup code (see NewRenderer implementations). Added TextInputEvent (replaces the old KeyPressEvent) and added to new events KeyDown & KeyUp. Added VSync to NewRendererOptions. Removed IconScale from button. Added ImageSource interface that replaces the Image/Texture method on the Texture interface. This makes converting back a texture to an image optional (since this is atypical for a hardware texture for instance). Added new KeyModifier: OSCommand (Windows/Command key). Added KeyState that can keep the state of keys (pressed or not). Added KeyEnter, representing the Enter key. Changed signatures of CreateTexture methods in Renderer. Changed signatures of icon related method (removed factories). Basic example now depends on sdlgui.
33 lines
749 B
Go
33 lines
749 B
Go
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
|
|
VSync bool
|
|
}
|