macOS: equalize splits when double tapping on SplitView divider
parent
0d5ecc7713
commit
e298620828
|
|
@ -21,6 +21,9 @@ struct SplitView<L: View, R: View>: View {
|
|||
let left: L
|
||||
let right: R
|
||||
|
||||
/// Called when the divider is double-tapped to equalize splits.
|
||||
let onEqualize: () -> Void
|
||||
|
||||
/// The minimum size (in points) of a split
|
||||
let minSize: CGFloat = 10
|
||||
|
||||
|
|
@ -56,6 +59,9 @@ struct SplitView<L: View, R: View>: View {
|
|||
split: $split)
|
||||
.position(splitterPoint)
|
||||
.gesture(dragGesture(geo.size, splitterPoint: splitterPoint))
|
||||
.onTapGesture(count: 2) {
|
||||
onEqualize()
|
||||
}
|
||||
}
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(splitViewLabel)
|
||||
|
|
@ -69,7 +75,8 @@ struct SplitView<L: View, R: View>: View {
|
|||
dividerColor: Color,
|
||||
resizeIncrements: NSSize = .init(width: 1, height: 1),
|
||||
@ViewBuilder left: (() -> L),
|
||||
@ViewBuilder right: (() -> R)
|
||||
@ViewBuilder right: (() -> R),
|
||||
onEqualize: @escaping () -> Void
|
||||
) {
|
||||
self.direction = direction
|
||||
self._split = split
|
||||
|
|
@ -77,6 +84,7 @@ struct SplitView<L: View, R: View>: View {
|
|||
self.resizeIncrements = resizeIncrements
|
||||
self.left = left()
|
||||
self.right = right()
|
||||
self.onEqualize = onEqualize
|
||||
}
|
||||
|
||||
private func dragGesture(_ size: CGSize, splitterPoint: CGPoint) -> some Gesture {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ struct TerminalSplitSubtreeView: View {
|
|||
},
|
||||
right: {
|
||||
TerminalSplitSubtreeView(node: split.right, onResize: onResize)
|
||||
},
|
||||
onEqualize: {
|
||||
guard let surface = node.leftmostLeaf().surface else { return }
|
||||
ghostty.splitEqualize(surface: surface)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ extension Ghostty {
|
|||
InspectorViewRepresentable(surfaceView: surfaceView)
|
||||
.focused($inspectorFocus)
|
||||
.focusedValue(\.ghosttySurfaceView, surfaceView)
|
||||
}, onEqualize: {
|
||||
guard let surface = surfaceView.surface else { return }
|
||||
ghostty.splitEqualize(surface: surface)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue