Merge pull request #235 from fgrosse/window-initial-position
Support setting an initial window position
This commit is contained in:
commit
5568202e30
|
@ -3,8 +3,10 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
- Pending physical testing, Gamepad API support from [PR-233](https://github.com/faiface/pixel/pull/233)
|
||||
- Support setting an initial window position
|
||||
|
||||
## [v0.10.0-beta] 2020-05-10
|
||||
- Add `WindowConfig.TransparentFramebuffer` option to support window transparency onto the background
|
||||
|
|
|
@ -36,6 +36,9 @@ type WindowConfig struct {
|
|||
// Bounds specify the bounds of the Window in pixels.
|
||||
Bounds pixel.Rect
|
||||
|
||||
// Initial window position
|
||||
Position pixel.Vec
|
||||
|
||||
// If set to nil, the Window will be windowed. Otherwise it will be fullscreen on the
|
||||
// specified Monitor.
|
||||
Monitor *Monitor
|
||||
|
@ -120,6 +123,10 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
|
|||
glfw.WindowHint(glfw.AutoIconify, bool2int[!cfg.NoIconify])
|
||||
glfw.WindowHint(glfw.TransparentFramebuffer, bool2int[cfg.TransparentFramebuffer])
|
||||
|
||||
if cfg.Position.X != 0 || cfg.Position.Y != 0 {
|
||||
glfw.WindowHint(glfw.Visible, glfw.False)
|
||||
}
|
||||
|
||||
var share *glfw.Window
|
||||
if currWin != nil {
|
||||
share = currWin.window
|
||||
|
@ -136,6 +143,11 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if cfg.Position.X != 0 || cfg.Position.Y != 0 {
|
||||
w.window.SetPos(int(cfg.Position.X), int(cfg.Position.Y))
|
||||
w.window.Show()
|
||||
}
|
||||
|
||||
// enter the OpenGL context
|
||||
w.begin()
|
||||
glhf.Init()
|
||||
|
|
Loading…
Reference in New Issue