refactor: table-driven keymap dispatch + auto-derived help list

Replace the global key handling scattered through the main loop with a single
KEYMAP table (key, gate, action, help text) and a DispatchKeymap() pass. The
About/Help overlay now renders its key list straight from the table, so the
on-screen shortcuts can never drift from the actual bindings.

- Order-sensitive keys (Space, Esc) stay inline where their frame ordering
  matters; they carry action==NULL and appear in the table for the help list.
- Adds the F11 fullscreen binding the sidebar button already advertised but
  that was never actually wired up.
- Fix About title em-dash rendering as '?' (font is ASCII-only); use a hyphen.

Launch render verified pixel-identical (AE=0); keys verified via injected input.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 09:05:37 -07:00
parent 53f7fa6047
commit 99c7d43637
3 changed files with 105 additions and 43 deletions
+16 -6
View File
@@ -578,7 +578,7 @@ void DrawAboutDialog(void)
DrawRectangle(0, 0, sw, sh, Fade(BLACK, 0.7f));
float pw = 560 * scale;
float ph = 470 * scale;
float ph = 540 * scale;
Rectangle panel = { (sw - pw) / 2, (sh - ph) / 2, pw, ph };
DrawRectangleRec(panel, (Color){ 30, 30, 38, 255 });
DrawRectangleLinesEx(panel, 2, (Color){ 90, 90, 110, 255 });
@@ -586,7 +586,7 @@ void DrawAboutDialog(void)
float px = panel.x + 24 * scale;
float py = panel.y + 20 * scale;
DrawTextScaled("rspektrum synchrosqueezed spectrogram viewer", px, py, 18, WHITE);
DrawTextScaled("rspektrum - synchrosqueezed spectrogram viewer", px, py, 18, WHITE);
py += 34 * scale;
// Body lines. NULL = blank spacer; headings start with no leading spaces.
@@ -606,10 +606,6 @@ void DrawAboutDialog(void)
" spectral magnitudes.",
" - Pixels show synchrosqueezed (reassigned) energy, not raw FFT bins.",
" Good to ~a dB for visualization; not lab-grade metrology.",
"",
"Keys",
" O open file P toggle scope Home/End reset / fit view",
" F1 / Esc close this dialog",
};
int n = sizeof(lines) / sizeof(lines[0]);
for (int i = 0; i < n; i++) {
@@ -619,6 +615,20 @@ void DrawAboutDialog(void)
py += (s[0] == '\0' ? 8 : 18) * scale;
}
// Keys — rendered straight from the keymap table so this list can never
// drift from the actual bindings.
py += 10 * scale;
DrawTextScaled("Keys", px, py, 14, (Color){ 150, 200, 255, 255 });
py += 20 * scale;
int kn;
const KeyBinding* km = GetKeymap(&kn);
for (int i = 0; i < kn; i++) {
DrawTextScaled(TextFormat(" %-5s %s", km[i].label, km[i].help), px, py, 13, LIGHTGRAY);
py += 16 * scale;
}
DrawTextScaled(" Mouse wheel = zoom, Alt+drag = pan, drag = select box",
px, py, 13, LIGHTGRAY);
DrawTextScaled("F1 / Esc / click to close", panel.x + pw - 196 * scale,
panel.y + ph - 26 * scale, 12, GRAY);
// Note: opening/closing is handled in the main input loop (not here) so the