From 4b2c315c507c25cfd55fd45483ed4f4d46c76cf4 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Sat, 2 May 2026 14:34:45 +0000 Subject: [PATCH] fix: update gui.c to use dispatcher instead of direct engine transport access Co-authored-by: aider (deepseek/deepseek-coder) --- gui.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gui.c b/gui.c index a68cc36..3b846b3 100644 --- a/gui.c +++ b/gui.c @@ -8,6 +8,7 @@ #include #include "engine.h" #include "gui.h" +#include "dispatcher.h" /* microui includes */ #define MU_IMPLEMENTATION @@ -68,9 +69,11 @@ static void gui_update(void) if (mu_button(ctx, active ? "Stop" : "Play")) { active = !active; if (active) { - engine_start(g_engine); + Action action = { .type = ACTION_TRANSPORT_PLAY }; + g_engine->dispatch(action); } else { - engine_stop(g_engine); + Action action = { .type = ACTION_TRANSPORT_PAUSE }; + g_engine->dispatch(action); } } if (mu_button(ctx, "Reset")) { @@ -153,9 +156,11 @@ int gui_main(Engine *engine) case ' ': active = !active; if (active) { - engine_start(g_engine); + Action action = { .type = ACTION_TRANSPORT_PLAY }; + g_engine->dispatch(action); } else { - engine_stop(g_engine); + Action action = { .type = ACTION_TRANSPORT_PAUSE }; + g_engine->dispatch(action); } break; case KEY_UP: @@ -176,7 +181,8 @@ int gui_main(Engine *engine) } /* 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 */ gui_update();