feat(ui): bespoke Karplus Resonator layout — reuse the Tune slot for the root
In Pitched mode the generic stack showed a redundant Tune Hz knob beside the Root note selector, and stranded Sensitivity on its own row. Give the pedal a custom layout (as the looper has one): - Top row: the root control, then Sustain and Tone. The root slot is the continuous Tune Hz knob in Free mode and the stepped Root note selector in Pitched mode — one slot, reused, so Pitched no longer shows a dead Tune knob. - The Free / Pitched switch sits directly beneath the top row. - Voicing and Sensitivity share the next row. - Standard Level · Bypass · Mix footer. View-only: the pedal still publishes Tune as a stable effect knob, so positional presets round-trip exactly as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -538,6 +538,8 @@ public struct PedalView: View {
|
||||
Group {
|
||||
if let looper: LooperPedal = pedal as? LooperPedal {
|
||||
looperColumnarContent(looper)
|
||||
} else if pedal is KarplusResonatorPedal {
|
||||
karplusContent
|
||||
} else {
|
||||
defaultContent(sliders: sliders)
|
||||
}
|
||||
@@ -731,6 +733,82 @@ public struct PedalView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Karplus Resonator layout
|
||||
|
||||
/// Bespoke layout for the ``KarplusResonatorPedal``. The generic stack would show a redundant
|
||||
/// Tune Hz knob beside the Root note selector in Pitched mode, and strand Sensitivity on a row of
|
||||
/// its own. Instead:
|
||||
/// - **Top row**: the root control, then Sustain and Tone. The root slot is the continuous Tune
|
||||
/// Hz knob in Free mode and the stepped Root note selector in Pitched mode — one slot, reused.
|
||||
/// - **Switch** directly beneath the top row: the Free / Pitched toggle.
|
||||
/// - **Voicing + Sensitivity** share the next row.
|
||||
/// - Standard Level · Bypass · Mix footer.
|
||||
///
|
||||
/// Only the *view* changes — the pedal still publishes Tune as a stable effect knob, so positional
|
||||
/// presets round-trip exactly as for any other pedal.
|
||||
private var karplusContent: some View {
|
||||
VStack(spacing: PedalView.sectionSpacing) {
|
||||
namePlate
|
||||
karplusTopRow
|
||||
switchRow
|
||||
karplusVoicingSensitivityRow
|
||||
bottomControls
|
||||
PedalMappingStrip(pedal: pedal, map: controlMappingMap)
|
||||
}
|
||||
}
|
||||
|
||||
/// The first effect knob whose label matches `label`, or `nil`.
|
||||
private func effectKnob(_ label: String) -> PedalKnob? {
|
||||
pedal.effectKnobs.first { $0.label == label }
|
||||
}
|
||||
|
||||
/// The first selector whose label matches `label`, or `nil`.
|
||||
private func effectSelector(_ label: String) -> PedalSelectorKnob? {
|
||||
pedal.effectSelectors.first { $0.label == label }
|
||||
}
|
||||
|
||||
/// Renders one selector with the standard rebuild-on-commit wiring.
|
||||
private func selectorCell(_ selector: PedalSelectorKnob) -> some View {
|
||||
PedalSelectorKnobView(
|
||||
selector,
|
||||
onCommit: selector.rebuildsOnChange
|
||||
? { [pedal, pedalRebuildAction] in pedalRebuildAction(pedal) }
|
||||
: nil
|
||||
)
|
||||
}
|
||||
|
||||
/// The root-tuning control: the stepped Root note selector when Pitched (it is published only in
|
||||
/// that mode), otherwise the continuous Tune Hz knob. One physical slot, reused across modes.
|
||||
@ViewBuilder
|
||||
private var karplusRootControl: some View {
|
||||
if let root: PedalSelectorKnob = effectSelector("Root") {
|
||||
selectorCell(root)
|
||||
} else if let tune: PedalKnob = effectKnob("Tune") {
|
||||
knobCell(tune)
|
||||
}
|
||||
}
|
||||
|
||||
/// Top row: the root control (Tune knob or Root selector), then Sustain and Tone.
|
||||
private var karplusTopRow: some View {
|
||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||
Spacer(minLength: 0)
|
||||
karplusRootControl
|
||||
if let sustain: PedalKnob = effectKnob("Sustain") { knobCell(sustain) }
|
||||
if let tone: PedalKnob = effectKnob("Tone") { knobCell(tone) }
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Second row: the Voicing selector paired with the Sensitivity knob.
|
||||
private var karplusVoicingSensitivityRow: some View {
|
||||
HStack(alignment: .top, spacing: PedalView.knobRowItemSpacing) {
|
||||
Spacer(minLength: 0)
|
||||
if let voicing: PedalSelectorKnob = effectSelector("Voicing") { selectorCell(voicing) }
|
||||
if let sensitivity: PedalKnob = effectKnob("Sensitivity") { knobCell(sensitivity) }
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subviews
|
||||
|
||||
/// Capsule name plate near the top of the enclosure.
|
||||
|
||||
Reference in New Issue
Block a user