mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Revert "ui: Add IsWindowResizable and SetWindowResizable"
This reverts commit f403e0716f
.
Reason: Compilation error on browsers
This commit is contained in:
parent
f403e0716f
commit
0d4e903b7a
@ -37,7 +37,6 @@ import (
|
||||
|
||||
var (
|
||||
windowDecorated = flag.Bool("windowdecorated", true, "whether the window is decorated")
|
||||
windowResizable = flag.Bool("windowresizable", false, "whether the window is resizable")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -222,7 +221,6 @@ func main() {
|
||||
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
|
||||
|
||||
ebiten.SetWindowDecorated(*windowDecorated)
|
||||
ebiten.SetWindowResizable(*windowResizable)
|
||||
|
||||
if err := ebiten.Run(update, initScreenWidth, initScreenHeight, initScreenScale, "Window Size (Ebiten Demo)"); err != nil && err != terminated {
|
||||
log.Fatal(err)
|
||||
|
@ -162,17 +162,6 @@ func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallbac
|
||||
return nil // TODO
|
||||
}
|
||||
|
||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
||||
var gcb glfw.SizeCallback
|
||||
if cbfun != nil {
|
||||
gcb = func(window *glfw.Window, width, height int) {
|
||||
cbfun(theWindows.get(window), width, height)
|
||||
}
|
||||
}
|
||||
w.w.SetSizeCallback(gcb)
|
||||
return nil // TODO
|
||||
}
|
||||
|
||||
func (w *Window) SetIcon(images []image.Image) {
|
||||
w.w.SetIcon(images)
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ type (
|
||||
CharModsCallback func(w *Window, char rune, mods ModifierKey)
|
||||
FramebufferSizeCallback func(w *Window, width int, height int)
|
||||
ScrollCallback func(w *Window, xoff float64, yoff float64)
|
||||
SizeCallback func(w *Window, width int, height int)
|
||||
)
|
||||
|
||||
type VidMode struct {
|
||||
|
@ -59,12 +59,8 @@ type userInterface struct {
|
||||
initFullscreen bool
|
||||
initCursorVisible bool
|
||||
initWindowDecorated bool
|
||||
initWindowResizable bool
|
||||
initIconImages []image.Image
|
||||
|
||||
reqWidth int
|
||||
reqHeight int
|
||||
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
@ -97,6 +93,7 @@ func initialize() error {
|
||||
glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
|
||||
}
|
||||
glfw.WindowHint(glfw.Visible, glfw.False)
|
||||
glfw.WindowHint(glfw.Resizable, glfw.False)
|
||||
|
||||
// Create a window to set the initial monitor.
|
||||
w, err := glfw.CreateWindow(16, 16, "", nil, nil)
|
||||
@ -232,19 +229,6 @@ func (u *userInterface) setRunnableInBackground(runnableInBackground bool) {
|
||||
u.m.Unlock()
|
||||
}
|
||||
|
||||
func (u *userInterface) isInitWindowResizable() bool {
|
||||
u.m.Lock()
|
||||
v := u.initWindowResizable
|
||||
u.m.Unlock()
|
||||
return v
|
||||
}
|
||||
|
||||
func (u *userInterface) setInitWindowResizable(resizable bool) {
|
||||
u.m.Lock()
|
||||
u.initWindowResizable = resizable
|
||||
u.m.Unlock()
|
||||
}
|
||||
|
||||
func (u *userInterface) getInitIconImages() []image.Image {
|
||||
u.m.Lock()
|
||||
i := u.initIconImages
|
||||
@ -274,15 +258,17 @@ func ScreenSizeInFullscreen() (int, int) {
|
||||
return int(float64(v.Width) / s), int(float64(v.Height) / s)
|
||||
}
|
||||
|
||||
func SetScreenSize(width, height int) {
|
||||
func SetScreenSize(width, height int) bool {
|
||||
u := currentUI
|
||||
if !u.isRunning() {
|
||||
panic("ui: Run is not called yet")
|
||||
}
|
||||
r := false
|
||||
_ = mainthread.Run(func() error {
|
||||
u.setScreenSize(width, height, u.scale, u.fullscreen(), u.vsync)
|
||||
r = u.setScreenSize(width, height, u.scale, u.fullscreen(), u.vsync)
|
||||
return nil
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func SetScreenScale(scale float64) bool {
|
||||
@ -523,30 +509,6 @@ func SetWindowDecorated(decorated bool) {
|
||||
// return nil
|
||||
}
|
||||
|
||||
func IsWindowResizable() bool {
|
||||
u := currentUI
|
||||
if !u.isRunning() {
|
||||
return u.isInitWindowResizable()
|
||||
}
|
||||
v := false
|
||||
_ = mainthread.Run(func() error {
|
||||
v = currentUI.window.GetAttrib(glfw.Resizable) == glfw.True
|
||||
return nil
|
||||
})
|
||||
return v
|
||||
}
|
||||
|
||||
func SetWindowResizable(resizable bool) {
|
||||
if !currentUI.isRunning() {
|
||||
currentUI.setInitWindowResizable(resizable)
|
||||
return
|
||||
}
|
||||
|
||||
panic("ui: SetWindowResizable can't be called after Run so far.")
|
||||
|
||||
// TODO: Now SetAttrib doesn't exist on GLFW 3.2. Revisit later (#556).
|
||||
}
|
||||
|
||||
func DeviceScaleFactor() float64 {
|
||||
f := 0.0
|
||||
u := currentUI
|
||||
@ -575,12 +537,6 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
|
||||
}
|
||||
glfw.WindowHint(glfw.Decorated, decorated)
|
||||
|
||||
resizable := glfw.False
|
||||
if u.isInitWindowResizable() {
|
||||
resizable = glfw.True
|
||||
}
|
||||
glfw.WindowHint(glfw.Resizable, resizable)
|
||||
|
||||
// As a start, create a window with temporary size to create OpenGL context thread.
|
||||
window, err := glfw.CreateWindow(16, 16, "", nil, nil)
|
||||
if err != nil {
|
||||
@ -637,21 +593,6 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
|
||||
y := my + (v.Height-h)/3
|
||||
x, y = adjustWindowPosition(x, y)
|
||||
u.window.SetPos(x, y)
|
||||
|
||||
u.window.SetSizeCallback(func(_ *glfw.Window, width, height int) {
|
||||
go func() {
|
||||
w := int(float64(width) / u.scale)
|
||||
h := int(float64(height) / u.scale)
|
||||
_ = mainthread.Run(func() error {
|
||||
if u.fullscreen() {
|
||||
return nil
|
||||
}
|
||||
u.reqWidth = w
|
||||
u.reqHeight = h
|
||||
return nil
|
||||
})
|
||||
}()
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -772,17 +713,6 @@ func (u *userInterface) update(g GraphicsContext) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Update the screen size when the window is resizable.
|
||||
_ = mainthread.Run(func() error {
|
||||
w, h := u.reqWidth, u.reqHeight
|
||||
if w != 0 || h != 0 {
|
||||
u.setScreenSize(w, h, u.scale, u.fullscreen(), u.vsync)
|
||||
}
|
||||
u.reqWidth = 0
|
||||
u.reqHeight = 0
|
||||
return nil
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -839,13 +769,6 @@ func (u *userInterface) forceSetScreenSize(width, height int, scale float64, ful
|
||||
minWindowWidth = 1
|
||||
}
|
||||
|
||||
if width < 1 {
|
||||
width = 1
|
||||
}
|
||||
if height < 1 {
|
||||
height = 1
|
||||
}
|
||||
|
||||
u.width = width
|
||||
u.windowWidth = width
|
||||
s := scale * devicescale.GetAt(u.currentMonitor().GetPos())
|
||||
|
28
run.go
28
run.go
@ -310,8 +310,6 @@ func IsRunnableInBackground() bool {
|
||||
|
||||
// SetWindowDecorated sets the state if the window is decorated.
|
||||
//
|
||||
// The window is decorated by default.
|
||||
//
|
||||
// SetWindowDecorated works only on desktops.
|
||||
// SetWindowDecorated does nothing on other platforms.
|
||||
//
|
||||
@ -322,36 +320,14 @@ func SetWindowDecorated(decorated bool) {
|
||||
ui.SetWindowDecorated(decorated)
|
||||
}
|
||||
|
||||
// IsWindowDecorated reports whether the window is decorated.
|
||||
// IsWindowDecorated returns a boolean value indicating whether
|
||||
// the window is decorated.
|
||||
//
|
||||
// IsWindowDecorated is concurrent-safe.
|
||||
func IsWindowDecorated() bool {
|
||||
return ui.IsWindowDecorated()
|
||||
}
|
||||
|
||||
// SetWindowResizable sets the state if the window is resizable.
|
||||
//
|
||||
// The window is not resizable by default.
|
||||
//
|
||||
// When the window is resizable, the image size given via the update function can be changed by resizing.
|
||||
//
|
||||
// SetWindowResizable works only on desktops.
|
||||
// SetWindowResizable does nothing on other platforms.
|
||||
//
|
||||
// SetWindowResizable panics if SetWindowResizable is called after Run.
|
||||
//
|
||||
// SetWindowResizable is concurrent-safe.
|
||||
func SetWindowResizable(resizable bool) {
|
||||
ui.SetWindowResizable(resizable)
|
||||
}
|
||||
|
||||
// IsWindowResizable reports whether the window is resizable.
|
||||
//
|
||||
// IsWindowResizable is concurrent-safe.
|
||||
func IsWindowResizable() bool {
|
||||
return ui.IsWindowResizable()
|
||||
}
|
||||
|
||||
// SetRunnableInBackground sets the state if the game runs even in background.
|
||||
//
|
||||
// If the given value is true, the game runs in background e.g. when losing focus.
|
||||
|
Loading…
Reference in New Issue
Block a user