1f5b70edc7
Tier 2 of the rig-undo feature, on the same undo stack as the structural (tier 1) edits. Records one undo checkpoint when the user finishes changing a pedal control, so ⌘Z / the ↶ button step back through knob turns and switch flips as well as add/remove/move. - UndoEntry.parameter + PedalControlGroup (knob/advancedKnob/slider/switch/ selector); UndoCoordinator.recordParameterEdit + .parameter handling in undo()/redo(). applyParameter re-resolves the LIVE node by (pedalID, group, controlLabel) via ShoeGaze.pedal(id:), so an undo lands on the right control even after an intervening structural rebuild replaced the pedal's node (pedal ids persist through rebuild). old == new records nothing. - Knobs record via Lyrebird 2.3.0's ParameterKnob.onEditingEnded (one edit per drag): PedalView.recordingKnob (main / advanced / mix / level / looper) and TempoSyncKnobView. - Self-contained views (VerticalParameterSlider, PedalSwitchView, PedalSelectorKnobView) record via a new \.pedalParameterEditRecorder environment closure PedalView installs, capturing pedal.id + the coordinator. Slider/selector snapshot node.value at drag start; switch records old→new on the committing tap. - rebuildsOnChange switches/selectors are deliberately NOT recorded (they alter graph topology and would fight the structural restore's live-value merge) — documented as a known gap, along with tempo-sync division changes. - Bump the Lyrebird pin to 2.3.0 (the released tag with onEditingEnded), drop the dev-time local path override. Tests: 18 UndoCoordinator tests (knob/slider/switch/selector round-trips, post-rebuild re-resolution, + a catalogue test asserting unique control labels per group so the by-label resolution can't mis-target). Full suite 837 green; both demo schemes build against 2.3.0. External review + caveman sweep: no blocking findings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
2.0 KiB
Swift
51 lines
2.0 KiB
Swift
// UndoEntry.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Foundation
|
|
|
|
/// One entry on an ``UndoCoordinator`` undo or redo stack.
|
|
///
|
|
/// Two kinds of edit are recorded:
|
|
/// - **Structural** topology changes (adding, removing, moving, or re-routing pedals and boards) are
|
|
/// captured as a whole-rig ``ShoeGazeState`` snapshot, restored surgically on undo.
|
|
/// - **Parameter** changes (a single knob / slider turn) are captured as the control's identity plus
|
|
/// its before/after values, so undo sets it back without disturbing anything else.
|
|
///
|
|
/// Both undo and redo are a symmetric swap: a structural entry restores its snapshot; a parameter
|
|
/// entry sets its control to the old value on undo and the new value on redo. Either way the applied
|
|
/// entry moves to the opposite stack.
|
|
enum UndoEntry {
|
|
|
|
/// A whole-rig topology change — adding, removing, or moving a pedal, board, split/merge region,
|
|
/// or router. The associated ``ShoeGazeState`` is the snapshot to restore when this entry is
|
|
/// applied: the rig state *before* the change for an undo entry, or *after* it for the matching
|
|
/// redo entry.
|
|
case structural(label: String, state: ShoeGazeState)
|
|
|
|
/// A single parameter change on one pedal control. The control is addressed by its pedal's id,
|
|
/// its group, and its label (re-resolved live so it survives an intervening rebuild); `oldValue`
|
|
/// is restored on undo and `newValue` on redo.
|
|
case parameter(
|
|
label: String,
|
|
pedalID: UUID,
|
|
group: PedalControlGroup,
|
|
controlLabel: String,
|
|
oldValue: Double,
|
|
newValue: Double
|
|
)
|
|
|
|
/// A human-readable description of the action (e.g. `"Add Reverb"`, `"Drive"`), shown next to the
|
|
/// Undo / Redo menu items and toolbar buttons.
|
|
var label: String {
|
|
switch self {
|
|
case .structural(let label, _):
|
|
return label
|
|
case .parameter(let label, _, _, _, _, _):
|
|
return label
|
|
}
|
|
}
|
|
}
|