feat(ui): pre-board, board and post-board in one vertical scroller

The board canvas used to fill the remaining height and centre itself, pinning
the pre-board strip above and the post-board strip below — so a tall pre/post
chain clipped instead of scrolling, and the three sections never read as one
signal path. Wrap pre-board → board → post-board in a single vertical
ScrollView so the whole path scrolls top-to-bottom as one page, on macOS and
iOS alike. The transport / palette / routing header stays fixed above it.

BoardFlowView gains a `sizesToContent` mode: it sizes to its chain height and
scrolls only horizontally, so it nests inside the outer vertical scroller with
no competing vertical scroll (a tall parallel split simply grows the page).
The default fill-and-centre behaviour is unchanged for any other caller.

Verified on the iPad simulator: sections stack in signal-flow order and the
board still scrolls horizontally through a long chain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 14:15:41 -08:00
parent 4cae1e6fd0
commit 3f05cfa416
2 changed files with 58 additions and 30 deletions
+23 -2
View File
@@ -63,6 +63,12 @@ public struct BoardFlowView: View {
private let shoeGaze: ShoeGaze private let shoeGaze: ShoeGaze
private let boardIndex: Int private let boardIndex: Int
/// When `true`, the view sizes to its content height and scrolls only horizontally, so it can sit
/// inside an outer vertical scroller (the pre-board → board → post-board page) without a nested
/// vertical scroll. When `false` (the default), it fills the available height and centres the
/// chain, adding a vertical scroll only for tall parallel splits.
private let sizesToContent: Bool
/// Undo coordinator injected by ``ShoeGazeBuilderView``; `nil` in lightweight hosts (previews), /// Undo coordinator injected by ``ShoeGazeBuilderView``; `nil` in lightweight hosts (previews),
/// where edits run directly without recording history. /// where edits run directly without recording history.
@Environment(UndoCoordinator.self) private var undo: UndoCoordinator? @Environment(UndoCoordinator.self) private var undo: UndoCoordinator?
@@ -74,9 +80,10 @@ public struct BoardFlowView: View {
/// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal. /// lanes exceed the viewport height (tall parallel splits). Otherwise scrolling stays horizontal.
@State private var contentHeight: CGFloat = 0 @State private var contentHeight: CGFloat = 0
public init(shoeGaze: ShoeGaze, boardIndex: Int) { public init(shoeGaze: ShoeGaze, boardIndex: Int, sizesToContent: Bool = false) {
self.shoeGaze = shoeGaze self.shoeGaze = shoeGaze
self.boardIndex = boardIndex self.boardIndex = boardIndex
self.sizesToContent = sizesToContent
} }
// MARK: - Body // MARK: - Body
@@ -91,9 +98,22 @@ public struct BoardFlowView: View {
} }
} }
@ViewBuilder
private func flow(board: PedalBoard) -> some View { private func flow(board: PedalBoard) -> some View {
let stages: [StageModel] = stageModels(board: board) let stages: [StageModel] = stageModels(board: board)
return GeometryReader { proxy in if sizesToContent {
// One-scroller mode: the board is only as tall as its chain and scrolls horizontally,
// so the outer vertical scroller flows pre-board → board → post-board as one page with
// no nested vertical scroll. A tall parallel split simply makes the page taller.
ScrollView(.horizontal, showsIndicators: true) {
chainRow(board: board, stages: stages)
}
.frame(height: contentHeight > 0 ? contentHeight : nil)
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
contentHeight = height
}
} else {
GeometryReader { proxy in
let viewportHeight: CGFloat = proxy.size.height let viewportHeight: CGFloat = proxy.size.height
// Lock to horizontal, adding the vertical axis only when the chain is taller than the // Lock to horizontal, adding the vertical axis only when the chain is taller than the
// viewport (deep parallel splits) so it can be reached instead of clipped. // viewport (deep parallel splits) so it can be reached instead of clipped.
@@ -118,6 +138,7 @@ public struct BoardFlowView: View {
} }
} }
} }
}
/// The left→right chain of endpoints, connectors and stage cards. Reports its own intrinsic /// The left→right chain of endpoints, connectors and stage cards. Reports its own intrinsic
/// height through `BoardFlowContentHeightKey` so `flow` can decide whether vertical scrolling is /// height through `BoardFlowContentHeightKey` so `flow` can decide whether vertical scrolling is
@@ -726,10 +726,19 @@ public struct ShoeGazeBuilderView: View {
} }
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
ControlMappingLegend() ControlMappingLegend()
// Pre-board, the board canvas and post-board share a single vertical scroller, so the whole
// signal path reads top-to-bottom as one page (on macOS and iOS alike) instead of pinning
// the board and clipping the pre/post strips.
ScrollView(.vertical, showsIndicators: true) {
VStack(alignment: .leading, spacing: ShoeGazeBuilderView.sectionSpacing) {
preBoardStrip preBoardStrip
boardArea boardArea
postBoardStrip postBoardStrip
} }
.frame(maxWidth: .infinity, alignment: .topLeading)
}
.frame(maxHeight: .infinity)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
// Make the undo coordinator reachable to every board / palette subview so their structural // Make the undo coordinator reachable to every board / palette subview so their structural
// edits record history. Optional-object injection: `nil` resolves `@Environment(...)` to nil. // edits record history. Optional-object injection: `nil` resolves `@Environment(...)` to nil.
@@ -1598,13 +1607,11 @@ public struct ShoeGazeBuilderView: View {
// MARK: - Board area // MARK: - Board area
private var boardArea: some View { private var boardArea: some View {
// Vertically center the signal-flow board in the available space. // Content-sized so it flows inside the shared pre/board/post vertical scroller (scrolls
VStack(spacing: 0) { // horizontally for a long chain; a tall parallel split grows the page). No vertical centering —
Spacer(minLength: 0) // the board sits in signal-flow order between the pre-board and post-board strips.
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex) BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex, sizesToContent: true)
Spacer(minLength: 0) .frame(maxWidth: .infinity, alignment: .leading)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
} }
/// Performs a routing action from the palette against the selected board. /// Performs a routing action from the palette against the selected board.