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
+41 -20
View File
@@ -63,6 +63,12 @@ public struct BoardFlowView: View {
private let shoeGaze: ShoeGaze
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),
/// where edits run directly without recording history.
@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.
@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.boardIndex = boardIndex
self.sizesToContent = sizesToContent
}
// MARK: - Body
@@ -91,31 +98,45 @@ public struct BoardFlowView: View {
}
}
@ViewBuilder
private func flow(board: PedalBoard) -> some View {
let stages: [StageModel] = stageModels(board: board)
return GeometryReader { proxy in
let viewportHeight: CGFloat = proxy.size.height
// 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.
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
? [.horizontal, .vertical]
: .horizontal
ScrollView(axes, showsIndicators: true) {
// The spacers centre the chain vertically when it is shorter than the viewport; when
// it overflows, the min-height floor is already exceeded so they collapse to zero and
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
// longer stretches them.
VStack(spacing: 0) {
Spacer(minLength: 0)
chainRow(board: board, stages: stages)
Spacer(minLength: 0)
}
.frame(minHeight: viewportHeight)
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(maxWidth: .infinity, maxHeight: .infinity)
.frame(height: contentHeight > 0 ? contentHeight : nil)
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
contentHeight = height
}
} else {
GeometryReader { proxy in
let viewportHeight: CGFloat = proxy.size.height
// 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.
let axes: Axis.Set = contentHeight > viewportHeight + BoardFlowView.verticalScrollSlack
? [.horizontal, .vertical]
: .horizontal
ScrollView(axes, showsIndicators: true) {
// The spacers centre the chain vertically when it is shorter than the viewport; when
// it overflows, the min-height floor is already exceeded so they collapse to zero and
// the chain scrolls. Pedals keep their intrinsic height either way — the window no
// longer stretches them.
VStack(spacing: 0) {
Spacer(minLength: 0)
chainRow(board: board, stages: stages)
Spacer(minLength: 0)
}
.frame(minHeight: viewportHeight)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onPreferenceChange(BoardFlowContentHeightKey.self) { height in
contentHeight = height
}
}
}
}
@@ -726,9 +726,18 @@ public struct ShoeGazeBuilderView: View {
}
Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity))
ControlMappingLegend()
preBoardStrip
boardArea
postBoardStrip
// 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
boardArea
postBoardStrip
}
.frame(maxWidth: .infinity, alignment: .topLeading)
}
.frame(maxHeight: .infinity)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
// Make the undo coordinator reachable to every board / palette subview so their structural
@@ -1598,13 +1607,11 @@ public struct ShoeGazeBuilderView: View {
// MARK: - Board area
private var boardArea: some View {
// Vertically center the signal-flow board in the available space.
VStack(spacing: 0) {
Spacer(minLength: 0)
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex)
Spacer(minLength: 0)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
// Content-sized so it flows inside the shared pre/board/post vertical scroller (scrolls
// horizontally for a long chain; a tall parallel split grows the page). No vertical centering —
// the board sits in signal-flow order between the pre-board and post-board strips.
BoardFlowView(shoeGaze: shoeGaze, boardIndex: clampedBoardIndex, sizesToContent: true)
.frame(maxWidth: .infinity, alignment: .leading)
}
/// Performs a routing action from the palette against the selected board.