mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/ui: refactoring: remove unused members from EbitengineWindowDelegate
Closes #2297
This commit is contained in:
parent
9bc571af5e
commit
1d487be57b
@ -98,6 +98,11 @@ type userInterfaceImpl struct {
|
|||||||
initScreenTransparent bool
|
initScreenTransparent bool
|
||||||
initFocused bool
|
initFocused bool
|
||||||
|
|
||||||
|
origWindowPosX int
|
||||||
|
origWindowPosY int
|
||||||
|
origWindowWidthInDIP int
|
||||||
|
origWindowHeightInDIP int
|
||||||
|
|
||||||
fpsModeInited bool
|
fpsModeInited bool
|
||||||
|
|
||||||
input Input
|
input Input
|
||||||
@ -112,8 +117,6 @@ type userInterfaceImpl struct {
|
|||||||
// t is the main thread == the rendering thread.
|
// t is the main thread == the rendering thread.
|
||||||
t thread.Thread
|
t thread.Thread
|
||||||
m sync.RWMutex
|
m sync.RWMutex
|
||||||
|
|
||||||
native userInterfaceImplNative
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -137,8 +140,9 @@ func init() {
|
|||||||
initWindowHeightInDIP: 480,
|
initWindowHeightInDIP: 480,
|
||||||
initFocused: true,
|
initFocused: true,
|
||||||
fpsMode: FPSModeVsyncOn,
|
fpsMode: FPSModeVsyncOn,
|
||||||
|
origWindowPosX: invalidPos,
|
||||||
|
origWindowPosY: invalidPos,
|
||||||
}
|
}
|
||||||
theUI.native.initialize()
|
|
||||||
theUI.input.ui = &theUI.userInterfaceImpl
|
theUI.input.ui = &theUI.userInterfaceImpl
|
||||||
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
||||||
}
|
}
|
||||||
@ -1709,3 +1713,21 @@ func (u *userInterfaceImpl) forceToRefreshIfNeeded() {
|
|||||||
func (u *userInterfaceImpl) isWindowMaximized() bool {
|
func (u *userInterfaceImpl) isWindowMaximized() bool {
|
||||||
return u.window.GetAttrib(glfw.Maximized) == glfw.True && !u.isNativeFullscreen()
|
return u.window.GetAttrib(glfw.Maximized) == glfw.True && !u.isNativeFullscreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *userInterfaceImpl) origWindowPos() (int, int) {
|
||||||
|
return u.origWindowPosX, u.origWindowPosY
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *userInterfaceImpl) setOrigWindowPos(x, y int) {
|
||||||
|
u.origWindowPosX = x
|
||||||
|
u.origWindowPosY = y
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *userInterfaceImpl) origWindowSizeInDIP() (int, int) {
|
||||||
|
return u.origWindowWidthInDIP, u.origWindowHeightInDIP
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *userInterfaceImpl) setOrigWindowSizeInDIP(width, height int) {
|
||||||
|
u.origWindowWidthInDIP = width
|
||||||
|
u.origWindowHeightInDIP = height
|
||||||
|
}
|
||||||
|
@ -23,10 +23,6 @@ package ui
|
|||||||
// #import <AppKit/AppKit.h>
|
// #import <AppKit/AppKit.h>
|
||||||
//
|
//
|
||||||
// @interface EbitengineWindowDelegate : NSObject <NSWindowDelegate>
|
// @interface EbitengineWindowDelegate : NSObject <NSWindowDelegate>
|
||||||
// // origPos is the window's original position. This is valid only when the application is in the fullscreen mode.
|
|
||||||
// @property CGPoint origPos;
|
|
||||||
// // origSize is the window's original size.
|
|
||||||
// @property CGSize origSize;
|
|
||||||
// @end
|
// @end
|
||||||
//
|
//
|
||||||
// @implementation EbitengineWindowDelegate {
|
// @implementation EbitengineWindowDelegate {
|
||||||
@ -86,8 +82,6 @@ package ui
|
|||||||
// - (void)windowWillEnterFullScreen:(NSNotification *)notification {
|
// - (void)windowWillEnterFullScreen:(NSNotification *)notification {
|
||||||
// NSWindow* window = (NSWindow*)[notification object];
|
// NSWindow* window = (NSWindow*)[notification object];
|
||||||
// [self pushResizableState:window];
|
// [self pushResizableState:window];
|
||||||
// self->_origPos = [window frame].origin;
|
|
||||||
// self->_origSize = [window frame].size;
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// - (void)windowDidEnterFullScreen:(NSNotification *)notification {
|
// - (void)windowDidEnterFullScreen:(NSNotification *)notification {
|
||||||
@ -191,40 +185,6 @@ package ui
|
|||||||
// [window setBackgroundColor: [NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:0]];
|
// [window setBackgroundColor: [NSColor colorWithSRGBRed:0 green:0 blue:0 alpha:0]];
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// static void windowOriginalPosition(uintptr_t windowPtr, int* x, int* y) {
|
|
||||||
// NSWindow* window = (NSWindow*)windowPtr;
|
|
||||||
// EbitengineWindowDelegate* delegate = (EbitengineWindowDelegate*)window.delegate;
|
|
||||||
// CGPoint pos = delegate.origPos;
|
|
||||||
// *x = pos.x;
|
|
||||||
// *y = pos.y;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static void setWindowOriginalPosition(uintptr_t windowPtr, int x, int y) {
|
|
||||||
// NSWindow* window = (NSWindow*)windowPtr;
|
|
||||||
// EbitengineWindowDelegate* delegate = (EbitengineWindowDelegate*)window.delegate;
|
|
||||||
// CGPoint pos;
|
|
||||||
// pos.x = x;
|
|
||||||
// pos.y = y;
|
|
||||||
// delegate.origPos = pos;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static void windowOriginalSize(uintptr_t windowPtr, int* width, int* height) {
|
|
||||||
// NSWindow* window = (NSWindow*)windowPtr;
|
|
||||||
// EbitengineWindowDelegate* delegate = (EbitengineWindowDelegate*)window.delegate;
|
|
||||||
// CGSize size = delegate.origSize;
|
|
||||||
// *width = size.width;
|
|
||||||
// *height = size.height;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static void setWindowOriginalSize(uintptr_t windowPtr, int width, int height) {
|
|
||||||
// NSWindow* window = (NSWindow*)windowPtr;
|
|
||||||
// EbitengineWindowDelegate* delegate = (EbitengineWindowDelegate*)window.delegate;
|
|
||||||
// CGSize size;
|
|
||||||
// size.width = width;
|
|
||||||
// size.height = height;
|
|
||||||
// delegate.origSize = size;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static void setNativeCursor(int cursorID) {
|
// static void setNativeCursor(int cursorID) {
|
||||||
// id cursor = [[NSCursor class] performSelector:@selector(arrowCursor)];
|
// id cursor = [[NSCursor class] performSelector:@selector(arrowCursor)];
|
||||||
// switch (cursorID) {
|
// switch (cursorID) {
|
||||||
@ -306,8 +266,6 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|||||||
// clearVideoModeScaleCache must be called from the main thread.
|
// clearVideoModeScaleCache must be called from the main thread.
|
||||||
func clearVideoModeScaleCache() {}
|
func clearVideoModeScaleCache() {}
|
||||||
|
|
||||||
type userInterfaceImplNative struct{}
|
|
||||||
|
|
||||||
// dipFromGLFWMonitorPixel must be called from the main thread.
|
// dipFromGLFWMonitorPixel must be called from the main thread.
|
||||||
func (u *userInterfaceImpl) dipFromGLFWMonitorPixel(x float64, monitor *glfw.Monitor) float64 {
|
func (u *userInterfaceImpl) dipFromGLFWMonitorPixel(x float64, monitor *glfw.Monitor) float64 {
|
||||||
return x
|
return x
|
||||||
@ -411,43 +369,3 @@ func initializeWindowAfterCreation(w *glfw.Window) {
|
|||||||
// Enable resizing temporary before making the window fullscreen.
|
// Enable resizing temporary before making the window fullscreen.
|
||||||
C.initializeWindow(C.uintptr_t(w.GetCocoaWindow()))
|
C.initializeWindow(C.uintptr_t(w.GetCocoaWindow()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowPos() (int, int) {
|
|
||||||
if !u.isNativeFullscreen() {
|
|
||||||
return invalidPos, invalidPos
|
|
||||||
}
|
|
||||||
var cx, cy C.int
|
|
||||||
C.windowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), &cx, &cy)
|
|
||||||
x := int(cx)
|
|
||||||
_, h := u.origWindowSizeInDIP()
|
|
||||||
y := flipY(int(cy)) - h
|
|
||||||
return x, y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowPos(x, y int) {
|
|
||||||
if !u.isNativeFullscreen() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
cx := C.int(x)
|
|
||||||
_, h := u.origWindowSizeInDIP()
|
|
||||||
cy := C.int(flipY(y + h))
|
|
||||||
C.setWindowOriginalPosition(C.uintptr_t(u.window.GetCocoaWindow()), cx, cy)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowSizeInDIP() (int, int) {
|
|
||||||
// TODO: Make these values consistent with the original positions that are updated only when the app is in fullscreen.
|
|
||||||
var cw, ch C.int
|
|
||||||
C.windowOriginalSize(C.uintptr_t(u.window.GetCocoaWindow()), &cw, &ch)
|
|
||||||
w := int(u.dipFromGLFWPixel(float64(cw), u.currentMonitor()))
|
|
||||||
h := int(u.dipFromGLFWPixel(float64(ch), u.currentMonitor()))
|
|
||||||
return w, h
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowSizeInDIP(width, height int) {
|
|
||||||
cw := C.int(u.dipFromGLFWPixel(float64(width), u.currentMonitor()))
|
|
||||||
ch := C.int(u.dipFromGLFWPixel(float64(height), u.currentMonitor()))
|
|
||||||
C.setWindowOriginalSize(C.uintptr_t(u.window.GetCocoaWindow()), cw, ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImplNative) initialize() {
|
|
||||||
}
|
|
||||||
|
@ -142,13 +142,6 @@ func videoModeScaleUncached(m *glfw.Monitor) float64 {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
type userInterfaceImplNative struct {
|
|
||||||
origWindowPosX int
|
|
||||||
origWindowPosY int
|
|
||||||
origWindowWidthInDIP int
|
|
||||||
origWindowHeightInDIP int
|
|
||||||
}
|
|
||||||
|
|
||||||
// dipFromGLFWMonitorPixel must be called from the main thread.
|
// dipFromGLFWMonitorPixel must be called from the main thread.
|
||||||
func (u *userInterfaceImpl) dipFromGLFWMonitorPixel(x float64, monitor *glfw.Monitor) float64 {
|
func (u *userInterfaceImpl) dipFromGLFWMonitorPixel(x float64, monitor *glfw.Monitor) float64 {
|
||||||
return x / (videoModeScale(monitor) * u.deviceScaleFactor(monitor))
|
return x / (videoModeScale(monitor) * u.deviceScaleFactor(monitor))
|
||||||
@ -237,26 +230,3 @@ func initializeWindowAfterCreation(w *glfw.Window) {
|
|||||||
// Apparently the window state is inconsistent just after the window is created, but we are not sure.
|
// Apparently the window state is inconsistent just after the window is created, but we are not sure.
|
||||||
// For more details, see the discussion in #1829.
|
// For more details, see the discussion in #1829.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowPos() (int, int) {
|
|
||||||
return u.native.origWindowPosX, u.native.origWindowPosY
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowPos(x, y int) {
|
|
||||||
u.native.origWindowPosX = x
|
|
||||||
u.native.origWindowPosY = y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowSizeInDIP() (int, int) {
|
|
||||||
return u.native.origWindowWidthInDIP, u.native.origWindowHeightInDIP
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowSizeInDIP(width, height int) {
|
|
||||||
u.native.origWindowWidthInDIP = width
|
|
||||||
u.native.origWindowHeightInDIP = height
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImplNative) initialize() {
|
|
||||||
u.origWindowPosX = invalidPos
|
|
||||||
u.origWindowPosY = invalidPos
|
|
||||||
}
|
|
||||||
|
@ -62,13 +62,6 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type userInterfaceImplNative struct {
|
|
||||||
origWindowPosX int
|
|
||||||
origWindowPosY int
|
|
||||||
origWindowWidthInDIP int
|
|
||||||
origWindowHeightInDIP int
|
|
||||||
}
|
|
||||||
|
|
||||||
// clearVideoModeScaleCache must be called from the main thread.
|
// clearVideoModeScaleCache must be called from the main thread.
|
||||||
func clearVideoModeScaleCache() {}
|
func clearVideoModeScaleCache() {}
|
||||||
|
|
||||||
@ -193,26 +186,3 @@ func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode)
|
|||||||
|
|
||||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowPos() (int, int) {
|
|
||||||
return u.native.origWindowPosX, u.native.origWindowPosY
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowPos(x, y int) {
|
|
||||||
u.native.origWindowPosX = x
|
|
||||||
u.native.origWindowPosY = y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) origWindowSizeInDIP() (int, int) {
|
|
||||||
return u.native.origWindowWidthInDIP, u.native.origWindowHeightInDIP
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) setOrigWindowSizeInDIP(width, height int) {
|
|
||||||
u.native.origWindowWidthInDIP = width
|
|
||||||
u.native.origWindowHeightInDIP = height
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImplNative) initialize() {
|
|
||||||
u.origWindowPosX = invalidPos
|
|
||||||
u.origWindowPosY = invalidPos
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user