diff options
Diffstat (limited to 'tools/mq_editor/editor.js')
| -rw-r--r-- | tools/mq_editor/editor.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/mq_editor/editor.js b/tools/mq_editor/editor.js index 3c07877..0854ec0 100644 --- a/tools/mq_editor/editor.js +++ b/tools/mq_editor/editor.js @@ -20,6 +20,8 @@ class PartialEditor { // Callback: called after a partial is deleted so the host can update keepCount this.onPartialDeleted = null; + // Callback: called before any mutation (for undo/redo) + this.onBeforeChange = null; // Private state this._selectedIndex = -1; @@ -355,6 +357,7 @@ class PartialEditor { if (!this.partials) return; const val = parseFloat(e.target.value); if (isNaN(val)) return; + if (this.onBeforeChange) this.onBeforeChange(); this.partials[partialIndex][curveKey][field + pointIndex] = val; if (this.viewer) this.viewer.render(); }; @@ -363,6 +366,7 @@ class PartialEditor { _setupButtons() { document.getElementById('mutePartialBtn').addEventListener('click', () => { if (this._selectedIndex < 0 || !this.partials) return; + if (this.onBeforeChange) this.onBeforeChange(); const p = this.partials[this._selectedIndex]; p.muted = !p.muted; if (this.viewer) this.viewer.render(); @@ -371,6 +375,7 @@ class PartialEditor { document.getElementById('deletePartialBtn').addEventListener('click', () => { if (this._selectedIndex < 0 || !this.partials || !this.viewer) return; + if (this.onBeforeChange) this.onBeforeChange(); this.partials.splice(this._selectedIndex, 1); this.viewer.selectPartial(-1); if (this.onPartialDeleted) this.onPartialDeleted(); @@ -490,6 +495,7 @@ class PartialEditor { const curve = partial.freqCurve; for (let i = 0; i < 4; ++i) { if (Math.hypot(this._tToX(curve['t' + i]) - x, this._ampToY(curve['a' + i]) - y) <= 8) { + if (this.onBeforeChange) this.onBeforeChange(); this._dragPointIndex = i; this._dragCompanionOff = null; if (i === 0) |
