// 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 } } }