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
@@ -288,6 +288,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -303,8 +304,9 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.s;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DesktopDuck;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
@@ -321,6 +323,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -336,8 +339,9 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 13;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.s;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.neon443.DesktopDuck;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
REGISTER_APP_GROUPS = YES;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// s
|
||||
// DesktopDuck
|
||||
//
|
||||
// Created by neon443 on 11/09/2025.
|
||||
//
|
||||
@@ -9,12 +9,14 @@ import Cocoa
|
||||
|
||||
@main
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
var gooseWindow: GooseWindow?
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
// Insert code here to initialize your application
|
||||
// let window = NSWindow(contentRect: NSScreen.main!.frame, styleMask: .borderless, backing: .buffered, defer: false)
|
||||
// window.backgroundColor = .init(srgbRed: 1, green: 1, blue: 1, alpha: 0.1)
|
||||
// window.orderFront(nil)
|
||||
let x = GooseWindow()
|
||||
gooseWindow = GooseWindow()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
||||
@@ -25,7 +25,8 @@ class Goose: NSViewController {
|
||||
}
|
||||
|
||||
func setup() {
|
||||
gooseView.frame = NSRect(x: 100, y: 100, width: 25, height: 25)
|
||||
gooseView.translatesAutoresizingMaskIntoConstraints = false
|
||||
gooseView.frame = NSRect(x: 100, y: 100, width: 50, height: 50)
|
||||
self.view.addSubview(gooseView)
|
||||
|
||||
let bodyView = NSImageView(image: NSImage(named: "body")!)
|
||||
@@ -41,10 +42,15 @@ class Goose: NSViewController {
|
||||
gooseView.addSubview(neckView)
|
||||
neckView.translatesAutoresizingMaskIntoConstraints = false
|
||||
neckView.rotate(byDegrees: 90)
|
||||
neckView.frame = NSRect(x: 0, y: 0, width: 30, height: 30)
|
||||
NSLayoutConstraint.activate([
|
||||
neckView.widthAnchor.constraint(equalToConstant: 25),
|
||||
neckView.heightAnchor.constraint(equalToConstant: 25)
|
||||
neckView.leftAnchor.constraint(equalTo: bodyView.leftAnchor),
|
||||
neckView.bottomAnchor.constraint(equalTo: bodyView.bottomAnchor),
|
||||
neckView.widthAnchor.constraint(equalToConstant: 30),
|
||||
neckView.heightAnchor.constraint(equalToConstant: 30)
|
||||
])
|
||||
bodyView.alphaValue = 0.5
|
||||
neckView.alphaValue = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.