Update app and tooling

This commit is contained in:
Lawrence Chen 2026-01-29 17:36:26 -08:00
parent 3046531bdd
commit e620ec7349
4950 changed files with 2975120 additions and 10 deletions

59
Sources/Backport.swift Normal file
View file

@ -0,0 +1,59 @@
import SwiftUI
// Centralized backports for newer SwiftUI APIs we want to use when available.
struct Backport<Content> {
let content: Content
}
extension View {
var backport: Backport<Self> { Backport(content: self) }
}
extension Backport where Content: View {
func pointerStyle(_ style: BackportPointerStyle?) -> some View {
#if canImport(AppKit)
if #available(macOS 15, *) {
return content.pointerStyle(style?.official)
} else {
return content
}
#else
return content
#endif
}
}
enum BackportPointerStyle {
case `default`
case grabIdle
case grabActive
case horizontalText
case verticalText
case link
case resizeLeft
case resizeRight
case resizeUp
case resizeDown
case resizeUpDown
case resizeLeftRight
#if canImport(AppKit)
@available(macOS 15, *)
var official: PointerStyle {
switch self {
case .default: return .default
case .grabIdle: return .grabIdle
case .grabActive: return .grabActive
case .horizontalText: return .horizontalText
case .verticalText: return .verticalText
case .link: return .link
case .resizeLeft: return .frameResize(position: .trailing, directions: [.inward])
case .resizeRight: return .frameResize(position: .leading, directions: [.inward])
case .resizeUp: return .frameResize(position: .bottom, directions: [.inward])
case .resizeDown: return .frameResize(position: .top, directions: [.inward])
case .resizeUpDown: return .frameResize(position: .top)
case .resizeLeftRight: return .frameResize(position: .trailing)
}
}
#endif
}

View file

@ -1,3 +1,4 @@
import AppKit
import SwiftUI
/// A split view shows a left and right (or top and bottom) view with a divider in the middle to do resizing.
@ -141,6 +142,16 @@ private struct Divider: View {
let invisibleSize: CGFloat
let color: Color
@Binding var split: CGFloat
@State private var isHovering = false
private var pointerStyle: BackportPointerStyle {
switch direction {
case .horizontal:
return .resizeLeftRight
case .vertical:
return .resizeUpDown
}
}
var body: some View {
ZStack {
@ -155,6 +166,33 @@ private struct Divider: View {
}
.frame(width: direction == .horizontal ? invisibleSize : nil,
height: direction == .vertical ? invisibleSize : nil)
.contentShape(Rectangle())
.backport.pointerStyle(pointerStyle)
.onHover { hovering in
if #available(macOS 15, *) {
return
}
guard hovering != isHovering else { return }
isHovering = hovering
if hovering {
switch direction {
case .horizontal:
NSCursor.resizeLeftRight.push()
case .vertical:
NSCursor.resizeUpDown.push()
}
} else {
NSCursor.pop()
}
}
.onDisappear {
if #available(macOS 15, *) {
return
}
guard isHovering else { return }
isHovering = false
NSCursor.pop()
}
}
}

View file

@ -42,10 +42,10 @@ final class WindowDecorationsController {
if window.isSheet {
return true
}
if window is NSPanel {
if window.styleMask.contains(.docModalWindow) {
return true
}
if window.styleMask.contains(.utilityWindow) || window.styleMask.contains(.docModalWindow) {
if window.styleMask.contains(.nonactivatingPanel) {
return true
}
return false