macos: move grab handle to separate file

This commit is contained in:
Mitchell Hashimoto
2025-12-27 12:51:26 -08:00
parent ad7460c256
commit b13ac575e6
2 changed files with 40 additions and 37 deletions

View File

@@ -0,0 +1,40 @@
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.white.opacity(isHovering || isDragging ? 0.15 : 0))
.frame(height: handleHeight)
.overlay(alignment: .center) {
if isHovering || isDragging {
Capsule()
.fill(Color.white.opacity(0.4))
.frame(width: 40, height: 4)
}
}
.contentShape(Rectangle())
.onHover { hovering in
withAnimation(.easeInOut(duration: 0.15)) {
isHovering = hovering
}
}
.backport.pointerStyle(isHovering ? .grabIdle : nil)
Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.draggable(surfaceView)
}
}
}

View File

@@ -956,43 +956,6 @@ extension Ghostty {
}
#endif
/// 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.white.opacity(isHovering || isDragging ? 0.15 : 0))
.frame(height: handleHeight)
.overlay(alignment: .center) {
if isHovering || isDragging {
Capsule()
.fill(Color.white.opacity(0.4))
.frame(width: 40, height: 4)
}
}
.contentShape(Rectangle())
.onHover { hovering in
withAnimation(.easeInOut(duration: 0.15)) {
isHovering = hovering
}
}
.backport.pointerStyle(isHovering ? .grabIdle : nil)
Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.draggable(surfaceView)
}
}
/// Visual overlay that shows a border around the edges when the bell rings with border feature enabled.
struct BellBorderOverlay: View {
let bell: Bool