From a1ce308082f6ce6226566100a75dfd6bf00d6361 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Tue, 4 Aug 2026 19:02:50 -0700 Subject: [PATCH] =?UTF-8?q?ui(layout):=20size=20pedal=20card=20width=20to?= =?UTF-8?q?=20content,=20not=20widthUnits=20=C3=97=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cards were `220 × widthUnits` wide, so control-sparse multi-unit pedals sat mostly empty (a 3-unit amp was 660px for a 4-knob row needing ~270; the 2-unit Cabinet was 440 for three selectors). Size the enclosure to its widest actual row instead — knob grid (columns capped by widthUnits), inline selectors, or switches — floored at the 3-slot Level·Bypass·Mix footer, and still widened for a vertical-fader bank. New: Cabinet 440→252, Bluesbreaker 660→330, Boutique/Dual 880→330; 1-unit pedals ~252. widthUnits now only sets the knob-column cap (≥2 packs 4 across), not raw width, so all 4-knob amps land at the same tight width regardless of their 3/4 unit value. The looper keeps the flat multiple — its bespoke three-column timeline/knobs/transport layout genuinely needs the wide card. 675 tests pass (view geometry; no logic change). Co-Authored-By: Claude Opus 4.8 --- Sources/LyrebirdShoeGazeUI/PedalView.swift | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/Sources/LyrebirdShoeGazeUI/PedalView.swift b/Sources/LyrebirdShoeGazeUI/PedalView.swift index c783c50..a0b37ee 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalView.swift @@ -422,9 +422,12 @@ public struct PedalView: View { // MARK: - Layout constants - /// Wide enough for three ~55 pt knobs (dial + label + value) plus padding in a - /// single row, so the effect controls never overlap. + /// Base card width — used by the looper's fixed multi-unit layout. Other pedals size to content + /// via ``enclosureColumnWidth`` (see `enclosureWidth(for:)`). private static let enclosureWidth: CGFloat = 220 + /// Per-column width for the content-sized enclosure — one knob/selector/switch slot (a ~50 pt + /// dial plus its caption). Card width = `2·padding + columns·this + (columns−1)·knobSpacing`. + private static let enclosureColumnWidth: CGFloat = 68 private static let enclosureCornerRadius: CGFloat = 12 private static let enclosurePadding: CGFloat = 14 private static let screwInset: CGFloat = 6 @@ -958,19 +961,36 @@ public struct PedalView: View { } } - /// Enclosure width — the base stompbox width scaled by the pedal's `widthUnits` - /// (a control-dense pedal such as the looper asks for a double-width card), widened - /// further to fit a wide vertical-fader bank (e.g. a multi-band graphic EQ) so its - /// faders are never clipped. + /// Enclosure width, sized to the pedal's **content** rather than a flat `widthUnits × base` + /// multiple (which left control-sparse multi-unit cards — amps, the Cabinet — mostly empty). + /// + /// The card fits its widest row: the knob grid (whose column count is capped by `widthUnits` — + /// a dense pedal packs `wideKnobColumnCount` across instead of `knobColumnCount`), the inline + /// selector row, or the switch row — never narrower than the three-slot `Level · Bypass · Mix` + /// footer. It is widened further to fit a vertical-fader bank (e.g. a multi-band graphic EQ) so + /// its faders are never clipped. + /// + /// The looper is the exception: its bespoke three-column layout (timeline · knobs · transport) + /// genuinely needs the full multi-unit width, so it keeps the flat multiple. private func enclosureWidth(for sliders: [PedalSlider]) -> CGFloat { - let unitWidth: CGFloat = PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits)) + if pedal is LooperPedal { + return PedalView.enclosureWidth * CGFloat(max(1, pedal.widthUnits)) + } + let columnCap: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount + let knobColumns: Int = min(pedal.effectKnobs.count, columnCap) + let footerColumns: Int = 3 // Level · Bypass · Mix (or Level · Bypass · footer selector) + let columns: Int = max(knobColumns, inlineSelectors.count, pedal.effectSwitches.count, footerColumns) + let contentWidth: CGFloat = 2 * PedalView.enclosurePadding + + CGFloat(columns) * PedalView.enclosureColumnWidth + + CGFloat(max(0, columns - 1)) * PedalView.knobSpacing + let sliderCount: Int = sliders.count - guard sliderCount > 0 else { return unitWidth } + guard sliderCount > 0 else { return contentWidth } let bankContentWidth: CGFloat = CGFloat(sliderCount) * PedalView.sliderBankItemWidth + CGFloat(max(0, sliderCount - 1)) * PedalView.sliderBankSpacing let needed: CGFloat = bankContentWidth + 2 * PedalView.enclosurePadding - return max(unitWidth, needed) + return max(contentWidth, needed) } /// Bottom control row: the `Level` knob, the bypass switch, and the `Mix` knob,