mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 21:40:29 +00:00
42 lines
1.5 KiB
Swift
42 lines
1.5 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
extension Ghostty {
|
|
/// A grab handle overlay at the top of the surface for dragging the window.
|
|
/// Only appears when hovering in the top region of the surface.
|
|
struct SurfaceGrabHandle: View {
|
|
private let handleHeight: CGFloat = 10
|
|
|
|
let surfaceView: SurfaceView
|
|
|
|
@State private var isHovering: Bool = false
|
|
@State private var isDragging: Bool = false
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
Rectangle()
|
|
.fill(Color.primary.opacity(isHovering || isDragging ? 0.15 : 0))
|
|
.frame(height: handleHeight)
|
|
.overlay(alignment: .center) {
|
|
if isHovering || isDragging {
|
|
Image(systemName: "ellipsis")
|
|
.font(.system(size: 14, weight: .semibold))
|
|
.foregroundColor(.primary.opacity(0.5))
|
|
}
|
|
}
|
|
.contentShape(Rectangle())
|
|
.overlay {
|
|
SurfaceDragSource(
|
|
surfaceView: surfaceView,
|
|
isDragging: $isDragging,
|
|
isHovering: $isHovering
|
|
)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
}
|
|
}
|
|
}
|