Renderers now respect Location of NewRendererOptions.

This commit is contained in:
Sander Schobers 2020-05-17 21:02:38 +02:00
parent 32c53eb947
commit 7f2e155edd
3 changed files with 11 additions and 1 deletions

View File

@ -308,6 +308,8 @@ func (r *Renderer) SetMouseCursor(c ui.MouseCursor) {
r.cursor = c
}
func (r *Renderer) SetPosition(p geom.PointF32) { r.disp.SetPosition(int(p.X), int(p.Y)) }
func (r *Renderer) SetResourceProvider(factory func() ui.Resources) {
if r.res != nil {
r.res.Destroy()

View File

@ -20,5 +20,8 @@ func (f rendererFactory) New(title string, width, height int, opts ui.NewRendere
return nil, err
}
renderer.SetWindowTitle(title)
if opts.Location != nil {
renderer.SetPosition(*opts.Location)
}
return renderer, nil
}

View File

@ -12,8 +12,13 @@ func init() {
type rendererFactory struct{}
func (f rendererFactory) New(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) {
location := sdl.Point{X: sdl.WINDOWPOS_UNDEFINED, Y: sdl.WINDOWPOS_UNDEFINED}
if opts.Location != nil {
location.X = int32(opts.Location.X)
location.Y = int32(opts.Location.Y)
}
return NewRenderer(title, int32(width), int32(height), NewRendererOptions{
Location: sdl.Point{X: sdl.WINDOWPOS_UNDEFINED, Y: sdl.WINDOWPOS_UNDEFINED},
Location: location,
Resizable: opts.Resizable,
VSync: opts.VSync,
})