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 76951f4 commit ca7b016
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions demos/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void control_change(unsigned char controller, unsigned char value, void *
printf("control change: %u, %u\n", controller, value);
}

static void create_window(void *user_data) {
static void create_window(char const *title, void *user_data) {
struct demo *demo = user_data;
struct gral_window_interface window_interface = {
&close,
Expand All @@ -139,28 +139,25 @@ 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, title, &window_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) {
printf("open empty\n");
create_window(user_data);
create_window("gral events demo", user_data);
}

static void open_file(char const *path, void *user_data) {
printf("open file: %s\n", path);
create_window(user_data);
create_window(path, user_data);
}

static void quit(void *user_data) {
Expand Down

0 comments on commit ca7b016

Please sign in to comment.