Add a native AppKit drag grip to the non-activating panel header; it accepts the first mouse and calls performDrag, so the panel can be moved before it becomes key. Keep a moved position while the panel stays visible and only recenter near the cursor when it is shown again (DeepL-like transient position). Add persisted translationFontSize (default 17 pt, range 12–28) to AppSettings and PanelConfiguration, apply it to the translation text, and expose a native Settings stepper. Add English/German strings and AppSettings clamp/round-trip tests. Verified: make verify green; synthetic double-copy opened the panel, dragging the grip moved the window, and a 22 pt capture showed the larger translation text.
31 lines
772 B
Swift
31 lines
772 B
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// An AppKit drag surface for the non-activating panel. SwiftUI's hosting view consumes mouse
|
|
/// events, so this view starts a native window drag on the first click.
|
|
struct WindowDragArea: NSViewRepresentable {
|
|
func makeNSView(context: Context) -> NSView {
|
|
DragView()
|
|
}
|
|
|
|
func updateNSView(_ nsView: NSView, context: Context) {}
|
|
}
|
|
|
|
private final class DragView: NSView {
|
|
override var mouseDownCanMoveWindow: Bool {
|
|
true
|
|
}
|
|
|
|
override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
|
|
true
|
|
}
|
|
|
|
override func mouseDown(with event: NSEvent) {
|
|
window?.performDrag(with: event)
|
|
}
|
|
|
|
override func resetCursorRects() {
|
|
addCursorRect(bounds, cursor: .openHand)
|
|
}
|
|
}
|