diff --git a/nob.c b/nob.c index c374d4b..fb9640e 100644 --- a/nob.c +++ b/nob.c @@ -284,6 +284,9 @@ void generate_default_config(Nob_String_Builder *content) nob_sb_append_cstr(content, "\n"); nob_sb_append_cstr(content, "//// Unfinished feature that enables capturing sound from the mic.\n"); nob_sb_append_cstr(content, "// #define MUSIALIZER_MICROPHONE\n"); + nob_sb_append_cstr(content, "\n"); + nob_sb_append_cstr(content, "//// Activate UI buttons on Press instead of Release just as John Carmack explained https://twitter.com/ID_AA_Carmack/status/1787850053912064005\n"); + nob_sb_append_cstr(content, "// #define MUSIALIZER_ACT_ON_PRESS\n"); } int main(int argc, char **argv) diff --git a/src/plug.c b/src/plug.c index e2b2440..4220367 100644 --- a/src/plug.c +++ b/src/plug.c @@ -226,7 +226,9 @@ typedef struct { float out_smooth[FFT_SIZE]; float out_smear[FFT_SIZE]; +#ifndef MUSIALIZER_ACT_ON_PRESS uint64_t active_button_id; +#endif // MUSIALIZER_ACT_ON_PRESS Popup_Tray pt; @@ -690,8 +692,9 @@ static int button_with_id(uint64_t id, Rectangle boundary) { Vector2 mouse = GetMousePosition(); int hoverover = CheckCollisionPointRec(mouse, boundary); - int clicked = 0; +#ifndef MUSIALIZER_ACT_ON_PRESS + int clicked = 0; if (p->active_button_id == 0) { if (hoverover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { p->active_button_id = id; @@ -702,6 +705,9 @@ static int button_with_id(uint64_t id, Rectangle boundary) if (hoverover) clicked = 1; } } +#else + int clicked = hoverover && IsMouseButtonPressed(MOUSE_BUTTON_LEFT); +#endif // MUSIALIZER_ACT_ON_PRESS return (clicked<<1) | hoverover; }