mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: adjusted windows centering (update and setup window)
This commit is contained in:
@@ -41,7 +41,7 @@ internal class SetupWindow: NSWindow, NSWindowDelegate {
|
||||
self.delegate = self
|
||||
self.title = localizedString("Stats Setup")
|
||||
|
||||
self.center()
|
||||
self.positionCenter()
|
||||
self.setIsVisible(false)
|
||||
|
||||
let windowController = NSWindowController()
|
||||
@@ -60,6 +60,13 @@ internal class SetupWindow: NSWindow, NSWindowDelegate {
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
self.finishHandler()
|
||||
}
|
||||
|
||||
private func positionCenter() {
|
||||
self.setFrameOrigin(NSPoint(
|
||||
x: (NSScreen.main!.frame.width - self.view.frame.width)/2,
|
||||
y: (NSScreen.main!.frame.height - self.view.frame.height)/2
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
private class SetupContainer: NSStackView {
|
||||
|
||||
@@ -16,12 +16,10 @@ class UpdateWindow: NSWindow, NSWindowDelegate {
|
||||
private let viewController: UpdateViewController = UpdateViewController()
|
||||
|
||||
init() {
|
||||
let w = NSScreen.main!.frame.width
|
||||
let h = NSScreen.main!.frame.height
|
||||
super.init(
|
||||
contentRect: NSRect(
|
||||
x: w - self.viewController.view.frame.width,
|
||||
y: h - self.viewController.view.frame.height,
|
||||
x: NSScreen.main!.frame.width - self.viewController.view.frame.width,
|
||||
y: NSScreen.main!.frame.height - self.viewController.view.frame.height,
|
||||
width: self.viewController.view.frame.width,
|
||||
height: self.viewController.view.frame.height
|
||||
),
|
||||
@@ -33,7 +31,7 @@ class UpdateWindow: NSWindow, NSWindowDelegate {
|
||||
self.title = "Stats"
|
||||
self.contentViewController = self.viewController
|
||||
self.titlebarAppearsTransparent = true
|
||||
self.center()
|
||||
self.positionCenter()
|
||||
self.setIsVisible(false)
|
||||
|
||||
let windowController = NSWindowController()
|
||||
@@ -48,6 +46,13 @@ class UpdateWindow: NSWindow, NSWindowDelegate {
|
||||
}
|
||||
self.viewController.open(v)
|
||||
}
|
||||
|
||||
private func positionCenter() {
|
||||
self.setFrameOrigin(NSPoint(
|
||||
x: (NSScreen.main!.frame.width - self.viewController.view.frame.width)/2,
|
||||
y: (NSScreen.main!.frame.height - self.viewController.view.frame.height)/2
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
private class UpdateViewController: NSViewController {
|
||||
|
||||
Reference in New Issue
Block a user