From 3f05cfa41629a28beff4fae0c3b5d6301b902a2b Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Thu, 26 Nov 2026 14:15:41 -0800 Subject: [PATCH] feat(ui): pre-board, board and post-board in one vertical scroller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../LyrebirdShoeGazeUI/BoardFlowView.swift | 61 +++++++++++++------ .../ShoeGazeBuilderView.swift | 27 +++++--- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/Sources/LyrebirdShoeGazeUI/BoardFlowView.swift b/Sources/LyrebirdShoeGazeUI/BoardFlowView.swift index 09e2465..d013a53 100644 --- a/Sources/LyrebirdShoeGazeUI/BoardFlowView.swift +++ b/Sources/LyrebirdShoeGazeUI/BoardFlowView.swift @@ -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 + } + } } } diff --git a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift index bb8cede..fcbb792 100644 --- a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift +++ b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift @@ -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.