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:
16
gui.c
16
gui.c
@@ -8,6 +8,7 @@
|
||||
#include <time.h>
|
||||
#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();
|
||||
|
||||
Reference in New Issue
Block a user