ui(cabinet): own category after amps + double-width card + stable selector id

- Add a dedicated PedalCategory.cabinet (tweed tan), placed right after
  Amp Model, and remap the Cabinet pedal to it (was buried in EQ & Filter).
  Move "Cabinet" in the palette preferredOrder to just after the amps.
- CabinetPedal is now double-width (widthUnits 2): three selectors
  (Cab / Mic / Mic B) crowded at single width, clipping the leading Cab
  caption and overlapping dials (a drag near the Mic/Mic B boundary could
  land on the neighbor's gesture — the "moving Mic moved Mic B" report).
- Harden the selector-row ForEach: key by the (unique-per-pedal) selector
  label instead of the array offset, so each selector keeps a stable SwiftUI
  identity across board rebuilds and can't inherit a sibling's drag state.

669 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 10:01:39 -07:00
parent 9b23f99a58
commit da2c3328ee
4 changed files with 15 additions and 6 deletions
@@ -51,6 +51,10 @@ public final class CabinetPedal: Pedal {
"Speaker-cabinet impulse-response convolution with selectable built-in voicings." "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.
public override var widthUnits: Int { 2 }
// MARK: - Parameters // MARK: - Parameters
/// Selected cabinet voicing as an index into ``CabinetVoice/allCases``. Snaps to integer /// Selected cabinet voicing as an index into ``CabinetVoice/allCases``. Snaps to integer
@@ -11,6 +11,7 @@ import SwiftUI
/// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order. /// to its category lives here, keyed by name like ``PedalPaletteView``'s preferred order.
public enum PedalCategory: String, CaseIterable, Identifiable, Sendable { public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
case amp = "Amp Model" case amp = "Amp Model"
case cabinet = "Cabinet"
case gain = "Gain" case gain = "Gain"
case dynamics = "Dynamics" case dynamics = "Dynamics"
case filter = "EQ & Filter" case filter = "EQ & Filter"
@@ -26,6 +27,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
var color: Color { var color: Color {
switch self { switch self {
case .amp: return Color(red: 0.70, green: 0.45, blue: 0.18) // warm valve-glow copper case .amp: return Color(red: 0.70, green: 0.45, blue: 0.18) // warm valve-glow copper
case .cabinet: return Color(red: 0.50, green: 0.36, blue: 0.18) // tweed / cabinet tan
case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12) case .gain: return Color(red: 0.82, green: 0.38, blue: 0.12)
case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32) case .dynamics: return Color(red: 0.20, green: 0.50, blue: 0.32)
case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55) case .filter: return Color(red: 0.14, green: 0.46, blue: 0.55)
@@ -48,7 +50,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable {
"Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain, "Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain,
"Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics, "Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics,
"Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter, "Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter,
"Cabinet": .filter, "Cabinet": .cabinet,
"Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation, "Tremolo": .modulation, "Phaser": .modulation, "Modulation": .modulation, "Chorus": .modulation,
"Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .modulation, "Flanger": .modulation, "Vibrato": .modulation, "Rotary": .modulation, "Ring Modulator": .modulation,
"Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch, "Bass Octaver": .pitch, "Octave Splitter": .pitch, "Harmonizer": .pitch,
@@ -54,10 +54,10 @@ public struct PedalPaletteView: View {
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is /// 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. /// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
private static let preferredOrder: [String] = [ private static let preferredOrder: [String] = [
"California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", "California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Cabinet", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
"Volume", "Volume",
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary", "Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary",
"Auto-Wah", "Wah", "Mutant", "Cabinet", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator", "Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer", "Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb", "Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
"Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb", "Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb",
+6 -3
View File
@@ -874,10 +874,13 @@ public struct PedalView: View {
if !selectors.isEmpty { if !selectors.isEmpty {
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) { HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
Spacer(minLength: 0) Spacer(minLength: 0)
ForEach(Array(selectors.enumerated()), id: \.offset) { pair in // Keyed by the (unique-per-pedal) selector label, not the array offset, so each
// selector keeps a stable SwiftUI identity across board rebuilds — a rebuildsOnChange
// selector must not inherit a sibling's drag @State.
ForEach(selectors, id: \.label) { selector in
PedalSelectorKnobView( PedalSelectorKnobView(
pair.element, selector,
onCommit: pair.element.rebuildsOnChange onCommit: selector.rebuildsOnChange
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) } ? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
: nil : nil
) )