From 6e299b9d381443da71b913f8b8909100f5344f8c Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Sat, 27 Jun 2026 20:11:18 -0700 Subject: [PATCH] Rework builder layout: scope beside stacked mixer + horizontal pedal picker Reclaim vertical space in ShoeGazeBuilderView. The top section now places the scope + CPU meters on the left (width matched to the mixer's Solo/Blend/All control column) and a right column that stacks the board mixer over a horizontal pedal picker. The board canvas takes the full width below. - PedalPaletteView gains an `axis` parameter: `.vertical` keeps the full-width sidebar column; `.horizontal` lays the catalog out as a row of fixed-width cards for a horizontal scroller. - Remove the old left palette sidebar and the stacked-under-palette scope. Co-Authored-By: Claude Opus 4.8 --- .../LyrebirdShoeGazeUI/PedalPaletteView.swift | 51 +++++++++++- .../ShoeGazeBuilderView.swift | 79 +++++++++++-------- 2 files changed, 97 insertions(+), 33 deletions(-) diff --git a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift index 3335f24..04aead2 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift @@ -45,6 +45,8 @@ public struct PedalPaletteView: View { private static let rowSubtitleSpacing: CGFloat = 2 /// Opacity of the pedal-row description subtitle. private static let summaryOpacity: Double = 0.55 + /// Fixed card width when laid out horizontally (the vertical layout stretches to fill instead). + private static let horizontalCardWidth: CGFloat = 150 /// Preferred display order for the built-in pedals. Any registered pedal not listed here is /// appended afterwards (sorted) so the palette never silently drops a newly added pedal. @@ -74,19 +76,25 @@ public struct PedalPaletteView: View { private let onAdd: (String) -> Void private let onRouting: (RoutingAction) -> Void + private let axis: Axis // MARK: - Init /// Creates a pedal palette. /// /// - Parameters: + /// - axis: `.vertical` (default) lays the catalog out as a full-width column for a sidebar; + /// `.horizontal` lays it out as a fixed-width-card row for a horizontal scroller. The host + /// wraps the view in a `ScrollView` of the matching axis. /// - onAdd: Invoked with a pedal's `displayName` when its row is tapped (append to main chain). /// Rows are also `.draggable` carrying `"add:"` for drop-onto-lane targeting. /// - onRouting: Invoked when a routing row is tapped. Defaults to a no-op. public init( + axis: Axis = .vertical, onAdd: @escaping (String) -> Void, onRouting: @escaping (RoutingAction) -> Void = { _ in } ) { + self.axis = axis self.onAdd = onAdd self.onRouting = onRouting } @@ -104,6 +112,14 @@ public struct PedalPaletteView: View { // MARK: - Body public var body: some View { + switch axis { + case .horizontal: horizontalBody + default: verticalBody + } + } + + /// Full-width column for a left sidebar. + private var verticalBody: some View { VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) { VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { sectionTitle("PEDALS") @@ -121,6 +137,22 @@ public struct PedalPaletteView: View { } } + /// Fixed-width-card row for a horizontal scroller: leading PEDALS group, a divider, then the + /// ROUTING group. + private var horizontalBody: some View { + HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) { + sectionTitle("PEDALS") + ForEach(orderedPedalNames, id: \.self) { name in + pedalRow(name) + } + Divider().overlay(Color.white.opacity(PedalPaletteView.cardBorderOpacity)) + sectionTitle("ROUTING") + ForEach(PedalPaletteView.routingOptions, id: \.title) { option in + routingCard(title: option.title, caption: option.caption, action: option.action) + } + } + } + // MARK: - Subviews private func sectionTitle(_ text: String) -> some View { @@ -158,7 +190,7 @@ public struct PedalPaletteView: View { } .padding(.horizontal, PedalPaletteView.cardPaddingH) .padding(.vertical, PedalPaletteView.cardPaddingV) - .frame(maxWidth: .infinity, alignment: .leading) + .modifier(CardFrame(axis: axis, width: PedalPaletteView.horizontalCardWidth)) .background(cardBackground(brightness: PedalPaletteView.pedalCardBrightness)) } .buttonStyle(.plain) @@ -180,12 +212,27 @@ public struct PedalPaletteView: View { } .padding(.horizontal, PedalPaletteView.cardPaddingH) .padding(.vertical, PedalPaletteView.cardPaddingV) - .frame(maxWidth: .infinity, alignment: .leading) + .modifier(CardFrame(axis: axis, width: PedalPaletteView.horizontalCardWidth)) .background(cardBackground(brightness: PedalPaletteView.routingCardBrightness)) } .buttonStyle(.plain) } + /// Stretches a card to fill width in a vertical column, or pins it to a fixed width in a + /// horizontal row. + private struct CardFrame: ViewModifier { + let axis: Axis + let width: CGFloat + func body(content: Content) -> some View { + switch axis { + case .horizontal: + content.frame(width: width, alignment: .leading) + default: + content.frame(maxWidth: .infinity, alignment: .leading) + } + } + } + private func cardBackground(brightness: Double) -> some View { RoundedRectangle(cornerRadius: PedalPaletteView.cardCornerRadius) .fill(Color(white: brightness)) diff --git a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift index abf475f..48c58e0 100644 --- a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift +++ b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift @@ -43,6 +43,9 @@ public struct ShoeGazeBuilderView: View { private static let minWidth: CGFloat = 720 private static let minHeight: CGFloat = 460 private static let sidebarWidth: CGFloat = 168 + /// Width of the scope/CPU block in the bottom strip — matches `BoardBarView`'s Solo/Blend/All + /// control column so the scope aligns under it. + private static let scopeWidth: CGFloat = 188 private static let columnSpacing: CGFloat = 14 private static let backgroundRed: Double = 0.08 private static let backgroundGreen: Double = 0.07 @@ -268,7 +271,8 @@ public struct ShoeGazeBuilderView: View { ) } - /// The main builder column: transport, IO, boards, palette, board area, scope, and status. + /// The main builder column: transport, IO, the scope-plus-mixer/picker top section, then the + /// board canvas. private var builderColumn: some View { VStack(alignment: .leading, spacing: ShoeGazeBuilderView.sectionSpacing) { transportRow @@ -277,28 +281,54 @@ public struct ShoeGazeBuilderView: View { recordingRow #endif Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) - BoardBarView( - shoeGaze: shoeGaze, - editingBoardIndex: $selectedBoardIndex, - crossfadeSeconds: $crossfadeSeconds, - onAddBoard: { addBoard() } - ) + topSection Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) - HStack(alignment: .top, spacing: ShoeGazeBuilderView.columnSpacing) { - paletteSidebar - Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) - boardArea - } - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) - // Scope + CPU meters sit under the pedal palette, matching its width. - ShoeGazeScopeView(shoeGaze: shoeGaze) - .frame(width: ShoeGazeBuilderView.sidebarWidth, alignment: .leading) - LyrebirdStatusView(engine: shoeGaze.engine) - .frame(width: ShoeGazeBuilderView.sidebarWidth, alignment: .leading) + boardArea } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) } + /// Top section: the scope + CPU meters on the left (sized to align with the mixer's + /// Solo/Blend/All control column), and a right column stacking the board mixer over the + /// horizontal pedal picker. + private var topSection: some View { + HStack(alignment: .top, spacing: ShoeGazeBuilderView.columnSpacing) { + VStack(alignment: .leading, spacing: ShoeGazeBuilderView.rowSpacing) { + ShoeGazeScopeView(shoeGaze: shoeGaze) + LyrebirdStatusView(engine: shoeGaze.engine) + } + .frame(width: ShoeGazeBuilderView.scopeWidth, alignment: .leading) + + Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) + + VStack(alignment: .leading, spacing: ShoeGazeBuilderView.sectionSpacing) { + BoardBarView( + shoeGaze: shoeGaze, + editingBoardIndex: $selectedBoardIndex, + crossfadeSeconds: $crossfadeSeconds, + onAddBoard: { addBoard() } + ) + Divider().overlay(Color.white.opacity(ShoeGazeBuilderView.dividerOpacity)) + pedalPickerRow + } + .frame(maxWidth: .infinity, alignment: .leading) + } + .fixedSize(horizontal: false, vertical: true) + } + + /// A compact horizontal pedal-picker strip (sits below the board mixer in the top section). + private var pedalPickerRow: some View { + ScrollView(.horizontal, showsIndicators: true) { + PedalPaletteView( + axis: .horizontal, + onAdd: { type in addPedal(type: type) }, + onRouting: { action in performRouting(action) } + ) + .padding(.bottom, 2) + } + .fixedSize(horizontal: false, vertical: true) + } + // MARK: - Presentation anchors /// Hosts the board-manager sheet on its own node so it does not collide with the file @@ -414,19 +444,6 @@ public struct ShoeGazeBuilderView: View { } } - // MARK: - Palette sidebar - - private var paletteSidebar: some View { - ScrollView(.vertical, showsIndicators: true) { - PedalPaletteView( - onAdd: { type in addPedal(type: type) }, - onRouting: { action in performRouting(action) } - ) - .padding(.trailing, 2) - } - .frame(width: ShoeGazeBuilderView.sidebarWidth) - } - // MARK: - Board area private var boardArea: some View {