From 6f3f373f20dd8b619284c5a4059b4ae7eb9168fc Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Tue, 13 Oct 2026 17:18:41 +0200 Subject: [PATCH] fix: optically center shortcut glyphs and tighten badge gaps --- README.md | 2 +- .../Conjure/LauncherWindowController.swift | 29 +++++++++---------- .../Conjure/UninstallReviewController.swift | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 131505c..29b5e93 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Select an application and open **Actions ⌘K**. **Open** is the first, default- The red **Uninstall application** action morphs the existing launcher into a file-review screen with checkboxes, paths, sizes, and a selected-item count; it does not create another window or review sheet. A native 180-millisecond resize and content crossfade runs in both directions, or switches immediately with Reduce Motion. The filter uses a centered, intrinsic-height text field without built-in search/cancel icons, beside an explicit back chevron. Filtering files by name or path does not change file selections. Up/Down or Control-K/Control-J highlights files; Return toggles the highlighted eligible file, including from the filter input, and Space also toggles when the list has focus. Back or Escape restores the original launcher frame, query, and selection. Temporary review geometry is not saved as the launcher position. Leaving is blocked during confirmation or an uninstall operation. Command-Return or the uninstall button opens a native final confirmation dialog; nothing is moved merely by entering review. The confirmation control uses the launcher's frosted rounded pill with separate Command and Return key badges. The launcher Actions control likewise shows separate Command and K badges matching its Open Return badge. -Keyboard file toggles update the existing checkbox without reloading or fading the list, preserving both the highlighted row and scroll position. The launcher's footer Open and Actions labels and their shortcut badges share 12-point medium text. Launcher and uninstall footer badges use square 18×18-point containers with horizontally and vertically centered text. Multi-key footer badges have a small gap between their outlines rather than touching. +Keyboard file toggles update the existing checkbox without reloading or fading the list, preserving both the highlighted row and scroll position. The launcher's footer Open and Actions labels and their shortcut badges share 12-point medium text. Launcher and uninstall footer badges use square 18×18-point containers, centering the visible glyph outlines rather than the font's line box. Adjacent key badges have a 4-point gap between their outlines. The actions selector is an arrowless panel inside the launcher, aligned to the bottom and right edges of the footer action pill, replacing it visually while open rather than floating above it. It shares the launcher's frosted Sunset background, 38-point selection row height, 22×22-point icon boxes with 12-point icon-to-text spacing, 14-point action and search text, rounded selection styling, and Return key badge; selection width follows the panel. Application and command rows use the same sizing constants. SF Symbol optical alignment insets are removed so command icons render inside the same bounds as application icons. The application name appears at the top and borderless action search sits eight points from the bottom, without a divider. Native animations crossfade the panel and footer pill: 160 milliseconds to open and 120 milliseconds to close, with unchanged geometry. Reduce Motion disables the animation. Rapid reopening invalidates stale dismissal completions, and closing panels immediately stop intercepting input. Escape, Command-K, an outside click, or switching away closes it and restores the pill. Closing while Conjure remains active restores launcher search focus; switching away does not steal focus back. Return in action search executes the highlighted action: Open launches the application, while Uninstall opens its review. diff --git a/Sources/Conjure/LauncherWindowController.swift b/Sources/Conjure/LauncherWindowController.swift index a1c8ce3..274411d 100644 --- a/Sources/Conjure/LauncherWindowController.swift +++ b/Sources/Conjure/LauncherWindowController.swift @@ -1,5 +1,6 @@ import AppKit import ConjureKit +import CoreText @MainActor final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSearchFieldDelegate, NSTableViewDataSource, NSTableViewDelegate { @@ -321,7 +322,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe actionsButton.leadingAnchor.constraint(equalTo: returnKey.trailingAnchor, constant: 14), commandKey.leadingAnchor.constraint(equalTo: actionsButton.trailingAnchor, constant: 8), commandKey.centerYAnchor.constraint(equalTo: actionPill.centerYAnchor), - kKey.leadingAnchor.constraint(equalTo: commandKey.trailingAnchor, constant: 8), + kKey.leadingAnchor.constraint(equalTo: commandKey.trailingAnchor, constant: 4), kKey.centerYAnchor.constraint(equalTo: actionPill.centerYAnchor), kKey.trailingAnchor.constraint(equalTo: actionPill.trailingAnchor, constant: -12), actionsButton.centerYAnchor.constraint(equalTo: actionPill.centerYAnchor), @@ -724,22 +725,20 @@ func shortcutBadge(_ title: String) -> NSTextField { @MainActor private final class ShortcutBadge: NSTextField { - override class var cellClass: AnyClass? { - get { ShortcutBadgeCell.self } - set { super.cellClass = newValue } - } - // NSTextField's horizontal alignment insets otherwise make an 18-point badge 22 points wide. override var alignmentRectInsets: NSEdgeInsets { NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } -} -@MainActor -private final class ShortcutBadgeCell: NSTextFieldCell { - override func drawingRect(forBounds rect: NSRect) -> NSRect { - var textRect = super.drawingRect(forBounds: rect) - let textHeight = cellSize(forBounds: rect).height - textRect.origin.y += (textRect.height - textHeight) / 2 - textRect.size.height = textHeight - return textRect + override func draw(_ dirtyRect: NSRect) { + guard let context = NSGraphicsContext.current?.cgContext else { return } + let line = CTLineCreateWithAttributedString(attributedStringValue) + let ink = CTLineGetBoundsWithOptions(line, .useGlyphPathBounds) + context.saveGState() + context.textMatrix = .identity + // Center visible ink, not the font's asymmetric ascender/descender line box. + context.translateBy(x: bounds.midX - ink.midX, y: bounds.midY + ink.midY) + context.scaleBy(x: 1, y: -1) + context.textPosition = .zero + CTLineDraw(line, context) + context.restoreGState() } } diff --git a/Sources/Conjure/UninstallReviewController.swift b/Sources/Conjure/UninstallReviewController.swift index 84d9938..22af0bf 100644 --- a/Sources/Conjure/UninstallReviewController.swift +++ b/Sources/Conjure/UninstallReviewController.swift @@ -130,7 +130,7 @@ final class UninstallReviewController: NSViewController, NSSearchFieldDelegate, remove.centerYAnchor.constraint(equalTo: pill.centerYAnchor), commandKey.leadingAnchor.constraint(equalTo: remove.trailingAnchor, constant: 8), commandKey.centerYAnchor.constraint(equalTo: pill.centerYAnchor), - returnKey.leadingAnchor.constraint(equalTo: commandKey.trailingAnchor, constant: 8), + returnKey.leadingAnchor.constraint(equalTo: commandKey.trailingAnchor, constant: 4), returnKey.centerYAnchor.constraint(equalTo: pill.centerYAnchor), returnKey.trailingAnchor.constraint(equalTo: pill.trailingAnchor, constant: -12) ])