refactor(ui): make widthUnits mean "base width in columns" + tidy overrides

Follow-up cleanup now that card width is content-derived. Redefine widthUnits
as the card's base width in knob columns (1 = 3-wide, 2 = 4-wide) — both the
knob-grid column count and the card's minimum width — with selector/switch rows
able to push wider. Values above 2 no longer do anything.

- Delete the now-misleading widthUnits 3/4 overrides on 11 amps; they inherit
  AmpVoicePedal's 2 (all full-surface amps → the same tight 4-wide card).
- Remove Mutant's redundant override (2 knobs + 2 switches → 3-wide either way).
- Cabinet: keep widthUnits 2 so it's 4-wide like the amps — its Cab/Mic/Mic B
  selector captions (voice names) need the room to stay readable (per request).
- Looper keeps widthUnits 3 (the one pedal still using the flat multiple for its
  bespoke timeline/knobs/transport layout).
- Refresh the widthUnits docs (base + AmpVoicePedal + Cabinet); update the amp
  tests' widthUnits assertions (3/4 → 2; Looper stays 3).

675 tests pass; no visual change to the amps, Cabinet now matches their width.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-05 09:05:40 -07:00
parent a1ce308082
commit 292261a088
26 changed files with 29 additions and 62 deletions
+6 -2
View File
@@ -143,8 +143,12 @@ open class Pedal: SynthesizerBase {
open func rigWillTeardown() {}
/// Number of standard enclosure widths this pedal's card occupies in the UI. Defaults
/// to `1`. A control-dense pedal (e.g. the looper) overrides to `2` for a wider card.
/// The UI multiplies its base enclosure width by this factor; `1` is the normal stompbox.
/// to `1`. This sets the card's **base width in knob columns**: `1` = a three-wide card, `≥ 2` =
/// four-wide (and the knob grid packs that many across). It is both the grid's column count and
/// the card's minimum width, so a `2` pedal is a four-wide card even with few knobs (e.g. the
/// Cabinet, to keep its selector captions readable). A pedal whose selector/switch row is wider
/// still pushes wider; values above `2` add nothing. (The looper is the sole exception: it
/// overrides the UI to a fixed multi-column layout scaled by this value.)
open var widthUnits: Int { 1 }
/// `true` when the board has placed this pedal in a stereo (width-2) region.
@@ -316,7 +316,8 @@ open class AmpVoicePedal: Pedal {
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
public override var showsMixControl: Bool { false }
/// Amp-head-style double-width card.
/// Amps use a four-wide knob grid for their Gain/Bass/Mid/Treble + signature controls (the card
/// width is sized to content — see `PedalView.enclosureWidth`).
public override var widthUnits: Int { 2 }
public override var summary: String { summaryText }
@@ -75,9 +75,6 @@ public final class AnaheimAmpPedal: AmpVoicePedal {
]
}
/// Wider card for the three switches.
public override var widthUnits: Int { 3 }
/// Creates an Anaheim amp.
///
/// - Parameters:
@@ -70,9 +70,6 @@ open class BoutiqueAmpPedal: AmpVoicePedal {
}
public override var powerAmpOversample: Int { 4 }
/// Wider card for the Presence/Depth/Master/Drive knobs plus the Channel switch.
public override var widthUnits: Int { 4 }
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
@@ -36,9 +36,6 @@ public final class BritishBluesbreakerAmpPedal: BritishComboAmpPedal {
]
}
/// Wider card for the extra tremolo knobs plus the Bright and Tremolo switches.
public override var widthUnits: Int { 3 }
/// The base Bright switch plus a Tremolo footswitch (compose `super` so Bright stays in sync).
public override var effectSwitches: [PedalSwitch] {
super.effectSwitches + [
@@ -63,9 +63,6 @@ public final class BritishDualAmpPedal: BritishComboAmpPedal {
}
public override var powerAmpOversample: Int { 4 }
/// Wider card for the extra Master/Drive/Reverb knobs plus the Bright and Channel switches.
public override var widthUnits: Int { 4 }
/// Creates a British Dual amp.
///
/// - Parameters:
@@ -34,9 +34,6 @@ public final class BritishMasterAmpPedal: BritishComboAmpPedal {
}
public override var powerAmpOversample: Int { 4 }
/// Wider card for the Presence/Master knobs plus the Bright switch.
public override var widthUnits: Int { 3 }
/// Creates a British Master amp.
///
/// - Parameters:
@@ -51,8 +51,8 @@ public final class CabinetPedal: Pedal {
"Speaker-cabinet impulse-response convolution with selectable built-in voicings."
}
/// Double-width card — three selectors (Cab / Mic / Mic B) need the room; at single width the
/// dials crowd and the leading selector's caption clips.
/// Four-wide card (same as the amps), so the Cab / Mic / Mic B selector captions — cabinet and
/// mic voice names — stay readable rather than crowding.
public override var widthUnits: Int { 2 }
// MARK: - Parameters
@@ -65,9 +65,6 @@ public final class ChimeTopBoostAmpPedal: AmpVoicePedal {
]
}
/// Wider card for the extra Cut/tremolo knobs plus the Brilliant and Tremolo switches.
public override var widthUnits: Int { 3 }
// MARK: - Init
/// Creates a Chime Top Boost amp.
@@ -48,9 +48,6 @@ public final class FullertonDriveAmpPedal: AmpVoicePedal {
]
}
/// Wider card for the Reverb/Drive knobs plus the Bright and Channel switches.
public override var widthUnits: Int { 3 }
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
@@ -68,9 +68,6 @@ open class FullertonReverbAmpPedal: AmpVoicePedal {
]
}
/// Wider card to hold the extra reverb/tremolo knobs plus the Bright switch.
public override var widthUnits: Int { 3 }
// MARK: - Init
/// Creates a Fullerton Reverb amp.
@@ -82,9 +82,6 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
/// Stereo output — the chorus feeds two independent power-amp/cabinet channels.
public override var channelKind: PedalChannelKind { .widener }
/// Wider card for the reverb/chorus knobs plus the Bright and Chorus switches.
public override var widthUnits: Int { 3 }
// MARK: - Init
/// Creates a Jazz Clean amp.
@@ -57,9 +57,6 @@ public final class MagnaVibratoAmpPedal: AmpVoicePedal {
]
}
/// Wider card for the vibrato knobs plus the Vibrato switch.
public override var widthUnits: Int { 3 }
/// Creates a Magna Vibrato amp.
///
/// - Parameters:
@@ -31,10 +31,6 @@ public final class MutantPedal: Pedal {
"Envelope-following auto-wah / funk filter that opens with your picking."
}
/// Double-width so the two switches — Sweep (2-way) and the 3-way Mode — sit side by side
/// without cramping now that switches lay out horizontally.
public override var widthUnits: Int { 2 }
// MARK: - Parameters
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass. Driven by a three-state switch.
@@ -54,9 +54,6 @@ public final class SixtiesComboAmpPedal: AmpVoicePedal {
public override var powerAmpOversample: Int { 4 }
public override var powerAmpDriveInput: any ValidGeneratorInput { grittyPowerDrive }
/// Wider card for the tremolo knobs plus the Tremolo switch.
public override var widthUnits: Int { 3 }
/// Creates a Sixties Combo amp.
///
/// - Parameters:
+8 -9
View File
@@ -964,11 +964,12 @@ public struct PedalView: View {
/// 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 card is `columns` wide, where `columns` is the pedal's base knob-grid width from
/// `widthUnits` (`1` → `knobColumnCount`, `≥ 2` → `wideKnobColumnCount`) — so a `widthUnits: 2`
/// pedal is always a four-wide card even if it carries fewer knobs (this is how the Cabinet
/// matches the amps so its selector captions stay readable). A pedal whose selector or switch row
/// is wider than that pushes wider still. 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.
@@ -976,10 +977,8 @@ public struct PedalView: View {
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 gridColumns: Int = pedal.widthUnits >= 2 ? PedalView.wideKnobColumnCount : PedalView.knobColumnCount
let columns: Int = max(gridColumns, inlineSelectors.count, pedal.effectSwitches.count)
let contentWidth: CGFloat = 2 * PedalView.enclosurePadding
+ CGFloat(columns) * PedalView.enclosureColumnWidth
+ CGFloat(max(0, columns - 1)) * PedalView.knobSpacing
@@ -133,7 +133,7 @@ struct BoutiqueAmpPedalTests {
#expect(lead.effectKnobs.map { $0.label }
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
#expect(lead.effectSwitches.map { $0.label } == ["Channel"])
#expect(lead.widthUnits == 4)
#expect(lead.widthUnits == 2)
#expect(lead.toneStackModel == .soldano)
#expect(lead.powerAmpOversample == 4)
@@ -108,7 +108,7 @@ struct BritishComboAmpPedalTests {
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Speed", "Intensity"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Tremolo"])
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
}
@Test func bluesbreakerTremoloIntensityChangesOutput() throws {
@@ -92,7 +92,7 @@ struct BritishMasterAmpPedalTests {
let pedal: BritishMasterAmpPedal = BritishMasterAmpPedal()
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
#expect(pedal.toneStackModel == .marshall)
#expect(pedal.powerAmpOversample == 4)
}
@@ -140,7 +140,7 @@ struct BritishMasterAmpPedalTests {
#expect(pedal.effectKnobs.map { $0.label }
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Master", "Drive", "Reverb"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Channel"])
#expect(pedal.widthUnits == 4)
#expect(pedal.widthUnits == 2)
#expect(pedal.toneStackModel == .marshall)
#expect(pedal.powerAmpOversample == 4)
}
@@ -85,7 +85,7 @@ struct CaliHiGainAmpPedalTests {
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
#expect(pedal.effectSliders.map { $0.label } == ["80", "240", "750", "2.2k", "6.6k"])
#expect(pedal.effectSwitches.map { $0.label } == ["Channel"])
#expect(pedal.widthUnits == 4)
#expect(pedal.widthUnits == 2)
#expect(pedal.toneStackModel == .mesa)
}
@@ -111,7 +111,7 @@ struct ChimeTopBoostAmpPedalTests {
#expect(pedal.effectSwitches.map { $0.label } == ["Brilliant", "Tremolo"])
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
#expect(pedal.showsMixControl == false)
#expect(pedal.toneStackModel == .vox)
}
@@ -105,7 +105,7 @@ struct FullertonDriveAmpPedalTests {
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Reverb", "Drive"])
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Channel"])
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
#expect(pedal.toneStackModel == .fender)
}
@@ -123,7 +123,7 @@ struct FullertonReverbAmpPedalTests {
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"])
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
#expect(pedal.showsMixControl == false)
#expect(pedal.toneStackModel == .fender)
}
@@ -105,7 +105,7 @@ struct FullertonVariantsTests {
== ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"], "\(v.name) knobs")
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Reverb FX", "Vibrato"], "\(v.name) switches")
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(v.name) selectors")
#expect(pedal.widthUnits == 3, "\(v.name) width")
#expect(pedal.widthUnits == 2, "\(v.name) width")
#expect(pedal.toneStackModel == .fender, "\(v.name) tone stack")
#expect(pedal.powerAmpOversample == 4, "\(v.name) should oversample the harder-driven power amp at 4×")
}
@@ -155,7 +155,7 @@ struct JazzCleanAmpPedalTests {
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Chorus", "Channel"])
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
#expect(pedal.widthUnits == 3)
#expect(pedal.widthUnits == 2)
#expect(pedal.showsMixControl == false)
#expect(pedal.channelKind == .widener, "Jazz Clean should be a stereo widener")
#expect(pedal.toneStackModel == .fender)
@@ -103,7 +103,7 @@ struct ModernHighGainAmpPedalTests {
== ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"])
#expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias", "Bias X"])
#expect(pedal.effectSwitches.map { $0.label } == ["Channel", "Tight"])
#expect(pedal.widthUnits == 4)
#expect(pedal.widthUnits == 2)
#expect(pedal.toneStackModel == .mesa)
#expect(pedal.sag == 0.3, "Modern High-Gain keeps rectifier sag on by default")
}