button.h (851B)
1 #ifndef TA_BUTTON_H
2 #define TA_BUTTON_H
3
4 #include <tuxanci2/text.h>
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include <stddef.h>
8
9 typedef void (*ta_button_callback)(void);
10
11 typedef struct {
12 const char *label;
13 ta_button_callback callback;
14 ta_text text_idle;
15 ta_text text_selected;
16 uint32_t text_width;
17 uint32_t text_height;
18 } ta_button;
19
20 typedef struct {
21 ta_button *buttons;
22 size_t buttons_size;
23 size_t size;
24 size_t selected;
25 bool up_was_down;
26 bool down_was_down;
27 bool enter_was_down;
28 } ta_button_lists;
29
30 void ta_button_lists_init(ta_button_lists *list);
31 bool ta_button_lists_add(ta_button_lists *list, const char *label, ta_button_callback callback);
32 void ta_button_lists_update(ta_button_lists *list);
33 void ta_button_lists_draw(const ta_button_lists *list);
34 void ta_button_lists_destroy(ta_button_lists *list);
35
36 #endif // TA_BUTTON_H