fix: new-file load resets full nav state (zoom out both axes, stop playback)
ResetForNewSignal only reset the time view + selection, leaving the previous file's frequency zoom, in-progress drags, and playback running. Loading a new file now zooms out both axes, cancels any drag/pan/divide, clears the selection, and stops playback + rewinds the playhead. Display preferences (colormap, dB scale, FFT size, grid, scope layout) are preserved by design. All three load paths funnel through this function. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -118,9 +118,24 @@ void ResetForNewSignal(void)
|
||||
// Cached STFT results are tied to the old signal data.
|
||||
FreeAllCacheEntries(&app.fftCache);
|
||||
|
||||
// Reset view + selection to full range.
|
||||
// Zoom out both axes and drop the old selection / any in-progress drags.
|
||||
// Display preferences (colormap, dB scale, FFT size, grid, scope layout)
|
||||
// are intentionally preserved across loads.
|
||||
app.view.start = 0.0f; app.view.end = 1.0f;
|
||||
app.view.freqStart = 0.0f; app.view.freqEnd = 1.0f;
|
||||
app.view.isPanning = false;
|
||||
ClearSelection();
|
||||
app.sel.isDragging = false;
|
||||
app.sel.isTimeSelecting = false;
|
||||
app.sel.isFreqSelecting = false;
|
||||
app.isDividing = false;
|
||||
|
||||
// Stop any playback from the previous signal and rewind the playhead.
|
||||
if (app.isPlaying && AudioPlaybackSound.frameCount > 0) StopSound(AudioPlaybackSound);
|
||||
app.isPlaying = false;
|
||||
app.playbackFinished = false;
|
||||
app.playheadElapsed = 0.0f;
|
||||
app.playheadT = 0.0f;
|
||||
|
||||
// Invalidate the cached visible texture.
|
||||
if (app.visibleTexture.id != 0) UnloadTexture(app.visibleTexture);
|
||||
|
||||
Reference in New Issue
Block a user