Mercurial > molko
comparison examples/example-cursor/example-cursor.c @ 485:3ff1fe64d0cd
core: window -> mlk_window
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 28 Feb 2023 08:40:35 +0100 |
parents | ca30ff96bbe0 |
children | d6757c30658e |
comparison
equal
deleted
inserted
replaced
484:f14b8290b3ce | 485:3ff1fe64d0cd |
---|---|
35 #define W 1280 | 35 #define W 1280 |
36 #define H 720 | 36 #define H 720 |
37 | 37 |
38 static struct mlk_state *states[1]; | 38 static struct mlk_state *states[1]; |
39 static char help_text[128]; | 39 static char help_text[128]; |
40 static enum window_cursor cursor = WINDOW_CURSOR_ARROW; | 40 static enum mlk_window_cursor cursor = MLK_WINDOW_CURSOR_ARROW; |
41 | 41 |
42 static struct label help = { | 42 static struct label help = { |
43 .x = 10, | 43 .x = 10, |
44 .y = 10, | 44 .y = 10, |
45 .text = help_text, | 45 .text = help_text, |
49 static void | 49 static void |
50 init(void) | 50 init(void) |
51 { | 51 { |
52 if (mlk_core_init("fr.malikania", "example-cursor") < 0 || ui_init() < 0) | 52 if (mlk_core_init("fr.malikania", "example-cursor") < 0 || ui_init() < 0) |
53 mlk_panic(); | 53 mlk_panic(); |
54 if (window_open("Example - Cursor", W, H) < 0) | 54 if (mlk_window_open("Example - Cursor", W, H) < 0) |
55 mlk_panic(); | 55 mlk_panic(); |
56 } | 56 } |
57 | 57 |
58 static void | 58 static void |
59 change(enum window_cursor cursor) | 59 change(enum mlk_window_cursor cursor) |
60 { | 60 { |
61 static const char *names[] = { | 61 static const char *names[] = { |
62 [WINDOW_CURSOR_ARROW] = "WINDOW_CURSOR_ARROW", | 62 [WINDOW_CURSOR_ARROW] = "WINDOW_CURSOR_ARROW", |
63 [WINDOW_CURSOR_EDIT] = "WINDOW_CURSOR_EDIT", | 63 [WINDOW_CURSOR_EDIT] = "WINDOW_CURSOR_EDIT", |
64 [WINDOW_CURSOR_WAIT] = "WINDOW_CURSOR_WAIT", | 64 [WINDOW_CURSOR_WAIT] = "WINDOW_CURSOR_WAIT", |
67 [WINDOW_CURSOR_NO] = "WINDOW_CURSOR_NO", | 67 [WINDOW_CURSOR_NO] = "WINDOW_CURSOR_NO", |
68 [WINDOW_CURSOR_HAND] = "WINDOW_CURSOR_HAND" | 68 [WINDOW_CURSOR_HAND] = "WINDOW_CURSOR_HAND" |
69 }; | 69 }; |
70 | 70 |
71 snprintf(help_text, sizeof (help_text), "Keys: <Left>/<Right> to change cursor. Current: %s", names[cursor]); | 71 snprintf(help_text, sizeof (help_text), "Keys: <Left>/<Right> to change cursor. Current: %s", names[cursor]); |
72 window_set_cursor(cursor); | 72 mlk_window_set_cursor(cursor); |
73 } | 73 } |
74 | 74 |
75 static void | 75 static void |
76 handle(struct mlk_state *st, const union mlk_event *ev) | 76 handle(struct mlk_state *st, const union mlk_event *ev) |
77 { | 77 { |
83 case MLK_KEY_LEFT: | 83 case MLK_KEY_LEFT: |
84 if (cursor > 0) | 84 if (cursor > 0) |
85 change(--cursor); | 85 change(--cursor); |
86 break; | 86 break; |
87 case MLK_KEY_RIGHT: | 87 case MLK_KEY_RIGHT: |
88 if (cursor + 1 < WINDOW_CURSOR_LAST) | 88 if (cursor + 1 < MLK_WINDOW_CURSOR_LAST) |
89 change(++cursor); | 89 change(++cursor); |
90 break; | 90 break; |
91 default: | 91 default: |
92 break; | 92 break; |
93 } | 93 } |
129 } | 129 } |
130 | 130 |
131 static void | 131 static void |
132 quit(void) | 132 quit(void) |
133 { | 133 { |
134 window_finish(); | 134 mlk_window_finish(); |
135 ui_finish(); | 135 ui_finish(); |
136 mlk_core_finish(); | 136 mlk_core_finish(); |
137 } | 137 } |
138 | 138 |
139 int | 139 int |