From bdfbe04713c6baea93345e7e8451f94609dec3f6 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Sat, 4 Jul 2026 13:05:57 -0700 Subject: [PATCH] Looper: wide 3-column layout to fit tall pedal without scrolling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The looper stacked too many sections to fit the board canvas. Render it (only) in a wide, three-column layout at widthUnits = 3: - Left column: loop timeline, Free/Sync switch, Reset footswitch. - Centre column: the four effect knobs (2×2) over a Level + Bypass footer, with the Mix slot reserved empty so Bypass stays horizontally centred like a normal pedal. - Right column: transport footswitches in a 2×2 grid — Record / Reverse over Stop / Cue Stop (ordered by label). Every other pedal keeps the default single-column section stack (extracted into PedalView.defaultContent, no behaviour change). Co-Authored-By: Claude Opus 4.8 --- .../LyrebirdShoeGaze/Pedals/LooperPedal.swift | 2 +- Sources/LyrebirdShoeGazeUI/PedalView.swift | 158 ++++++++++++++++-- .../LooperPedalTests.swift | 4 +- 3 files changed, 146 insertions(+), 18 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift index 5694ff6..bebbe67 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift @@ -41,7 +41,7 @@ public final class LooperPedal: Pedal { } /// Double-width card: the looper carries a full transport plus a track strip and timeline. - public override var widthUnits: Int { 2 } + public override var widthUnits: Int { 3 } /// The looper always passes the clean signal through and adds the loop on top (see `effect`), /// so the wet/dry Mix knob is meaningless — hide it and keep `mix` fully wet. diff --git a/Sources/LyrebirdShoeGazeUI/PedalView.swift b/Sources/LyrebirdShoeGazeUI/PedalView.swift index 972dc69..5f0d020 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalView.swift @@ -241,6 +241,10 @@ public struct PedalView: View { private static let shadowOpacity: Double = 0.60 private static let enclosureGradientDarkFraction: Double = 0.30 private static let bypassSectionSpacing: CGFloat = 6 + /// Gap between the looper's three content columns. + private static let looperColumnSpacing: CGFloat = 18 + /// Fixed width of the looper's left (timeline) column. + private static let looperTimelineColumnWidth: CGFloat = 200 /// Half the screw-dot size — used to centre screws on the corner position. private static let screwHalfSize: CGFloat = 4 private static let namePlateBackgroundOpacity: Double = 0.35 @@ -302,21 +306,14 @@ public struct PedalView: View { lineWidth: PedalView.innerHighlightLineWidth) .padding(PedalView.innerHighlightPadding) - // Content stack - VStack(spacing: PedalView.sectionSpacing) { - namePlate - looperTimeline - knobGrid - selectorRow - switchRow - // Keyed on the pedal instance so the buttons' live captions (which poll the pedal - // via `.task`) re-subscribe when a rig load / rebuild swaps in a new pedal instance. - transportButtonRow - .id(ObjectIdentifier(pedal)) - buttonRow - sliderBank(sliders) - Spacer(minLength: 0) - bottomControls + // Content stack — the looper uses a wide, columnar layout to stay short; every other + // pedal uses the default single-column section stack. + Group { + if let looper: LooperPedal = pedal as? LooperPedal { + looperColumnarContent(looper) + } else { + defaultContent(sliders: sliders) + } } .padding(PedalView.enclosurePadding) @@ -341,6 +338,137 @@ public struct PedalView: View { } } + // MARK: - Content layouts + + /// The default single-column section stack used by every pedal except the looper. + private func defaultContent(sliders: [PedalSlider]) -> some View { + VStack(spacing: PedalView.sectionSpacing) { + namePlate + looperTimeline + knobGrid + selectorRow + switchRow + // Keyed on the pedal instance so the buttons' live captions (which poll the pedal + // via `.task`) re-subscribe when a rig load / rebuild swaps in a new pedal instance. + transportButtonRow + .id(ObjectIdentifier(pedal)) + buttonRow + sliderBank(sliders) + Spacer(minLength: 0) + bottomControls + } + } + + /// Wide, three-column layout for the looper: the loop timeline on the left, the effect knobs + /// over the Free/Sync switch in the centre, and the transport footswitch grid (with bypass) on + /// the right. Laying the sections side-by-side keeps the tall pedal short enough to fit the + /// canvas without scrolling. Requires the looper's `widthUnits` to be wide enough (3×). + private func looperColumnarContent(_ looper: LooperPedal) -> some View { + VStack(spacing: PedalView.sectionSpacing) { + namePlate + HStack(alignment: .top, spacing: PedalView.looperColumnSpacing) { + // Left column: timeline, then the Free/Sync switch, then the Reset footswitch. + VStack(spacing: PedalView.sectionSpacing) { + LooperTimelineView(pedal: looper) + switchRow + looperResetCell + Spacer(minLength: 0) + } + .frame(width: PedalView.looperTimelineColumnWidth) + + // Centre column: the four effect knobs (2×2), with the Level + Bypass footer at the + // bottom. The Mix slot is reserved (empty) so Bypass stays horizontally centred, + // matching a normal pedal's footer. + VStack(spacing: PedalView.sectionSpacing) { + looperEffectKnobs(columns: 2) + Spacer(minLength: 0) + looperFooter + } + + // Right column: the transport footswitches (minus Reset) in a 2×2 grid. + looperTransportGrid(columns: 2) + .id(ObjectIdentifier(pedal)) + } + Spacer(minLength: 0) + } + } + + /// The looper's effect knobs (everything except the trailing `Mix` / `Level`) laid out in + /// rows of `columns`. + private func looperEffectKnobs(columns: Int) -> some View { + let knobs: [PedalKnob] = Array(pedal.knobs.dropLast(2)) + let rows: [[PedalKnob]] = stride(from: 0, to: knobs.count, by: columns).map { start in + Array(knobs[start ..< min(start + columns, knobs.count)]) + } + return VStack(spacing: PedalView.knobSpacing) { + ForEach(Array(rows.enumerated()), id: \.offset) { rowPair in + HStack(spacing: PedalView.knobRowItemSpacing) { + Spacer(minLength: 0) + ForEach(Array(rowPair.element.enumerated()), id: \.offset) { knobPair in + let knob: PedalKnob = knobPair.element + ParameterKnob(knob.label, node: knob.node, range: knob.range) + .foregroundStyle(Color.white) + } + Spacer(minLength: 0) + } + } + } + } + + /// Preferred grid order for the looper's transport footswitches (row-major), so the 2×2 grid + /// reads Record / Reverse over Stop / Cue Stop. Buttons not listed keep their original order + /// and follow. Matched by label to stay robust if the descriptor order changes. + private static let looperTransportOrder: [String] = ["Loop", "Reverse", "Stop", "Cue Stop"] + + /// The looper's transport footswitches — everything except the trailing Reset (which sits in + /// the left column) — laid out in rows of `columns` in ``looperTransportOrder``. + private func looperTransportGrid(columns: Int) -> some View { + let buttons: [PedalButton] = Array(pedal.effectTransportButtons.dropLast()) + let ordered: [PedalButton] = + PedalView.looperTransportOrder.compactMap { label in buttons.first { $0.label == label } } + + buttons.filter { !PedalView.looperTransportOrder.contains($0.label) } + let rows: [[PedalButton]] = stride(from: 0, to: ordered.count, by: columns).map { start in + Array(ordered[start ..< min(start + columns, ordered.count)]) + } + return VStack(spacing: PedalView.knobSpacing) { + ForEach(Array(rows.enumerated()), id: \.offset) { rowPair in + HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) { + Spacer(minLength: 0) + ForEach(Array(rowPair.element.enumerated()), id: \.offset) { pair in + PedalButtonView(pair.element) + } + Spacer(minLength: 0) + } + } + } + } + + /// The looper's footer: Level on the left, Bypass in the centre, and an empty third where a + /// normal pedal's Mix knob would sit — so Bypass stays horizontally centred in the column. + private var looperFooter: some View { + HStack(spacing: 0) { + levelControl + .frame(maxWidth: .infinity) + bypassControl + .frame(maxWidth: .infinity) + Color.clear + .frame(maxWidth: .infinity, maxHeight: 0) // reserved Mix slot + } + } + + /// The Reset footswitch (the trailing transport button), centred — sits at the bottom of the + /// looper's left (timeline) column. + @ViewBuilder + private var looperResetCell: some View { + if let reset: PedalButton = pedal.effectTransportButtons.last { + HStack(spacing: 0) { + Spacer(minLength: 0) + PedalButtonView(reset) + Spacer(minLength: 0) + } + } + } + // MARK: - Subviews /// Capsule name plate near the top of the enclosure. diff --git a/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift b/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift index 08e4659..c8e7222 100644 --- a/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift @@ -168,8 +168,8 @@ struct LooperPedalTests { #expect(pedal.effectTransportButtons.map { $0.label } == ["Loop", "Stop", "Cue Stop", "Reverse", "Reset"]) } - @Test func looperIsDoubleWidth() throws { - #expect(LooperPedal().widthUnits == 2) + @Test func looperIsTripleWidth() throws { + #expect(LooperPedal().widthUnits == 3) #expect(LooperPedal.trackCount == 4) }