mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
ui: Adjust cursor position on fullscreen (#267)
This commit is contained in:
parent
e7370d8a54
commit
5b6fa2d384
@ -240,25 +240,29 @@ func (u *userInterface) glfwSize() (int, int) {
|
|||||||
return int(float64(u.width) * u.scale * u.glfwScale), int(float64(u.height) * u.scale * u.glfwScale)
|
return int(float64(u.width) * u.scale * u.glfwScale), int(float64(u.height) * u.scale * u.glfwScale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *userInterface) getScale() float64 {
|
||||||
|
if !u.fullscreen {
|
||||||
|
return u.scale
|
||||||
|
}
|
||||||
|
if u.fullscreenScale == 0 {
|
||||||
|
m := glfw.GetPrimaryMonitor()
|
||||||
|
v := m.GetVideoMode()
|
||||||
|
sw := float64(v.Width) / float64(u.width)
|
||||||
|
sh := float64(v.Height) / float64(u.height)
|
||||||
|
s := sw
|
||||||
|
if s > sh {
|
||||||
|
s = sh
|
||||||
|
}
|
||||||
|
u.fullscreenScale = s
|
||||||
|
}
|
||||||
|
return u.fullscreenScale
|
||||||
|
}
|
||||||
|
|
||||||
func (u *userInterface) actualScreenScale() float64 {
|
func (u *userInterface) actualScreenScale() float64 {
|
||||||
if u.deviceScale == 0 {
|
if u.deviceScale == 0 {
|
||||||
u.deviceScale = deviceScale()
|
u.deviceScale = deviceScale()
|
||||||
}
|
}
|
||||||
if u.fullscreen {
|
return u.getScale() * u.deviceScale
|
||||||
if u.fullscreenScale == 0 {
|
|
||||||
m := glfw.GetPrimaryMonitor()
|
|
||||||
v := m.GetVideoMode()
|
|
||||||
sw := float64(v.Width) / float64(u.width)
|
|
||||||
sh := float64(v.Height) / float64(u.height)
|
|
||||||
s := sw
|
|
||||||
if s > sh {
|
|
||||||
s = sh
|
|
||||||
}
|
|
||||||
u.fullscreenScale = s
|
|
||||||
}
|
|
||||||
return u.fullscreenScale * u.deviceScale
|
|
||||||
}
|
|
||||||
return u.scale * u.deviceScale
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) pollEvents() {
|
func (u *userInterface) pollEvents() {
|
||||||
@ -266,7 +270,7 @@ func (u *userInterface) pollEvents() {
|
|||||||
if u.glfwScale == 0 {
|
if u.glfwScale == 0 {
|
||||||
u.glfwScale = glfwScale()
|
u.glfwScale = glfwScale()
|
||||||
}
|
}
|
||||||
currentInput.update(u.window, u.scale*u.glfwScale)
|
currentInput.update(u.window, u.getScale()*u.glfwScale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) update(g GraphicsContext) error {
|
func (u *userInterface) update(g GraphicsContext) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user