-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbox.c
More file actions
76 lines (64 loc) · 1.13 KB
/
Copy pathcheckbox.c
File metadata and controls
76 lines (64 loc) · 1.13 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "checkbox.h"
bool uk_checkbox(
UK *uk,
unsigned id,
const char *text,
bool *value
) {
UK_Rect row = {
uk->cx,
uk->cy,
uk->cw,
34.0f
};
bool hit =
uk_hit(uk, row);
if (hit && uk->mpress)
*value = !*value;
UK_Rect box = {
row.x,
row.y + 4.0f,
25.0f,
25.0f
};
UK_Color bg =
*value ?
uk->th.checkbox_on :
uk->th.checkbox_off;
uk_rect_fill_r(
uk,
box,
7.0f,
bg
);
if (*value) {
uk_line(
uk,
box.x + 6,
box.y + 13,
box.x + 11,
box.y + 18,
uk->th.checkbox_check,
2.0f
);
uk_line(
uk,
box.x + 11,
box.y + 18,
box.x + 20,
box.y + 7,
uk->th.checkbox_check,
2.0f
);
}
uk_text(
uk,
text,
box.x + 36.0f,
row.y + 6.0f,
uk->th.text
);
uk->cy += 44.0f;
(void)id;
return hit && uk->mpress;
}