mirror of
https://github.com/neon443/DesktopGoose2.git
synced 2026-11-30 12:44:52 +00:00
minor refactoring
This commit is contained in:
5 files changed
+32
-20
No files matched your search
@@ -8,8 +8,7 @@
|
||||
import Foundation
|
||||
import Cocoa
|
||||
|
||||
class GooseWindow {
|
||||
private var window: NSWindow
|
||||
class GooseWindow: NSWindow {
|
||||
private var goose: Goose
|
||||
private var angle: CGFloat = 90
|
||||
var shown: Bool = false
|
||||
@@ -18,30 +17,31 @@ class GooseWindow {
|
||||
|
||||
init() {
|
||||
goose = Goose()
|
||||
self.window = NSWindow(
|
||||
contentRect: CGRect(x: 0, y: 0, width: NSScreen.main!.frame.width, height: NSScreen.main!.frame.width),
|
||||
super.init(
|
||||
contentRect: NSRect(x: 0, y: 0, width: NSScreen.main!.frame.width, height: NSScreen.main!.frame.height),
|
||||
styleMask: .borderless,
|
||||
backing: .buffered,
|
||||
defer: false
|
||||
)
|
||||
window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1)
|
||||
window.isOpaque = false
|
||||
window.level = NSWindow.Level.screenSaver + 1
|
||||
window.ignoresMouseEvents = true
|
||||
window.hasShadow = false
|
||||
window.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllApplications.union(.stationary).union(.canJoinAllSpaces)
|
||||
|
||||
self.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1)
|
||||
self.isOpaque = false
|
||||
self.level = NSWindow.Level.screenSaver + 1
|
||||
self.ignoresMouseEvents = true
|
||||
self.hasShadow = false
|
||||
self.collectionBehavior = NSWindow.CollectionBehavior.canJoinAllApplications.union(.stationary).union(.canJoinAllSpaces)
|
||||
|
||||
showHide()
|
||||
|
||||
// window.contentView?.addSubview(NSTextField(labelWithString: "hi"))
|
||||
window.contentView?.addSubview(goose.view)
|
||||
self.contentView?.addSubview(goose.view)
|
||||
}
|
||||
|
||||
func showHide() {
|
||||
if shown {
|
||||
window.orderOut(nil)
|
||||
self.orderOut(nil)
|
||||
} else {
|
||||
window.orderFront(nil)
|
||||
self.orderFront(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||