mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Panic on MaximizeWindow when the window is not resizable
On Windows, the window could be maximized even when the window was not resizable. This behavior is confusing. Forbid it so that the behavior will be clearer.
This commit is contained in:
parent
3e244d7a7c
commit
4fe5acd711
@ -251,7 +251,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
ebiten.SetWindowDecorated(decorated)
|
||||
ebiten.SetWindowPosition(positionX, positionY)
|
||||
ebiten.SetWindowFloating(floating)
|
||||
if maximize {
|
||||
if maximize && ebiten.IsWindowResizable() {
|
||||
ebiten.MaximizeWindow()
|
||||
}
|
||||
if minimize {
|
||||
@ -294,7 +294,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
var lines []string
|
||||
if !ebiten.IsWindowMaximized() {
|
||||
if !ebiten.IsWindowMaximized() && ebiten.IsWindowResizable() {
|
||||
lines = append(lines, "[M] Maximize the window")
|
||||
}
|
||||
if !ebiten.IsWindowMinimized() {
|
||||
@ -403,6 +403,7 @@ func main() {
|
||||
ebiten.SetWindowFloating(true)
|
||||
}
|
||||
if *flagMaximize {
|
||||
ebiten.SetWindowResizable(true)
|
||||
ebiten.MaximizeWindow()
|
||||
}
|
||||
if *flagAutoAdjusting {
|
||||
|
@ -129,6 +129,9 @@ func (w *window) IsMaximized() bool {
|
||||
}
|
||||
|
||||
func (w *window) Maximize() {
|
||||
if !w.IsResizable() {
|
||||
panic("glfw: a window to maximize must be resizable")
|
||||
}
|
||||
if !w.ui.isRunning() {
|
||||
w.ui.setInitWindowMaximized(true)
|
||||
return
|
||||
|
@ -262,12 +262,15 @@ func SetWindowFloating(float bool) {
|
||||
|
||||
// MaximizeWindow maximizes the window.
|
||||
//
|
||||
// On some environments like macOS, MaximizeWindow requres that the window is resizable.
|
||||
// MaximizeWindow panics when the window is not resizable.
|
||||
//
|
||||
// MaximizeWindow does nothing on browsers or mobiles.
|
||||
//
|
||||
// MaximizeWindow is concurrent-safe.
|
||||
func MaximizeWindow() {
|
||||
if !IsWindowResizable() {
|
||||
panic("ebiten: a window to maximize must be resizable")
|
||||
}
|
||||
if w := uiDriver().Window(); w != nil {
|
||||
w.Maximize()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user