refactor: modal-gate helper + data-driven colormap table
Two extensibility easy-wins, both behavior-preserving: - UiModalOpen() centralizes the "an overlay owns input" check that was copy-pasted as `!showFileBrowser && !showAbout` across 6 input gates. New overlays now update one place. - Colormaps become a COLORMAPS[] table (name + function) indexed by enum. GetColormapColor and the sidebar both read it, so adding a colormap is one enum value + one Cmap* fn + one row — and the sidebar name can no longer drift from the enum (deleted the parallel colormapNames[] array). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+6
-6
@@ -217,7 +217,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// File browser toggle
|
||||
if (IsKeyPressed(KEY_O) && !app.showFileBrowser && !app.showAbout) {
|
||||
if (IsKeyPressed(KEY_O) && !UiModalOpen()) {
|
||||
app.showFileBrowser = true;
|
||||
ScanDirectory(GetWorkingDirectory());
|
||||
}
|
||||
@@ -258,7 +258,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// View controls
|
||||
if (app.loaded && !app.showFileBrowser && !app.showAbout) {
|
||||
if (app.loaded && !UiModalOpen()) {
|
||||
// Spectrogram area fills remaining window space (scaled)
|
||||
float viewScale = GetUIScale();
|
||||
float sidebarWidth = 320 * viewScale;
|
||||
@@ -438,7 +438,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// Keyboard shortcuts (SPACE for play/stop toggle, ESC for clear)
|
||||
if (IsKeyPressed(KEY_SPACE) && !app.showFileBrowser && !app.showAbout) {
|
||||
if (IsKeyPressed(KEY_SPACE) && !UiModalOpen()) {
|
||||
if (app.isPlaying && AudioPlaybackSound.frameCount > 0) {
|
||||
// Currently playing - stop it
|
||||
StopSound(AudioPlaybackSound);
|
||||
@@ -459,7 +459,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// Export PNG
|
||||
if (IsKeyPressed(KEY_E) && !app.showFileBrowser && !app.showAbout && app.stftComputed) {
|
||||
if (IsKeyPressed(KEY_E) && !UiModalOpen() && app.stftComputed) {
|
||||
ExportPNG(&app, app.exportDir);
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// LMB drag = box select (time + frequency) OR drag existing selection
|
||||
if (app.loaded && !app.showFileBrowser && !app.showAbout && CheckCollisionPointRec(mousePos, selBounds)) {
|
||||
if (app.loaded && !UiModalOpen() && CheckCollisionPointRec(mousePos, selBounds)) {
|
||||
// Set cursor to resize all when near divider
|
||||
if (mouseNearDivider && !app.isDividing) {
|
||||
SetMouseCursor(MOUSE_CURSOR_RESIZE_ALL);
|
||||
@@ -639,7 +639,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Handle divider drag. Works whether or not the scope is currently shown
|
||||
// (when hidden, the handle sits at the bottom and can be dragged back up).
|
||||
if (app.loaded && !app.showFileBrowser && !app.showAbout) {
|
||||
if (app.loaded && !UiModalOpen()) {
|
||||
// Grab the handle. The starting position is the *effective* divider,
|
||||
// which is the bottom of the view (1.0) while the scope is hidden.
|
||||
if (mouseNearDivider && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
|
||||
|
||||
Reference in New Issue
Block a user