diff --git a/Box42.xcodeproj/project.pbxproj b/Box42.xcodeproj/project.pbxproj index e5bf7f2..309678c 100644 --- a/Box42.xcodeproj/project.pbxproj +++ b/Box42.xcodeproj/project.pbxproj @@ -68,12 +68,21 @@ DE874F542A591F1400FC3B77 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F532A591F1400FC3B77 /* PreferencesView.swift */; }; DE874F572A591F2500FC3B77 /* Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F562A591F2500FC3B77 /* Icon.swift */; }; DE874F5F2A5935CC00FC3B77 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE874F5E2A5935CC00FC3B77 /* String.swift */; }; + DE97CA692A9A6364001073DE /* PixelConversion+CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE97CA682A9A6364001073DE /* PixelConversion+CGFloat.swift */; }; + DE98E83B2A98DB6000F8744A /* RotateImage+NSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E83A2A98DB6000F8744A /* RotateImage+NSImage.swift */; }; + DE98E8432A98DDFD00F8744A /* QuickSlotViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E8422A98DDFD00F8744A /* QuickSlotViewController.swift */; }; + DE98E8472A98DE6D00F8744A /* QuickSlotHorizontalStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E8462A98DE6D00F8744A /* QuickSlotHorizontalStackView.swift */; }; + DE98E84B2A98E03800F8744A /* QuickSlotItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E84A2A98E03800F8744A /* QuickSlotItem.swift */; }; + DE98E8502A98E06300F8744A /* QuickSlotViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E84F2A98E06300F8744A /* QuickSlotViewModel.swift */; }; + DE98E8552A98EA7900F8744A /* WindowButtonUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE98E8542A98EA7900F8744A /* WindowButtonUI.swift */; }; DE9DA8142A97F20E001C0D3B /* ButtonGroupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE9DA8132A97F20E001C0D3B /* ButtonGroupViewController.swift */; }; DEB862D42A85124500278FCD /* cleanCache.sh in Resources */ = {isa = PBXBuildFile; fileRef = DEB862D32A85124500278FCD /* cleanCache.sh */; }; DEB862D92A852C4500278FCD /* brewInGoinfre.sh in Resources */ = {isa = PBXBuildFile; fileRef = DEB862D82A852C4500278FCD /* brewInGoinfre.sh */; }; DEB862DC2A85347400278FCD /* Scripts.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEB862DB2A85347400278FCD /* Scripts.swift */; }; DEB862EB2A853F7F00278FCD /* BoxWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEB862E92A853F7F00278FCD /* BoxWindowController.swift */; }; - DEE0FA9D2A9A56CB00085A65 /* FunctionButtonUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE0FA9C2A9A56CB00085A65 /* FunctionButtonUI.swift */; }; + DEE0FA822A99FC1000085A65 /* QuickSlotCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE0FA812A99FC1000085A65 /* QuickSlotCollectionView.swift */; }; + DEE0FA8B2A9A0BD500085A65 /* QuickSlotCollectionViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE0FA842A99FD1100085A65 /* QuickSlotCollectionViewItem.swift */; }; + DEE0FA962A9A554F00085A65 /* FunctionButtonUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEE0FA952A9A554F00085A65 /* FunctionButtonUI.swift */; }; DEF749322A85657600D987C8 /* NSScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEF749312A85657600D987C8 /* NSScreen.swift */; }; /* End PBXBuildFile section */ @@ -141,12 +150,21 @@ DE874F532A591F1400FC3B77 /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = ""; }; DE874F562A591F2500FC3B77 /* Icon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = ""; }; DE874F5E2A5935CC00FC3B77 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; + DE97CA682A9A6364001073DE /* PixelConversion+CGFloat.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PixelConversion+CGFloat.swift"; sourceTree = ""; }; + DE98E83A2A98DB6000F8744A /* RotateImage+NSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RotateImage+NSImage.swift"; sourceTree = ""; }; + DE98E8422A98DDFD00F8744A /* QuickSlotViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotViewController.swift; sourceTree = ""; }; + DE98E8462A98DE6D00F8744A /* QuickSlotHorizontalStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotHorizontalStackView.swift; sourceTree = ""; }; + DE98E84A2A98E03800F8744A /* QuickSlotItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotItem.swift; sourceTree = ""; }; + DE98E84F2A98E06300F8744A /* QuickSlotViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotViewModel.swift; sourceTree = ""; }; + DE98E8542A98EA7900F8744A /* WindowButtonUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowButtonUI.swift; sourceTree = ""; }; DE9DA8132A97F20E001C0D3B /* ButtonGroupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroupViewController.swift; sourceTree = ""; }; DEB862D32A85124500278FCD /* cleanCache.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = cleanCache.sh; sourceTree = ""; }; DEB862D82A852C4500278FCD /* brewInGoinfre.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = brewInGoinfre.sh; sourceTree = ""; }; DEB862DB2A85347400278FCD /* Scripts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Scripts.swift; path = Box42/Scripts/Scripts.swift; sourceTree = SOURCE_ROOT; }; DEB862E92A853F7F00278FCD /* BoxWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxWindowController.swift; sourceTree = ""; }; - DEE0FA9C2A9A56CB00085A65 /* FunctionButtonUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionButtonUI.swift; sourceTree = ""; }; + DEE0FA812A99FC1000085A65 /* QuickSlotCollectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotCollectionView.swift; sourceTree = ""; }; + DEE0FA842A99FD1100085A65 /* QuickSlotCollectionViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickSlotCollectionViewItem.swift; sourceTree = ""; }; + DEE0FA952A9A554F00085A65 /* FunctionButtonUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunctionButtonUI.swift; sourceTree = ""; }; DEF7492E2A85603700D987C8 /* nodeInstall.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = nodeInstall.sh; sourceTree = ""; }; DEF749312A85657600D987C8 /* NSScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSScreen.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -195,6 +213,7 @@ DE018C082A509BB500FF0AA3 /* WebView */, DEB862E82A853F6800278FCD /* WindowButton */, DE0A917D2A8F864300D1D6F1 /* Toolbar */, + DE98E8382A98D48700F8744A /* QuickSlot */, DE4407F82A923E5B0091937A /* FunctionButton */, ); path = Box42; @@ -321,7 +340,7 @@ DE4407F82A923E5B0091937A /* FunctionButton */ = { isa = PBXGroup; children = ( - DEE0FA9B2A9A56BD00085A65 /* Model */, + DEE0FA942A9A553A00085A65 /* Model */, DE4407FC2A923E920091937A /* View */, DE4407F92A923E860091937A /* BoxFunctionViewController.swift */, ); @@ -372,6 +391,51 @@ path = Preferences; sourceTree = ""; }; + DE98E8382A98D48700F8744A /* QuickSlot */ = { + isa = PBXGroup; + children = ( + DE98E84E2A98E04F00F8744A /* ViewModel */, + DE98E8492A98E02400F8744A /* Model */, + DE98E8412A98DDEB00F8744A /* View */, + DEE0FA872A9A022100085A65 /* Controller */, + ); + path = QuickSlot; + sourceTree = ""; + }; + DE98E8412A98DDEB00F8744A /* View */ = { + isa = PBXGroup; + children = ( + DE98E8462A98DE6D00F8744A /* QuickSlotHorizontalStackView.swift */, + DEE0FA812A99FC1000085A65 /* QuickSlotCollectionView.swift */, + ); + path = View; + sourceTree = ""; + }; + DE98E8492A98E02400F8744A /* Model */ = { + isa = PBXGroup; + children = ( + DEE0FA842A99FD1100085A65 /* QuickSlotCollectionViewItem.swift */, + DE98E84A2A98E03800F8744A /* QuickSlotItem.swift */, + ); + path = Model; + sourceTree = ""; + }; + DE98E84E2A98E04F00F8744A /* ViewModel */ = { + isa = PBXGroup; + children = ( + DE98E84F2A98E06300F8744A /* QuickSlotViewModel.swift */, + ); + path = ViewModel; + sourceTree = ""; + }; + DE98E8532A98EA4F00F8744A /* Model */ = { + isa = PBXGroup; + children = ( + DE98E8542A98EA7900F8744A /* WindowButtonUI.swift */, + ); + path = Model; + sourceTree = ""; + }; DE9DA8122A97F1E2001C0D3B /* ButtonGroup */ = { isa = PBXGroup; children = ( @@ -406,16 +470,25 @@ DEB862E82A853F6800278FCD /* WindowButton */ = { isa = PBXGroup; children = ( + DE98E8532A98EA4F00F8744A /* Model */, DE3FF36F2A978A6E009C88EF /* View */, DE3FF3692A978A57009C88EF /* WindowButtonViewController.swift */, ); path = WindowButton; sourceTree = ""; }; - DEE0FA9B2A9A56BD00085A65 /* Model */ = { + DEE0FA872A9A022100085A65 /* Controller */ = { + isa = PBXGroup; + children = ( + DE98E8422A98DDFD00F8744A /* QuickSlotViewController.swift */, + ); + path = Controller; + sourceTree = ""; + }; + DEE0FA942A9A553A00085A65 /* Model */ = { isa = PBXGroup; children = ( - DEE0FA9C2A9A56CB00085A65 /* FunctionButtonUI.swift */, + DEE0FA952A9A554F00085A65 /* FunctionButtonUI.swift */, ); path = Model; sourceTree = ""; @@ -428,6 +501,8 @@ DEF749312A85657600D987C8 /* NSScreen.swift */, DE1F1A302A8BD68F00A88DD8 /* Double.swift */, DE24E63A2A8FE93900E29F5D /* NSImage.swift */, + DE98E83A2A98DB6000F8744A /* RotateImage+NSImage.swift */, + DE97CA682A9A6364001073DE /* PixelConversion+CGFloat.swift */, ); path = Extensions; sourceTree = ""; @@ -517,6 +592,7 @@ DE0A917B2A8F0CA800D1D6F1 /* AppleScripts+ShowMessage.swift in Sources */, DE018BB82A5099F900FF0AA3 /* Box42.xcdatamodeld in Sources */, DE874F542A591F1400FC3B77 /* PreferencesView.swift in Sources */, + DE98E83B2A98DB6000F8744A /* RotateImage+NSImage.swift in Sources */, DE0A91982A8F977F00D1D6F1 /* ToolbarViewController.swift in Sources */, DE9DA8142A97F20E001C0D3B /* ButtonGroupViewController.swift in Sources */, DE4408082A9240300091937A /* BoxFunctionButtonView.swift in Sources */, @@ -524,8 +600,11 @@ DE3FF3A32A97D2A6009C88EF /* DisplayURLTextfield.swift in Sources */, DE77BA562A82637900713683 /* StateManager.swift in Sources */, DE1F1A1C2A8B50C500A88DD8 /* BoxBaseContainerViewController.swift in Sources */, + DEE0FA962A9A554F00085A65 /* FunctionButtonUI.swift in Sources */, DE018BE72A509B1E00FF0AA3 /* WebViewController.swift in Sources */, + DE98E8552A98EA7900F8744A /* WindowButtonUI.swift in Sources */, DE4407FA2A923E860091937A /* BoxFunctionViewController.swift in Sources */, + DE98E8472A98DE6D00F8744A /* QuickSlotHorizontalStackView.swift in Sources */, DE4407FE2A923EA90091937A /* PreferenceButtonView.swift in Sources */, DEF749322A85657600D987C8 /* NSScreen.swift in Sources */, DE018BF02A509B2F00FF0AA3 /* MenubarViewController.swift in Sources */, @@ -533,13 +612,16 @@ DE44080C2A924B520091937A /* BoxFunctionViewGroup.swift in Sources */, DE018BE42A509B1700FF0AA3 /* CPU.swift in Sources */, DE874F5F2A5935CC00FC3B77 /* String.swift in Sources */, + DEE0FA822A99FC1000085A65 /* QuickSlotCollectionView.swift in Sources */, DE0A91862A8F889F00D1D6F1 /* RefreshPageViaToolbar.swift in Sources */, DE874F4E2A591DEA00FC3B77 /* Hotkey.swift in Sources */, DE0A91832A8F889000D1D6F1 /* GoHomePageViaToolbar().swift in Sources */, DE018BB32A5099F900FF0AA3 /* AppDelegate.swift in Sources */, DE0A91632A8E6A5400D1D6F1 /* Constants.swift in Sources */, DE0A91902A8F88CA00D1D6F1 /* DisplayURLInToolbar.swift in Sources */, + DEE0FA8B2A9A0BD500085A65 /* QuickSlotCollectionViewItem.swift in Sources */, DE018BF32A509B3300FF0AA3 /* MenubarModel.swift in Sources */, + DE98E8502A98E06300F8744A /* QuickSlotViewModel.swift in Sources */, DE7A257A2A6D8CA20043225A /* PreferencesViewController.swift in Sources */, DE24E63B2A8FE93900E29F5D /* NSImage.swift in Sources */, DE0A916D2A8E7DD700D1D6F1 /* HoverButton.swift in Sources */, @@ -549,6 +631,7 @@ DE0A91672A8E6CA700D1D6F1 /* WebViewManager.swift in Sources */, DE4408152A92750D0091937A /* keyDown+BoxBaseContainerViewController.swift in Sources */, DE018BED2A509B2600FF0AA3 /* URLModel.swift in Sources */, + DE97CA692A9A6364001073DE /* PixelConversion+CGFloat.swift in Sources */, DE4408052A923EC00091937A /* QuitButtonView.swift in Sources */, DE0A918A2A8F88A900D1D6F1 /* GoForwardInToolbar.swift in Sources */, DE1F1A1E2A8B50C500A88DD8 /* BoxButtonViewGroup.swift in Sources */, @@ -561,10 +644,11 @@ DE1F1A1D2A8B50C500A88DD8 /* BoxContentsViewGroup.swift in Sources */, DE24E6352A8FE02A00E29F5D /* MovableContainerView.swift in Sources */, DE1F1A362A8BDDDF00A88DD8 /* StorageConfig.swift in Sources */, - DEE0FA9D2A9A56CB00085A65 /* FunctionButtonUI.swift in Sources */, DE2AD3292A824EEB00002D51 /* Accessibility.swift in Sources */, DE24E6382A8FE10400E29F5D /* BoxBaseSplitView.swift in Sources */, DE44081D2A928F760091937A /* TopDivider.swift in Sources */, + DE98E84B2A98E03800F8744A /* QuickSlotItem.swift in Sources */, + DE98E8432A98DDFD00F8744A /* QuickSlotViewController.swift in Sources */, DE874F572A591F2500FC3B77 /* Icon.swift in Sources */, DE1F1A2E2A8BCC9800A88DD8 /* Storage.swift in Sources */, DE0A91782A8F014F00D1D6F1 /* WebView.swift in Sources */, diff --git a/Box42/BoxWindowController.swift b/Box42/BoxWindowController.swift index 3a3babf..fe74981 100644 --- a/Box42/BoxWindowController.swift +++ b/Box42/BoxWindowController.swift @@ -10,7 +10,7 @@ import Cocoa class BoxWindowController: NSWindowController, NSWindowDelegate { override init(window: NSWindow?) { let contentRect = BoxSizeManager.shared.boxViewSizeNSRect - let styleMask: NSWindow.StyleMask = [.resizable, .titled, .fullSizeContentView, .closable, .miniaturizable] + let styleMask: NSWindow.StyleMask = [.resizable, .titled, .fullSizeContentView] let windowInstance = NSWindow(contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false) super.init(window: windowInstance) windowInstance.delegate = self @@ -20,6 +20,13 @@ class BoxWindowController: NSWindowController, NSWindowDelegate { windowInstance.titleVisibility = .hidden windowInstance.isReleasedWhenClosed = false windowInstance.isMovableByWindowBackground = true + windowInstance.standardWindowButton(.closeButton)?.isHidden = true + windowInstance.standardWindowButton(.miniaturizeButton)?.isHidden = true + windowInstance.standardWindowButton(.zoomButton)?.isHidden = true + + if let zoomButton = windowInstance.standardWindowButton(.zoomButton) { + zoomButton.isHidden = true + } let boxViewController = BoxBaseContainerViewController(nibName: nil, bundle: nil) windowInstance.contentViewController = boxViewController diff --git a/Box42/Extensions/NSScreen.swift b/Box42/Extensions/NSScreen.swift index 263a718..836bb71 100644 --- a/Box42/Extensions/NSScreen.swift +++ b/Box42/Extensions/NSScreen.swift @@ -8,13 +8,18 @@ import Cocoa extension NSScreen { + static let screenSize = NSScreen.main?.visibleFrame.size static let screenWidth = screenSize!.width static let screenHeight = screenSize!.height - 60 static let halfOfScreen = (x: screenWidth / 2, y: screenHeight / 2) - static let contentsScreenSize = CGSize(width: CGFloat(768), height: screenHeight) - static let buttonGroupSize = CGSize(width: CGFloat(200), height: screenHeight) - static let customScreenSize = contentsScreenSize + buttonGroupSize + + static var contentsScreenSize = CGSize(width: CGFloat(768).pointsToPixels(), height: screenHeight) + static let buttonGroupSize = CGSize(width: CGFloat(312).pointsToPixels(), height: screenHeight) + + static var customScreenSize: CGSize { + return contentsScreenSize + buttonGroupSize + } } func +(left: CGSize, right: CGSize) -> CGSize { diff --git a/Box42/Extensions/PixelConversion+CGFloat.swift b/Box42/Extensions/PixelConversion+CGFloat.swift new file mode 100644 index 0000000..9b4f762 --- /dev/null +++ b/Box42/Extensions/PixelConversion+CGFloat.swift @@ -0,0 +1,22 @@ +// +// PixelConversion+CGFloat.swift +// Box42 +// +// Created by Chanhee Kim on 8/27/23. +// + +import Cocoa + +extension CGFloat { + func pointsToPixels() -> CGFloat { + return self * 1.073 + } + + func pixelsToPoints() -> CGFloat { + return self / 1.073 + } + + static func onePixelInPoints() -> CGFloat { + return CGFloat(1).pixelsToPoints() + } +} diff --git a/Box42/Extensions/RotateImage+NSImage.swift b/Box42/Extensions/RotateImage+NSImage.swift new file mode 100644 index 0000000..1483e86 --- /dev/null +++ b/Box42/Extensions/RotateImage+NSImage.swift @@ -0,0 +1,28 @@ +// +// RotateImage+NSImage.swift +// Box42 +// +// Created by Chanhee Kim on 8/25/23. +// + +import Cocoa + +extension NSImage { + func rotated(by degrees: CGFloat) -> NSImage? { + guard let imgRep = self.bestRepresentation(for: NSRect(x: 0, y: 0, width: self.size.width, height: self.size.height), context: nil, hints: nil) else { + return nil + } + + let image = NSImage(size: self.size) + + image.lockFocus() + let ctx = NSGraphicsContext.current?.cgContext + ctx?.translateBy(x: size.width / 2, y: size.height / 2) + ctx?.rotate(by: (degrees * CGFloat.pi) / 180) + ctx?.translateBy(x: -size.width / 2, y: -size.height / 2) + imgRep.draw(in: NSRect(x: 0, y: 0, width: size.width, height: size.height)) + image.unlockFocus() + + return image + } +} diff --git a/Box42/Main/BoxBaseContainerViewController.swift b/Box42/Main/BoxBaseContainerViewController.swift index dcb6323..011e26c 100644 --- a/Box42/Main/BoxBaseContainerViewController.swift +++ b/Box42/Main/BoxBaseContainerViewController.swift @@ -12,6 +12,7 @@ class BoxBaseContainerViewController: NSViewController { var splitView: BoxBaseSplitView = BoxBaseSplitView() var contentGroup: BoxContentsViewGroup = BoxContentsViewGroup() var toolbarGroupVC: ToolbarViewController = ToolbarViewController() + // var quickSlotGroupVC: QuickSlotViewController = QuickSlotViewController() var functionGroupVC: BoxFunctionViewController = BoxFunctionViewController() let windowViewGroupVC: WindowButtonViewController = WindowButtonViewController() var leftContainer: MovableContainerView = MovableContainerView() @@ -31,7 +32,8 @@ class BoxBaseContainerViewController: NSViewController { override func viewDidLoad() { self.view.wantsLayer = true - self.view.layer?.backgroundColor = NSColor(hex: "#FF9548").cgColor +// self.view.layer?.backgroundColor = NSColor(hex: "#FF9548").cgColor + self.view.layer?.backgroundColor = NSColor(hex: "#E7E7E7").cgColor } func BoxButtonViewGroupInit() -> BoxButtonViewGroup { @@ -71,42 +73,48 @@ class BoxBaseContainerViewController: NSViewController { private func leftContainerInit() { leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width leftContainer.frame.size.height = BoxSizeManager.shared.windowButtonGroupSize.height -// leftContainer.addSubview(windowViewGroupVC.view) + leftContainer.addSubview(windowViewGroupVC.view) leftContainer.addSubview(buttonGroupVC.view) leftContainer.addSubview(toolbarGroupVC.view) +// leftContainer.addSubview(quickSlotGroupVC.view) leftContainer.addSubview(functionGroupVC.view) leftContainerAutolayout() } private func leftContainerAutolayout() { -// windowViewGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(leftContainer) -// make.left.equalTo(leftContainer).offset(3) -// make.width.equalTo(77) -// make.height.equalTo(21) -// } + windowViewGroupVC.view.snp.makeConstraints { make in + make.top.equalTo(leftContainer) + make.left.equalTo(leftContainer).offset(3) + make.width.equalTo(77) + make.height.equalTo(21) + } toolbarGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(windowViewGroupVC.view.snp.bottom).offset(31) - make.top.equalTo(leftContainer).offset(31) // wVGVC 없으면 + make.top.equalTo(windowViewGroupVC.view.snp.bottom).offset(31) make.right.equalTo(leftContainer) make.left.equalTo(leftContainer) make.height.equalTo(44 + 14 + 24) } - functionGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(buttonGroup.snp.bottom).offset(Constants.UI.groupAutolayout) - make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) - make.left.bottom.equalTo(leftContainer) - } - buttonGroupVC.view.snp.makeConstraints { make in make.top.equalTo(toolbarGroupVC.view.snp.bottom).offset(Constants.UI.groupAutolayout) make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) make.left.equalTo(leftContainer) make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-Constants.UI.groupAutolayout) } + +// quickSlotGroupVC.view.snp.makeConstraints { make in +// make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-27) +// make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) +// make.left.equalTo(leftContainer) +// make.height.equalTo(178) +// } + + functionGroupVC.view.snp.makeConstraints { make in + make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) + make.left.bottom.equalTo(leftContainer) + } } func viewInit() { @@ -134,14 +142,14 @@ extension BoxBaseContainerViewController: NSSplitViewDelegate { func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat { if dividerIndex == 0 { - return 132 + return CGFloat(132).pointsToPixels() } return proposedMinimumPosition } func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMaximumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat { if dividerIndex == 0 { - return 200 + return CGFloat(312).pointsToPixels() } return proposedMaximumPosition } diff --git a/Box42/Menubar/MenubarViewController.swift b/Box42/Menubar/MenubarViewController.swift index 2701716..e9b361c 100644 --- a/Box42/Menubar/MenubarViewController.swift +++ b/Box42/Menubar/MenubarViewController.swift @@ -42,7 +42,7 @@ class MenubarViewController: NSViewController { } func buttonInit() { - buttonImageChange("Fox") + buttonImageChange("fox") statusBarVM.statusButtonAppear() } diff --git a/Box42/Menubar/MenubarViewModel.swift b/Box42/Menubar/MenubarViewModel.swift index 5d23f10..b1daf88 100644 --- a/Box42/Menubar/MenubarViewModel.swift +++ b/Box42/Menubar/MenubarViewModel.swift @@ -25,13 +25,13 @@ class StatusBarViewModel { statusBar.frames.removeAll() switch imgName { - case "Cat": for i in (0...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "cat_page\(i)"))} + case "cat": for i in (0...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "cat_page\(i)"))} case "gon": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "gon_\(i)"))} case "gun": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "gun_\(i)"))} case "gam": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "gam_\(i)"))} case "lee": for i in (1...5) {statusBar.frames.append(NSImage(imageLiteralResourceName: "lee_\(i)"))} - case "Box": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42box_\(i)"))} - case "Fox": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "fox_page\(i)"))} + case "box": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42box_\(i)"))} + case "fox": for i in (1...4) {statusBar.frames.append(NSImage(imageLiteralResourceName: "fox_page\(i)"))} case "box_oc": for i in (1...2) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42box_oc\(i)"))} default : for i in (1...11) {statusBar.frames.append(NSImage(imageLiteralResourceName: "42flip_0\(i)"))} } diff --git a/Box42/Resources/AppDelegate.swift b/Box42/Resources/AppDelegate.swift index 26df5dd..9bde3d6 100644 --- a/Box42/Resources/AppDelegate.swift +++ b/Box42/Resources/AppDelegate.swift @@ -20,8 +20,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { menubarController.menubarViewControllerStart() // alertAccessibility() // hotkey() - storage.storageTimerEvent() - } + +// storage.storageTimerEvent() + } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application diff --git a/Box42/Shared/Constants.swift b/Box42/Shared/Constants.swift index 4484e4a..5e6347d 100644 --- a/Box42/Shared/Constants.swift +++ b/Box42/Shared/Constants.swift @@ -8,7 +8,8 @@ struct Constants { struct url { static let initialName = "home" - static let initialPage = "https://42box.github.io/front-end/" +// static let initialPage = "https://42box.kr" + static let initialPage = "https://profile.intra.42.fr/" } struct UI { diff --git a/Box42/WindowButton/Model/WindowButtonUI.swift b/Box42/WindowButton/Model/WindowButtonUI.swift new file mode 100644 index 0000000..a9e3bdc --- /dev/null +++ b/Box42/WindowButton/Model/WindowButtonUI.swift @@ -0,0 +1,27 @@ +// +// WindowButtonUI.swift +// Box42 +// +// Created by Chanhee Kim on 8/25/23. +// + +import AppKit + +struct WindowButtonUI { + struct size { + static let diameter = 15 + static let cornerRadius = CGFloat(diameter / 2) + static let offset = 8 + } + + struct animation { + static let duration = TimeInterval(0.2) + } + + struct color { + static let maximize = NSColor(hex: "#76DF7A").cgColor + static let minimize = NSColor(hex: "#FFCE51").cgColor + static let close = NSColor(hex: "#F36161").cgColor + static let opacityWhite = NSColor(hex: "#7FFFFFFF").cgColor + } +} diff --git a/Box42/WindowButton/View/WindowCloseButton.swift b/Box42/WindowButton/View/WindowCloseButton.swift index 84074b3..3b5d404 100644 --- a/Box42/WindowButton/View/WindowCloseButton.swift +++ b/Box42/WindowButton/View/WindowCloseButton.swift @@ -12,13 +12,13 @@ class WindowCloseButton: NSButton { private var callback: (() -> Void)? init(completion: @escaping () -> Void) { - super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + super.init(frame: NSRect(x: 0, y: 0, width: WindowButtonUI.size.diameter, height: WindowButtonUI.size.diameter)) self.title = "" self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = 21 / 2 - self.layer?.backgroundColor = NSColor.white.cgColor + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite self.target = self self.action = #selector(closeAction) self.callback = completion @@ -37,19 +37,41 @@ class WindowCloseButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.red.cgColor - }, completionHandler: nil) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.toValue = WindowButtonUI.color.close + bgColorAnimation.duration = WindowButtonUI.animation.duration + + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.close + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 } - + override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.close + bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.duration = WindowButtonUI.animation.duration - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.white.cgColor - }, completionHandler: nil) + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius } } diff --git a/Box42/WindowButton/View/WindowMaximizeButton.swift b/Box42/WindowButton/View/WindowMaximizeButton.swift index 5934059..f5a7f3c 100644 --- a/Box42/WindowButton/View/WindowMaximizeButton.swift +++ b/Box42/WindowButton/View/WindowMaximizeButton.swift @@ -12,13 +12,13 @@ class WindowMaximizeButton: NSButton { private var callback: (() -> Void)? init(completion: @escaping () -> Void) { - super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + super.init(frame: NSRect(x: 0, y: 0, width: WindowButtonUI.size.diameter, height: WindowButtonUI.size.diameter)) self.title = "" self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = 21 / 2 - self.layer?.backgroundColor = NSColor.white.cgColor + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite self.target = self self.action = #selector(maximizeAction) self.callback = completion @@ -37,19 +37,41 @@ class WindowMaximizeButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.green.cgColor - }, completionHandler: nil) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.toValue = WindowButtonUI.color.maximize + bgColorAnimation.duration = WindowButtonUI.animation.duration + + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.maximize + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 } - + override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.maximize + bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.duration = WindowButtonUI.animation.duration - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.white.cgColor - }, completionHandler: nil) + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius } } diff --git a/Box42/WindowButton/View/WindowMinimizeButton.swift b/Box42/WindowButton/View/WindowMinimizeButton.swift index c628742..4d6537c 100644 --- a/Box42/WindowButton/View/WindowMinimizeButton.swift +++ b/Box42/WindowButton/View/WindowMinimizeButton.swift @@ -12,13 +12,13 @@ class WindowMinimizeButton: NSButton { private var callback: (() -> Void)? init(completion: @escaping () -> Void) { - super.init(frame: NSRect(x: 0, y: 0, width: 21, height: 21)) + super.init(frame: NSRect(x: 0, y: 0, width: WindowButtonUI.size.diameter, height: WindowButtonUI.size.diameter)) self.title = "" self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = 21 / 2 - self.layer?.backgroundColor = NSColor.white.cgColor + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = WindowButtonUI.color.minimize self.target = self self.action = #selector(minimizeAction) self.callback = completion @@ -37,19 +37,41 @@ class WindowMinimizeButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.yellow.cgColor - }, completionHandler: nil) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.toValue = WindowButtonUI.color.minimize + bgColorAnimation.duration = WindowButtonUI.animation.duration + + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.minimize + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 } - + override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) + + let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") + bgColorAnimation.fromValue = WindowButtonUI.color.minimize + bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite + bgColorAnimation.duration = WindowButtonUI.animation.duration - NSAnimationContext.runAnimationGroup({ (context) in - context.duration = 2 - self.layer?.backgroundColor = NSColor.white.cgColor - }, completionHandler: nil) + let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") + cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 + cornerAnimation.toValue = WindowButtonUI.size.cornerRadius + cornerAnimation.duration = WindowButtonUI.animation.duration + + self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") + self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") + + self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius } } diff --git a/Box42/WindowButton/View/WindowViewGroup.swift b/Box42/WindowButton/View/WindowViewGroup.swift index 9891bcc..15ff801 100644 --- a/Box42/WindowButton/View/WindowViewGroup.swift +++ b/Box42/WindowButton/View/WindowViewGroup.swift @@ -40,22 +40,22 @@ class WindowViewGroup: NSView { windowClose.snp.makeConstraints { make in make.top.equalToSuperview() make.left.equalToSuperview() - make.width.equalTo(21) - make.height.equalTo(21) + make.width.equalTo(WindowButtonUI.size.diameter) + make.height.equalTo(WindowButtonUI.size.diameter) } windowMinimize.snp.makeConstraints { make in make.top.bottom.equalTo(windowClose) - make.left.equalTo(windowClose.snp.right).offset(7) - make.width.equalTo(21) - make.height.equalTo(21) + make.left.equalTo(windowClose.snp.right).offset(WindowButtonUI.size.offset) + make.width.equalTo(WindowButtonUI.size.diameter) + make.height.equalTo(WindowButtonUI.size.diameter) } windowMaximize.snp.makeConstraints { make in make.top.bottom.equalTo(windowClose) - make.left.equalTo(windowMinimize.snp.right).offset(7) - make.width.equalTo(21) - make.height.equalTo(21) + make.left.equalTo(windowMinimize.snp.right).offset(WindowButtonUI.size.offset) + make.width.equalTo(WindowButtonUI.size.diameter) + make.height.equalTo(WindowButtonUI.size.diameter) } } }