mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
parent
80c03792cb
commit
0f09ddfbd2
@ -1,52 +0,0 @@
|
|||||||
// Copyright 2019 The Ebiten Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package driver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"image"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Window interface {
|
|
||||||
IsDecorated() bool
|
|
||||||
SetDecorated(decorated bool)
|
|
||||||
|
|
||||||
IsResizable() bool
|
|
||||||
SetResizable(resizable bool)
|
|
||||||
|
|
||||||
Position() (int, int)
|
|
||||||
SetPosition(x, y int)
|
|
||||||
|
|
||||||
Size() (int, int)
|
|
||||||
SetSize(width, height int)
|
|
||||||
SizeLimits() (minw, minh, maxw, maxh int)
|
|
||||||
SetSizeLimits(minw, minh, maxw, maxh int)
|
|
||||||
|
|
||||||
IsFloating() bool
|
|
||||||
SetFloating(floating bool)
|
|
||||||
|
|
||||||
Maximize()
|
|
||||||
IsMaximized() bool
|
|
||||||
|
|
||||||
Minimize()
|
|
||||||
IsMinimized() bool
|
|
||||||
|
|
||||||
SetIcon(iconImages []image.Image)
|
|
||||||
SetTitle(title string)
|
|
||||||
Restore()
|
|
||||||
|
|
||||||
IsBeingClosed() bool
|
|
||||||
SetClosingHandled(handled bool)
|
|
||||||
IsClosingHandled() bool
|
|
||||||
}
|
|
@ -22,7 +22,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/cbackend"
|
"github.com/hajimehoshi/ebiten/v2/internal/cbackend"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const deviceScaleFactor = 1
|
const deviceScaleFactor = 1
|
||||||
@ -132,6 +131,6 @@ func (*UserInterface) Input() *Input {
|
|||||||
return &theUserInterface.input
|
return &theUserInterface.input
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*UserInterface) Window() driver.Window {
|
func (*UserInterface) Window() *Window {
|
||||||
return nil
|
return &Window{}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/thread"
|
"github.com/hajimehoshi/ebiten/v2/internal/thread"
|
||||||
@ -102,7 +101,7 @@ type UserInterface struct {
|
|||||||
fpsModeInited bool
|
fpsModeInited bool
|
||||||
|
|
||||||
input Input
|
input Input
|
||||||
iwindow window
|
iwindow Window
|
||||||
|
|
||||||
sizeCallback glfw.SizeCallback
|
sizeCallback glfw.SizeCallback
|
||||||
closeCallback glfw.CloseCallback
|
closeCallback glfw.CloseCallback
|
||||||
@ -1435,7 +1434,7 @@ func (u *UserInterface) Input() *Input {
|
|||||||
return &u.input
|
return &u.input
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) Window() driver.Window {
|
func (u *UserInterface) Window() *Window {
|
||||||
return &u.iwindow
|
return &u.iwindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
||||||
)
|
)
|
||||||
@ -665,6 +664,6 @@ func (u *UserInterface) Input() *Input {
|
|||||||
return &u.input
|
return &u.input
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) Window() driver.Window {
|
func (u *UserInterface) Window() *Window {
|
||||||
return nil
|
return &Window{}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
"golang.org/x/mobile/gl"
|
"golang.org/x/mobile/gl"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
"github.com/hajimehoshi/ebiten/v2/internal/devicescale"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
"github.com/hajimehoshi/ebiten/v2/internal/gamepad"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
||||||
@ -450,8 +449,8 @@ func (u *UserInterface) Input() *Input {
|
|||||||
return &u.input
|
return &u.input
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) Window() driver.Window {
|
func (u *UserInterface) Window() *Window {
|
||||||
return nil
|
return &Window{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Touch struct {
|
type Touch struct {
|
||||||
|
@ -23,11 +23,11 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||||
)
|
)
|
||||||
|
|
||||||
type window struct {
|
type Window struct {
|
||||||
ui *UserInterface
|
ui *UserInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsDecorated() bool {
|
func (w *Window) IsDecorated() bool {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
return w.ui.isInitWindowDecorated()
|
return w.ui.isInitWindowDecorated()
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ func (w *window) IsDecorated() bool {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetDecorated(decorated bool) {
|
func (w *Window) SetDecorated(decorated bool) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.setInitWindowDecorated(decorated)
|
w.ui.setInitWindowDecorated(decorated)
|
||||||
return
|
return
|
||||||
@ -53,7 +53,7 @@ func (w *window) SetDecorated(decorated bool) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsResizable() bool {
|
func (w *Window) IsResizable() bool {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
return w.ui.isInitWindowResizable()
|
return w.ui.isInitWindowResizable()
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func (w *window) IsResizable() bool {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetResizable(resizable bool) {
|
func (w *Window) SetResizable(resizable bool) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.setInitWindowResizable(resizable)
|
w.ui.setInitWindowResizable(resizable)
|
||||||
return
|
return
|
||||||
@ -77,7 +77,7 @@ func (w *window) SetResizable(resizable bool) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsFloating() bool {
|
func (w *Window) IsFloating() bool {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
return w.ui.isInitWindowFloating()
|
return w.ui.isInitWindowFloating()
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func (w *window) IsFloating() bool {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetFloating(floating bool) {
|
func (w *Window) SetFloating(floating bool) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.setInitWindowFloating(floating)
|
w.ui.setInitWindowFloating(floating)
|
||||||
return
|
return
|
||||||
@ -101,7 +101,7 @@ func (w *window) SetFloating(floating bool) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsMaximized() bool {
|
func (w *Window) IsMaximized() bool {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
return w.ui.isInitWindowMaximized()
|
return w.ui.isInitWindowMaximized()
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func (w *window) IsMaximized() bool {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Maximize() {
|
func (w *Window) Maximize() {
|
||||||
if !w.IsResizable() {
|
if !w.IsResizable() {
|
||||||
panic("ui: a window to maximize must be resizable")
|
panic("ui: a window to maximize must be resizable")
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ func (w *window) Maximize() {
|
|||||||
w.ui.t.Call(w.ui.maximizeWindow)
|
w.ui.t.Call(w.ui.maximizeWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsMinimized() bool {
|
func (w *Window) IsMinimized() bool {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ func (w *window) IsMinimized() bool {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Minimize() {
|
func (w *Window) Minimize() {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
return
|
return
|
||||||
@ -142,7 +142,7 @@ func (w *window) Minimize() {
|
|||||||
w.ui.t.Call(w.ui.iconifyWindow)
|
w.ui.t.Call(w.ui.iconifyWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Restore() {
|
func (w *Window) Restore() {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
return
|
return
|
||||||
@ -150,7 +150,7 @@ func (w *window) Restore() {
|
|||||||
w.ui.t.Call(w.ui.restoreWindow)
|
w.ui.t.Call(w.ui.restoreWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Position() (int, int) {
|
func (w *Window) Position() (int, int) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
panic("ui: WindowPosition can't be called before the main loop starts")
|
panic("ui: WindowPosition can't be called before the main loop starts")
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ func (w *window) Position() (int, int) {
|
|||||||
return x, y
|
return x, y
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetPosition(x, y int) {
|
func (w *Window) SetPosition(x, y int) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.setInitWindowPositionInDIP(x, y)
|
w.ui.setInitWindowPositionInDIP(x, y)
|
||||||
return
|
return
|
||||||
@ -183,7 +183,7 @@ func (w *window) SetPosition(x, y int) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) Size() (int, int) {
|
func (w *Window) Size() (int, int) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
ww, wh := w.ui.getInitWindowSizeInDIP()
|
ww, wh := w.ui.getInitWindowSizeInDIP()
|
||||||
return w.ui.adjustWindowSizeBasedOnSizeLimitsInDIP(ww, wh)
|
return w.ui.adjustWindowSizeBasedOnSizeLimitsInDIP(ww, wh)
|
||||||
@ -196,7 +196,7 @@ func (w *window) Size() (int, int) {
|
|||||||
return ww, wh
|
return ww, wh
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetSize(width, height int) {
|
func (w *Window) SetSize(width, height int) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.setInitWindowSizeInDIP(width, height)
|
w.ui.setInitWindowSizeInDIP(width, height)
|
||||||
return
|
return
|
||||||
@ -212,11 +212,11 @@ func (w *window) SetSize(width, height int) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SizeLimits() (minw, minh, maxw, maxh int) {
|
func (w *Window) SizeLimits() (minw, minh, maxw, maxh int) {
|
||||||
return w.ui.getWindowSizeLimitsInDIP()
|
return w.ui.getWindowSizeLimitsInDIP()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
||||||
if !w.ui.setWindowSizeLimitsInDIP(minw, minh, maxw, maxh) {
|
if !w.ui.setWindowSizeLimitsInDIP(minw, minh, maxw, maxh) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -227,12 +227,12 @@ func (w *window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
|||||||
w.ui.t.Call(w.ui.updateWindowSizeLimits)
|
w.ui.t.Call(w.ui.updateWindowSizeLimits)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetIcon(iconImages []image.Image) {
|
func (w *Window) SetIcon(iconImages []image.Image) {
|
||||||
// The icons are actually set at (*UserInterface).loop.
|
// The icons are actually set at (*UserInterface).loop.
|
||||||
w.ui.setIconImages(iconImages)
|
w.ui.setIconImages(iconImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetTitle(title string) {
|
func (w *Window) SetTitle(title string) {
|
||||||
if !w.ui.isRunning() {
|
if !w.ui.isRunning() {
|
||||||
w.ui.m.Lock()
|
w.ui.m.Lock()
|
||||||
w.ui.title = title
|
w.ui.title = title
|
||||||
@ -245,14 +245,14 @@ func (w *window) SetTitle(title string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsBeingClosed() bool {
|
func (w *Window) IsBeingClosed() bool {
|
||||||
return w.ui.isWindowBeingClosed()
|
return w.ui.isWindowBeingClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) SetClosingHandled(handled bool) {
|
func (w *Window) SetClosingHandled(handled bool) {
|
||||||
w.ui.setWindowClosingHandled(handled)
|
w.ui.setWindowClosingHandled(handled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *window) IsClosingHandled() bool {
|
func (w *Window) IsClosingHandled() bool {
|
||||||
return w.ui.isWindowClosingHandled()
|
return w.ui.isWindowClosingHandled()
|
||||||
}
|
}
|
||||||
|
100
internal/ui/window_null.go
Normal file
100
internal/ui/window_null.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// Copyright 2022 The Ebiten Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build android || js || ios || ebitencbackend
|
||||||
|
// +build android js ios ebitencbackend
|
||||||
|
|
||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"image"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Window struct{}
|
||||||
|
|
||||||
|
func (*Window) IsDecorated() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetDecorated(decorated bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsResizable() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetResizable(resizable bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) Position() (int, int) {
|
||||||
|
return 0, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetPosition(x, y int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) Size() (int, int) {
|
||||||
|
return 0, 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetSize(width, height int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SizeLimits() (minw, minh, maxw, maxh int) {
|
||||||
|
return -1, -1, -1, -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsFloating() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetFloating(floating bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) Maximize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsMaximized() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) Minimize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsMinimized() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetIcon(iconImages []image.Image) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetTitle(title string) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) Restore() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsBeingClosed() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) SetClosingHandled(handled bool) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Window) IsClosingHandled() bool {
|
||||||
|
return false
|
||||||
|
}
|
105
window.go
105
window.go
@ -31,10 +31,7 @@ const (
|
|||||||
//
|
//
|
||||||
// IsWindowDecorated is concurrent-safe.
|
// IsWindowDecorated is concurrent-safe.
|
||||||
func IsWindowDecorated() bool {
|
func IsWindowDecorated() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsDecorated()
|
||||||
return w.IsDecorated()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowDecorated sets the state if the window is decorated.
|
// SetWindowDecorated sets the state if the window is decorated.
|
||||||
@ -49,9 +46,7 @@ func IsWindowDecorated() bool {
|
|||||||
//
|
//
|
||||||
// SetWindowDecorated is concurrent-safe.
|
// SetWindowDecorated is concurrent-safe.
|
||||||
func SetWindowDecorated(decorated bool) {
|
func SetWindowDecorated(decorated bool) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetDecorated(decorated)
|
||||||
w.SetDecorated(decorated)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowResizable reports whether the window is resizable by the user's dragging on desktops.
|
// IsWindowResizable reports whether the window is resizable by the user's dragging on desktops.
|
||||||
@ -59,10 +54,7 @@ func SetWindowDecorated(decorated bool) {
|
|||||||
//
|
//
|
||||||
// IsWindowResizable is concurrent-safe.
|
// IsWindowResizable is concurrent-safe.
|
||||||
func IsWindowResizable() bool {
|
func IsWindowResizable() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsResizable()
|
||||||
return w.IsResizable()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowResizable sets whether the window is resizable by the user's dragging on desktops.
|
// SetWindowResizable sets whether the window is resizable by the user's dragging on desktops.
|
||||||
@ -77,9 +69,7 @@ func IsWindowResizable() bool {
|
|||||||
//
|
//
|
||||||
// SetWindowResizable is concurrent-safe.
|
// SetWindowResizable is concurrent-safe.
|
||||||
func SetWindowResizable(resizable bool) {
|
func SetWindowResizable(resizable bool) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetResizable(resizable)
|
||||||
w.SetResizable(resizable)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowTitle sets the title of the window.
|
// SetWindowTitle sets the title of the window.
|
||||||
@ -88,9 +78,7 @@ func SetWindowResizable(resizable bool) {
|
|||||||
//
|
//
|
||||||
// SetWindowTitle is concurrent-safe.
|
// SetWindowTitle is concurrent-safe.
|
||||||
func SetWindowTitle(title string) {
|
func SetWindowTitle(title string) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetTitle(title)
|
||||||
w.SetTitle(title)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowIcon sets the icon of the game window.
|
// SetWindowIcon sets the icon of the game window.
|
||||||
@ -114,9 +102,7 @@ func SetWindowTitle(title string) {
|
|||||||
//
|
//
|
||||||
// SetWindowIcon is concurrent-safe.
|
// SetWindowIcon is concurrent-safe.
|
||||||
func SetWindowIcon(iconImages []image.Image) {
|
func SetWindowIcon(iconImages []image.Image) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetIcon(iconImages)
|
||||||
w.SetIcon(iconImages)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WindowPosition returns the window position.
|
// WindowPosition returns the window position.
|
||||||
@ -131,10 +117,7 @@ func SetWindowIcon(iconImages []image.Image) {
|
|||||||
//
|
//
|
||||||
// WindowPosition is concurrent-safe.
|
// WindowPosition is concurrent-safe.
|
||||||
func WindowPosition() (x, y int) {
|
func WindowPosition() (x, y int) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().Position()
|
||||||
return w.Position()
|
|
||||||
}
|
|
||||||
return 0, 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowPosition sets the window position.
|
// SetWindowPosition sets the window position.
|
||||||
@ -148,9 +131,7 @@ func WindowPosition() (x, y int) {
|
|||||||
// SetWindowPosition is concurrent-safe.
|
// SetWindowPosition is concurrent-safe.
|
||||||
func SetWindowPosition(x, y int) {
|
func SetWindowPosition(x, y int) {
|
||||||
atomic.StoreUint32(&windowPositionSetExplicitly, 1)
|
atomic.StoreUint32(&windowPositionSetExplicitly, 1)
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetPosition(x, y)
|
||||||
w.SetPosition(x, y)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -158,16 +139,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func initializeWindowPositionIfNeeded(width, height int) {
|
func initializeWindowPositionIfNeeded(width, height int) {
|
||||||
w := ui.Get().Window()
|
|
||||||
if w == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if atomic.LoadUint32(&windowPositionSetExplicitly) == 0 {
|
if atomic.LoadUint32(&windowPositionSetExplicitly) == 0 {
|
||||||
sw, sh := ui.Get().ScreenSizeInFullscreen()
|
sw, sh := ui.Get().ScreenSizeInFullscreen()
|
||||||
x := (sw - width) / 2
|
x := (sw - width) / 2
|
||||||
y := (sh - height) / 3
|
y := (sh - height) / 3
|
||||||
w.SetPosition(x, y)
|
ui.Get().Window().SetPosition(x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,10 +154,7 @@ func initializeWindowPositionIfNeeded(width, height int) {
|
|||||||
//
|
//
|
||||||
// WindowSize is concurrent-safe.
|
// WindowSize is concurrent-safe.
|
||||||
func WindowSize() (int, int) {
|
func WindowSize() (int, int) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().Size()
|
||||||
return w.Size()
|
|
||||||
}
|
|
||||||
return 0, 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowSize sets the window size on desktops.
|
// SetWindowSize sets the window size on desktops.
|
||||||
@ -196,9 +169,7 @@ func SetWindowSize(width, height int) {
|
|||||||
if width <= 0 || height <= 0 {
|
if width <= 0 || height <= 0 {
|
||||||
panic("ebiten: width and height must be positive")
|
panic("ebiten: width and height must be positive")
|
||||||
}
|
}
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetSize(width, height)
|
||||||
w.SetSize(width, height)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WindowSizeLimits returns the limitation of the window size on desktops.
|
// WindowSizeLimits returns the limitation of the window size on desktops.
|
||||||
@ -206,10 +177,7 @@ func SetWindowSize(width, height int) {
|
|||||||
//
|
//
|
||||||
// WindowSizeLimits is concurrent-safe.
|
// WindowSizeLimits is concurrent-safe.
|
||||||
func WindowSizeLimits() (minw, minh, maxw, maxh int) {
|
func WindowSizeLimits() (minw, minh, maxw, maxh int) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().SizeLimits()
|
||||||
return w.SizeLimits()
|
|
||||||
}
|
|
||||||
return -1, -1, -1, -1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowSizeLimits sets the limitation of the window size on desktops.
|
// SetWindowSizeLimits sets the limitation of the window size on desktops.
|
||||||
@ -217,9 +185,7 @@ func WindowSizeLimits() (minw, minh, maxw, maxh int) {
|
|||||||
//
|
//
|
||||||
// SetWindowSizeLimits is concurrent-safe.
|
// SetWindowSizeLimits is concurrent-safe.
|
||||||
func SetWindowSizeLimits(minw, minh, maxw, maxh int) {
|
func SetWindowSizeLimits(minw, minh, maxw, maxh int) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetSizeLimits(minw, minh, maxw, maxh)
|
||||||
w.SetSizeLimits(minw, minh, maxw, maxh)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowFloating reports whether the window is always shown above all the other windows.
|
// IsWindowFloating reports whether the window is always shown above all the other windows.
|
||||||
@ -228,10 +194,7 @@ func SetWindowSizeLimits(minw, minh, maxw, maxh int) {
|
|||||||
//
|
//
|
||||||
// IsWindowFloating is concurrent-safe.
|
// IsWindowFloating is concurrent-safe.
|
||||||
func IsWindowFloating() bool {
|
func IsWindowFloating() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsFloating()
|
||||||
return w.IsFloating()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowFloating sets the state whether the window is always shown above all the other windows.
|
// SetWindowFloating sets the state whether the window is always shown above all the other windows.
|
||||||
@ -243,9 +206,7 @@ func IsWindowFloating() bool {
|
|||||||
//
|
//
|
||||||
// SetWindowFloating is concurrent-safe.
|
// SetWindowFloating is concurrent-safe.
|
||||||
func SetWindowFloating(float bool) {
|
func SetWindowFloating(float bool) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetFloating(float)
|
||||||
w.SetFloating(float)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaximizeWindow maximizes the window.
|
// MaximizeWindow maximizes the window.
|
||||||
@ -259,9 +220,7 @@ func MaximizeWindow() {
|
|||||||
if !IsWindowResizable() {
|
if !IsWindowResizable() {
|
||||||
panic("ebiten: a window to maximize must be resizable")
|
panic("ebiten: a window to maximize must be resizable")
|
||||||
}
|
}
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().Maximize()
|
||||||
w.Maximize()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowMaximized reports whether the window is maximized or not.
|
// IsWindowMaximized reports whether the window is maximized or not.
|
||||||
@ -275,10 +234,7 @@ func IsWindowMaximized() bool {
|
|||||||
if !IsWindowResizable() {
|
if !IsWindowResizable() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsMaximized()
|
||||||
return w.IsMaximized()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinimizeWindow minimizes the window.
|
// MinimizeWindow minimizes the window.
|
||||||
@ -289,9 +245,7 @@ func IsWindowMaximized() bool {
|
|||||||
//
|
//
|
||||||
// MinimizeWindow is concurrent-safe.
|
// MinimizeWindow is concurrent-safe.
|
||||||
func MinimizeWindow() {
|
func MinimizeWindow() {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().Minimize()
|
||||||
w.Minimize()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowMinimized reports whether the window is minimized or not.
|
// IsWindowMinimized reports whether the window is minimized or not.
|
||||||
@ -300,10 +254,7 @@ func MinimizeWindow() {
|
|||||||
//
|
//
|
||||||
// IsWindowMinimized is concurrent-safe.
|
// IsWindowMinimized is concurrent-safe.
|
||||||
func IsWindowMinimized() bool {
|
func IsWindowMinimized() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsMinimized()
|
||||||
return w.IsMinimized()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestoreWindow restores the window from its maximized or minimized state.
|
// RestoreWindow restores the window from its maximized or minimized state.
|
||||||
@ -315,9 +266,7 @@ func RestoreWindow() {
|
|||||||
if !IsWindowMaximized() && !IsWindowMinimized() {
|
if !IsWindowMaximized() && !IsWindowMinimized() {
|
||||||
panic("ebiten: RestoreWindow must be called on a maximized or a minimized window")
|
panic("ebiten: RestoreWindow must be called on a maximized or a minimized window")
|
||||||
}
|
}
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().Restore()
|
||||||
w.Restore()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowBeingClosed returns true when the user is trying to close the window on desktops.
|
// IsWindowBeingClosed returns true when the user is trying to close the window on desktops.
|
||||||
@ -328,10 +277,7 @@ func RestoreWindow() {
|
|||||||
//
|
//
|
||||||
// IsWindowBeingClosed is concurrent-safe.
|
// IsWindowBeingClosed is concurrent-safe.
|
||||||
func IsWindowBeingClosed() bool {
|
func IsWindowBeingClosed() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsBeingClosed()
|
||||||
return w.IsBeingClosed()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowClosingHandled sets whether the window closing is handled or not on desktops. The default state is false.
|
// SetWindowClosingHandled sets whether the window closing is handled or not on desktops. The default state is false.
|
||||||
@ -346,9 +292,7 @@ func IsWindowBeingClosed() bool {
|
|||||||
//
|
//
|
||||||
// SetWindowClosingHandled is concurrent-safe.
|
// SetWindowClosingHandled is concurrent-safe.
|
||||||
func SetWindowClosingHandled(handled bool) {
|
func SetWindowClosingHandled(handled bool) {
|
||||||
if w := ui.Get().Window(); w != nil {
|
ui.Get().Window().SetClosingHandled(handled)
|
||||||
w.SetClosingHandled(handled)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsWindowClosingHandled reports whether the window closing is handled or not on desktops by SetWindowClosingHandled.
|
// IsWindowClosingHandled reports whether the window closing is handled or not on desktops by SetWindowClosingHandled.
|
||||||
@ -357,8 +301,5 @@ func SetWindowClosingHandled(handled bool) {
|
|||||||
//
|
//
|
||||||
// IsWindowClosingHandled is concurrent-safe.
|
// IsWindowClosingHandled is concurrent-safe.
|
||||||
func IsWindowClosingHandled() bool {
|
func IsWindowClosingHandled() bool {
|
||||||
if w := ui.Get().Window(); w != nil {
|
return ui.Get().Window().IsClosingHandled()
|
||||||
return w.IsClosingHandled()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user