mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
macos: remove the unused resizeEvent code from SplitView
This commit is contained in:
@@ -43,7 +43,6 @@ struct TerminalSplitSubtreeView: View {
|
||||
}),
|
||||
dividerColor: ghostty.config.splitDividerColor,
|
||||
resizeIncrements: .init(width: 1, height: 1),
|
||||
resizePublisher: .init(),
|
||||
left: {
|
||||
TerminalSplitSubtreeView(node: split.left, onResize: onResize)
|
||||
},
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
/// A split view shows a left and right (or top and bottom) view with a divider in the middle to do resizing.
|
||||
/// The terminlogy "left" and "right" is always used but for vertical splits "left" is "top" and "right" is "bottom".
|
||||
@@ -13,12 +12,10 @@ struct SplitView<L: View, R: View>: View {
|
||||
/// Divider color
|
||||
let dividerColor: Color
|
||||
|
||||
/// If set, the split view supports programmatic resizing via events sent via the publisher.
|
||||
/// Minimum increment (in points) that this split can be resized by, in
|
||||
/// each direction. Both `height` and `width` should be whole numbers
|
||||
/// greater than or equal to 1.0
|
||||
let resizeIncrements: NSSize
|
||||
let resizePublisher: PassthroughSubject<Double, Never>
|
||||
|
||||
/// The left and right views to render.
|
||||
let left: L
|
||||
@@ -55,37 +52,15 @@ struct SplitView<L: View, R: View>: View {
|
||||
.position(splitterPoint)
|
||||
.gesture(dragGesture(geo.size, splitterPoint: splitterPoint))
|
||||
}
|
||||
.onReceive(resizePublisher) { value in
|
||||
resize(for: geo.size, amount: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize a split view. This view isn't programmatically resizable; it can only be resized
|
||||
/// by manually dragging the divider.
|
||||
init(_ direction: SplitViewDirection,
|
||||
_ split: Binding<CGFloat>,
|
||||
dividerColor: Color,
|
||||
@ViewBuilder left: (() -> L),
|
||||
@ViewBuilder right: (() -> R)) {
|
||||
self.init(
|
||||
direction,
|
||||
split,
|
||||
dividerColor: dividerColor,
|
||||
resizeIncrements: .init(width: 1, height: 1),
|
||||
resizePublisher: .init(),
|
||||
left: left,
|
||||
right: right
|
||||
)
|
||||
}
|
||||
|
||||
/// Initialize a split view that supports programmatic resizing.
|
||||
/// Initialize a split view that can be resized by manually dragging the divider.
|
||||
init(
|
||||
_ direction: SplitViewDirection,
|
||||
_ split: Binding<CGFloat>,
|
||||
dividerColor: Color,
|
||||
resizeIncrements: NSSize,
|
||||
resizePublisher: PassthroughSubject<Double, Never>,
|
||||
resizeIncrements: NSSize = .init(width: 1, height: 1),
|
||||
@ViewBuilder left: (() -> L),
|
||||
@ViewBuilder right: (() -> R)
|
||||
) {
|
||||
@@ -93,25 +68,10 @@ struct SplitView<L: View, R: View>: View {
|
||||
self._split = split
|
||||
self.dividerColor = dividerColor
|
||||
self.resizeIncrements = resizeIncrements
|
||||
self.resizePublisher = resizePublisher
|
||||
self.left = left()
|
||||
self.right = right()
|
||||
}
|
||||
|
||||
private func resize(for size: CGSize, amount: Double) {
|
||||
let dim: CGFloat
|
||||
switch (direction) {
|
||||
case .horizontal:
|
||||
dim = size.width
|
||||
case .vertical:
|
||||
dim = size.height
|
||||
}
|
||||
|
||||
let pos = split * dim
|
||||
let new = min(max(minSize, pos + amount), dim - minSize)
|
||||
split = new / dim
|
||||
}
|
||||
|
||||
private func dragGesture(_ size: CGSize, splitterPoint: CGPoint) -> some Gesture {
|
||||
return DragGesture()
|
||||
.onChanged { gesture in
|
||||
|
Reference in New Issue
Block a user