v2.3.0 release: onEditingEnded edit-ended callback on continuous controls
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -189,6 +189,34 @@ ParameterLabel("Level", node: synth.$amplitude)
|
||||
ParameterLabel("Freq (Hz)", node: synth.$frequency, decimalPlaces: 1)
|
||||
```
|
||||
|
||||
### Reporting the end of an edit (`onEditingEnded`)
|
||||
|
||||
The continuous controls — `ParameterKnob`, `ParameterSlider`, `ParameterXY`, and `MultiSlider` —
|
||||
drive their node(s) continuously while dragging. Attach `.onEditingEnded` to be told **once per
|
||||
drag gesture**, with the value(s) at the start and end of the drag, so a host can record a single
|
||||
edit (an undo checkpoint, say) instead of one per intermediate update:
|
||||
|
||||
```swift
|
||||
ParameterKnob("Cutoff", node: synth.$cutoff, range: 20...20000)
|
||||
.onEditingEnded { previous, new in
|
||||
undo.record(previous, new) // called once, when the drag ends
|
||||
}
|
||||
```
|
||||
|
||||
The payload differs per control:
|
||||
|
||||
| Control | `onEditingEnded` closure |
|
||||
|---|---|
|
||||
| `ParameterKnob` / `ParameterSlider` | `(previous: Double, new: Double)` |
|
||||
| `ParameterXY` | `(previous: (x: Double, y: Double), new: (x: Double, y: Double))` — one gesture drives both nodes |
|
||||
| `MultiSlider` | `(previous: [Double], new: [Double])` — the `count` cell values before/after (a drag can paint several bars) |
|
||||
|
||||
Notes:
|
||||
- It fires once per gesture **even when the value didn't net-change** (e.g. a `MultiSlider` tap on an
|
||||
unchanged bar). Filter on `previous == new` if your host wants to skip no-op edits.
|
||||
- `ParameterSlider` (the SwiftUI variant) rides the native `Slider`'s editing-changed signal, so it
|
||||
also fires for keyboard / accessibility adjustments, not only pointer drags.
|
||||
|
||||
### LyrebirdStatusView
|
||||
|
||||
Compact engine status display showing average and peak CPU load. Polls the engine at 10 Hz;
|
||||
|
||||
Reference in New Issue
Block a user