refactor: group viewport/zoom/pan state into a Viewport sub-struct

The visible-window + pan-anchor state was 10 flat fields (viewStart, viewEnd,
freqView*, pan*) used densely throughout the zoom/pan/scrollbar code. Group
them into a Viewport sub-struct (app.view.*).

Rename anchored strictly to 'app.' so ScopeView's own view->viewStart/viewEnd
(same field names) are untouched. Settled render verified pixel-identical
(AE=0); End/zoom path verified via injected key input.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 09:17:26 -07:00
parent 8e4250ae63
commit f91cae77e8
3 changed files with 125 additions and 123 deletions
+13 -11
View File
@@ -106,6 +106,17 @@ typedef struct {
float dragFreqStart; // selection freq start when the move began
} Selection;
// The visible window into the spectrogram (time + frequency), all 0-1
// normalized, plus the range captured at the start of a pan drag.
typedef struct {
float start, end; // visible time range
float freqStart, freqEnd; // visible freq range (0 = 0 Hz, 1 = Nyquist)
bool isPanning;
float panStart, panEnd; // time range captured when the pan began
float panFreqStart, panFreqEnd; // freq range captured when the pan began
Vector2 panStartPos; // mouse pos when the pan began
} Viewport;
typedef struct {
AudioSignal signal;
StftResult stft;
@@ -126,17 +137,8 @@ typedef struct {
char exportDir[4096];
char exportMessage[256];
// Viewport/zoom controls
float viewStart; // 0-1, start of visible time region
float viewEnd; // 0-1, end of visible time region
float freqViewStart; // 0-1, start of visible frequency region (0 = 0Hz)
float freqViewEnd; // 0-1, end of visible frequency region (1 = Nyquist)
bool isPanning;
float panStartViewStart;
float panStartViewEnd;
float panStartFreqViewStart;
float panStartFreqViewEnd;
Vector2 panStartPos;
// Visible viewport (time + frequency) and in-progress pan state.
Viewport view;
// Cached visible texture
Texture2D visibleTexture;