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();