fix: use native close-only window decorations for notes
This commit is contained in:
@@ -76,6 +76,8 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
defer: false
|
||||
)
|
||||
window.title = "Conjure"
|
||||
window.titleVisibility = .hidden
|
||||
window.titlebarAppearsTransparent = true
|
||||
window.animationBehavior = .none
|
||||
window.appearance = NSAppearance(named: .darkAqua)
|
||||
window.backgroundColor = .clear
|
||||
@@ -238,6 +240,11 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
alignmentGuides?.update(for: window)
|
||||
}
|
||||
|
||||
func windowShouldClose(_ sender: NSWindow) -> Bool {
|
||||
dismiss()
|
||||
return false
|
||||
}
|
||||
|
||||
func windowDidResignKey(_ notification: Notification) {
|
||||
(window as? LauncherPanel)?.resetNumberHints()
|
||||
guard !isLaunching, launcherFrameBeforeReview == nil, window?.attachedSheet == nil else { return }
|
||||
@@ -907,6 +914,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
self.launcherViews.first?.isHidden = false
|
||||
self.launcherViews.first?.setAccessibilityHidden(false)
|
||||
if command == .notes, let previousFrame {
|
||||
self.window?.styleMask = [.borderless]
|
||||
self.window?.setFrame(previousFrame, display: true)
|
||||
if let material = content as? NSVisualEffectView { roundMaterialCorners(material, radius: 24) }
|
||||
}
|
||||
@@ -945,6 +953,9 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
)
|
||||
searchField.setAccessibilityLabel(accessibilityLabel)
|
||||
if command == .notes {
|
||||
window?.styleMask = [.titled, .closable, .fullSizeContentView]
|
||||
window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||
window?.standardWindowButton(.zoomButton)?.isHidden = true
|
||||
launcherViews.first?.isHidden = true
|
||||
launcherViews.first?.setAccessibilityHidden(true)
|
||||
if var frame = window?.frame {
|
||||
|
||||
@@ -45,21 +45,6 @@ final class NotesController: NSViewController, NSTextViewDelegate {
|
||||
let content = NotesView()
|
||||
content.commandShortcut = { [weak self] in self?.handleCommandKey($0) ?? false }
|
||||
view = content
|
||||
let close = iconButton("circle.fill", label: "Close notes", action: #selector(closeWindow))
|
||||
close.contentTintColor = SunsetPalette.accent
|
||||
close.isBordered = false
|
||||
close.image = close.image?.withSymbolConfiguration(.init(paletteColors: [SunsetPalette.accent]))
|
||||
let lights = NSStackView(views: [close])
|
||||
lights.spacing = 8
|
||||
for _ in 0..<2 {
|
||||
let dot = NSView()
|
||||
dot.wantsLayer = true
|
||||
dot.layer?.backgroundColor = SunsetPalette.secondaryText.withAlphaComponent(0.18).cgColor
|
||||
dot.layer?.cornerRadius = 6
|
||||
dot.setAccessibilityElement(false)
|
||||
NSLayoutConstraint.activate([dot.widthAnchor.constraint(equalToConstant: 12), dot.heightAnchor.constraint(equalToConstant: 12)])
|
||||
lights.addArrangedSubview(dot)
|
||||
}
|
||||
browseButton.target = self
|
||||
browseButton.action = #selector(browseNotes)
|
||||
configureIcon(browseButton, symbol: "note.text", label: "Browse notes (⌘P)")
|
||||
@@ -76,16 +61,15 @@ final class NotesController: NSViewController, NSTextViewDelegate {
|
||||
noteTitle.lineBreakMode = .byTruncatingTail
|
||||
noteTitle.setAccessibilityLabel("Note title")
|
||||
let header = NSView()
|
||||
for control in [lights, noteTitle, controls] {
|
||||
for control in [noteTitle, controls] {
|
||||
control.translatesAutoresizingMaskIntoConstraints = false
|
||||
header.addSubview(control)
|
||||
control.centerYAnchor.constraint(equalTo: header.centerYAnchor).isActive = true
|
||||
}
|
||||
NSLayoutConstraint.activate([
|
||||
lights.leadingAnchor.constraint(equalTo: header.leadingAnchor, constant: 10),
|
||||
controls.trailingAnchor.constraint(equalTo: header.trailingAnchor, constant: -8),
|
||||
noteTitle.centerXAnchor.constraint(equalTo: header.centerXAnchor),
|
||||
noteTitle.leadingAnchor.constraint(greaterThanOrEqualTo: lights.trailingAnchor, constant: 16),
|
||||
noteTitle.leadingAnchor.constraint(greaterThanOrEqualTo: header.leadingAnchor, constant: 44),
|
||||
noteTitle.trailingAnchor.constraint(lessThanOrEqualTo: controls.leadingAnchor, constant: -16),
|
||||
])
|
||||
actions.closed = { [weak self] in self?.focusEditor() }
|
||||
@@ -202,10 +186,6 @@ final class NotesController: NSViewController, NSTextViewDelegate {
|
||||
return button
|
||||
}
|
||||
|
||||
@objc private func closeWindow() {
|
||||
guard save() else { return }
|
||||
view.window?.performClose(nil)
|
||||
}
|
||||
|
||||
@objc private func toggleFormatting(_ sender: NSButton) {
|
||||
formatting.isHidden.toggle()
|
||||
|
||||
Reference in New Issue
Block a user