Mercurial > molko
comparison examples/example-cursor/example-cursor.c @ 469:0d6206cee6b9
core: state -> mlk_state
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 27 Feb 2023 11:11:23 +0100 |
parents | 01f5580e43d1 |
children | ca30ff96bbe0 |
comparison
equal
deleted
inserted
replaced
468:91ce23a36143 | 469:0d6206cee6b9 |
---|---|
33 #include <mlk/ui/ui.h> | 33 #include <mlk/ui/ui.h> |
34 | 34 |
35 #define W 1280 | 35 #define W 1280 |
36 #define H 720 | 36 #define H 720 |
37 | 37 |
38 static struct 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 window_cursor cursor = WINDOW_CURSOR_ARROW; |
41 | 41 |
42 static struct label help = { | 42 static struct label help = { |
43 .x = 10, | 43 .x = 10, |
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 window_set_cursor(cursor); |
73 } | 73 } |
74 | 74 |
75 static void | 75 static void |
76 handle(struct state *st, const union mlk_event *ev) | 76 handle(struct mlk_state *st, const union mlk_event *ev) |
77 { | 77 { |
78 (void)st; | 78 (void)st; |
79 | 79 |
80 switch (ev->type) { | 80 switch (ev->type) { |
81 case MLK_EVENT_KEYDOWN: | 81 case MLK_EVENT_KEYDOWN: |
101 break; | 101 break; |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 static void | 105 static void |
106 draw(struct state *st) | 106 draw(struct mlk_state *st) |
107 { | 107 { |
108 (void)st; | 108 (void)st; |
109 | 109 |
110 mlk_painter_set_color(0xebede9ff); | 110 mlk_painter_set_color(0xebede9ff); |
111 mlk_painter_clear(); | 111 mlk_painter_clear(); |
114 } | 114 } |
115 | 115 |
116 static void | 116 static void |
117 run(void) | 117 run(void) |
118 { | 118 { |
119 struct state state = { | 119 struct mlk_state state = { |
120 .handle = handle, | 120 .handle = handle, |
121 .draw = draw | 121 .draw = draw |
122 }; | 122 }; |
123 | 123 |
124 change(cursor); | 124 change(cursor); |