Skip to content

Commit

Permalink
improve the events demo
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Sep 18, 2024
1 parent 3d9e0b4 commit 81239d4
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions demos/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void control_change(unsigned char controller, unsigned char value, void *

static void create_window(void *user_data) {
struct demo *demo = user_data;
struct gral_window_interface window_interface = {
struct gral_window_interface interface = {
&close,
&draw,
&resize,
Expand All @@ -139,18 +139,15 @@ static void create_window(void *user_data) {
&focus_enter,
&focus_leave
};
demo->window = gral_window_create(demo->application, 600, 400, "gral events demo", &window_interface, demo);
demo->timer = gral_timer_create(1000, &timer, demo);
struct gral_midi_interface midi_interface = {
&note_on,
&note_off,
&control_change
};
demo->midi = gral_midi_create(demo->application, "gral events demo", &midi_interface, demo);
demo->window = gral_window_create(demo->application, 600, 400, "gral events demo", &interface, demo);
}

static void start(void *user_data) {
printf("start\n");
struct demo *demo = user_data;
demo->timer = gral_timer_create(1000, &timer, demo);
struct gral_midi_interface midi_interface = {&note_on, &note_off, &control_change};
demo->midi = gral_midi_create(demo->application, "gral events demo", &midi_interface, demo);
}

static void open_empty(void *user_data) {
Expand All @@ -165,14 +162,15 @@ static void open_file(char const *path, void *user_data) {

static void quit(void *user_data) {
printf("quit\n");
struct demo *demo = user_data;
gral_midi_delete(demo->midi);
}

int main(int argc, char **argv) {
struct demo demo;
struct gral_application_interface interface = {&start, &open_empty, &open_file, &quit};
demo.application = gral_application_create("com.github.eyelash.libgral.demos.events", &interface, &demo);
int result = gral_application_run(demo.application, argc, argv);
gral_midi_delete(demo.midi);
gral_window_delete(demo.window);
gral_application_delete(demo.application);
return result;
Expand Down

0 comments on commit 81239d4

Please sign in to comment.