fix: update gui.c to use dispatcher instead of direct engine transport access

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 14:34:45 +00:00
parent 3dae299894
commit 4b2c315c50

16
gui.c
View File

@@ -8,6 +8,7 @@
#include <time.h> #include <time.h>
#include "engine.h" #include "engine.h"
#include "gui.h" #include "gui.h"
#include "dispatcher.h"
/* microui includes */ /* microui includes */
#define MU_IMPLEMENTATION #define MU_IMPLEMENTATION
@@ -68,9 +69,11 @@ static void gui_update(void)
if (mu_button(ctx, active ? "Stop" : "Play")) { if (mu_button(ctx, active ? "Stop" : "Play")) {
active = !active; active = !active;
if (active) { if (active) {
engine_start(g_engine); Action action = { .type = ACTION_TRANSPORT_PLAY };
g_engine->dispatch(action);
} else { } else {
engine_stop(g_engine); Action action = { .type = ACTION_TRANSPORT_PAUSE };
g_engine->dispatch(action);
} }
} }
if (mu_button(ctx, "Reset")) { if (mu_button(ctx, "Reset")) {
@@ -153,9 +156,11 @@ int gui_main(Engine *engine)
case ' ': case ' ':
active = !active; active = !active;
if (active) { if (active) {
engine_start(g_engine); Action action = { .type = ACTION_TRANSPORT_PLAY };
g_engine->dispatch(action);
} else { } else {
engine_stop(g_engine); Action action = { .type = ACTION_TRANSPORT_PAUSE };
g_engine->dispatch(action);
} }
break; break;
case KEY_UP: case KEY_UP:
@@ -176,7 +181,8 @@ int gui_main(Engine *engine)
} }
/* update engine state */ /* update engine state */
current_beat = g_engine->transport->bar_position * 4 + g_engine->transport->beat_position; AppState state = dispatcher_get_state();
current_beat = state.bar_position * 4 + state.beat_position;
/* render GUI */ /* render GUI */
gui_update(); gui_update();