mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
macOS: simple SplitView AX
Proper labels, action to move the divider
This commit is contained in:
@@ -7,6 +7,7 @@ extension SplitView {
|
||||
let visibleSize: CGFloat
|
||||
let invisibleSize: CGFloat
|
||||
let color: Color
|
||||
@Binding var split: CGFloat
|
||||
|
||||
private var visibleWidth: CGFloat? {
|
||||
switch (direction) {
|
||||
@@ -79,6 +80,40 @@ extension SplitView {
|
||||
NSCursor.pop()
|
||||
}
|
||||
}
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(axLabel)
|
||||
.accessibilityValue("\(Int(split * 100))%")
|
||||
.accessibilityHint(axHint)
|
||||
.accessibilityAddTraits(.isButton)
|
||||
.accessibilityAdjustableAction { direction in
|
||||
let adjustment: CGFloat = 0.025
|
||||
switch direction {
|
||||
case .increment:
|
||||
split = min(split + adjustment, 0.9)
|
||||
case .decrement:
|
||||
split = max(split - adjustment, 0.1)
|
||||
@unknown default:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var axLabel: String {
|
||||
switch direction {
|
||||
case .horizontal:
|
||||
return "Horizontal split divider"
|
||||
case .vertical:
|
||||
return "Vertical split divider"
|
||||
}
|
||||
}
|
||||
|
||||
private var axHint: String {
|
||||
switch direction {
|
||||
case .horizontal:
|
||||
return "Drag to resize the left and right panes"
|
||||
case .vertical:
|
||||
return "Drag to resize the top and bottom panes"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -42,16 +42,23 @@ struct SplitView<L: View, R: View>: View {
|
||||
left
|
||||
.frame(width: leftRect.size.width, height: leftRect.size.height)
|
||||
.offset(x: leftRect.origin.x, y: leftRect.origin.y)
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(leftPaneLabel)
|
||||
right
|
||||
.frame(width: rightRect.size.width, height: rightRect.size.height)
|
||||
.offset(x: rightRect.origin.x, y: rightRect.origin.y)
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(rightPaneLabel)
|
||||
Divider(direction: direction,
|
||||
visibleSize: splitterVisibleSize,
|
||||
invisibleSize: splitterInvisibleSize,
|
||||
color: dividerColor)
|
||||
color: dividerColor,
|
||||
split: $split)
|
||||
.position(splitterPoint)
|
||||
.gesture(dragGesture(geo.size, splitterPoint: splitterPoint))
|
||||
}
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel(splitViewLabel)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +144,35 @@ struct SplitView<L: View, R: View>: View {
|
||||
return CGPoint(x: size.width / 2, y: leftRect.size.height)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Accessibility
|
||||
|
||||
private var splitViewLabel: String {
|
||||
switch direction {
|
||||
case .horizontal:
|
||||
return "Horizontal split view"
|
||||
case .vertical:
|
||||
return "Vertical split view"
|
||||
}
|
||||
}
|
||||
|
||||
private var leftPaneLabel: String {
|
||||
switch direction {
|
||||
case .horizontal:
|
||||
return "Left pane"
|
||||
case .vertical:
|
||||
return "Top pane"
|
||||
}
|
||||
}
|
||||
|
||||
private var rightPaneLabel: String {
|
||||
switch direction {
|
||||
case .horizontal:
|
||||
return "Right pane"
|
||||
case .vertical:
|
||||
return "Bottom pane"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum SplitViewDirection: Codable {
|
||||
|
@@ -32,6 +32,8 @@ struct TerminalSplitSubtreeView: View {
|
||||
Ghostty.InspectableSurface(
|
||||
surfaceView: leafView,
|
||||
isSplit: !isRoot)
|
||||
.accessibilityElement(children: .contain)
|
||||
.accessibilityLabel("Terminal pane")
|
||||
|
||||
case .split(let split):
|
||||
let splitViewDirection: SplitViewDirection = switch (split.direction) {
|
||||
|
Reference in New Issue
Block a user