forked from Tasssadar/multirom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.h
50 lines (40 loc) · 928 Bytes
/
button.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef BUTTON_H
#define BUTTON_H
#include "framebuffer.h"
#include "input.h"
enum
{
BTN_HOVER = 0x01,
BTN_DISABLED = 0x02,
BTN_CHECKED = 0x04,
};
enum
{
CLR_NORMAL = 0,
CLR_HOVER,
CLR_DIS,
CLR_CHECK,
CLR_MAX
};
typedef struct
{
int x, y;
int w, h;
fb_text *text;
fb_rect *rect;
uint32_t c[CLR_MAX][2];
int flags;
int touch_id;
int action;
void (*clicked)(int); // action
} button;
void button_init_ui(button *b, const char *text, int size);
void button_destroy(button *b);
void button_move(button *b, int x, int y);
void button_set_hover(button *b, int hover);
void button_enable(button *b, int enable);
void button_set_checked(button *b, int checked);
void button_set_color(button *b, int idx, int text, uint32_t color);
void button_update_colors(button *b);
int button_touch_handler(touch_event *ev, void *data);
#endif