feat: adjusted windows centering (update and setup window)

This commit is contained in:
Serhiy Mytrovtsiy
2023-02-09 22:02:18 +01:00
parent 06151f49dd
commit f647abca42
2 changed files with 18 additions and 6 deletions

View File

@@ -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 {

View File

@@ -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 {