added mouse wheel support
This commit is contained in:
34
test/test.c
34
test/test.c
@@ -38,6 +38,16 @@ static inline void test_screen(TimEvent* e) {
|
||||
sprintf(buf, "input : %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
|
||||
e->s[0], e->s[1], e->s[2], e->s[3], e->s[4], e->s[5], e->s[6], e->s[7]);
|
||||
tim_label(buf, 2, 4, A, A, style_default);
|
||||
// replace unprintable characters with space
|
||||
i32 s_len = tim_utf8_len(e->s);
|
||||
for(i32 i = 0; i < s_len; i++){
|
||||
i32 pos = tim_utf8_pos(e->s, i);
|
||||
u8 uc = e->s[pos];
|
||||
if(uc < (u8)' '){
|
||||
e->s[pos] = ' ';
|
||||
}
|
||||
}
|
||||
tim_label(e->s, 2, 5, A, A, style_default);
|
||||
|
||||
// lower right
|
||||
render_us += tim->render_us;
|
||||
@@ -52,7 +62,7 @@ static inline void test_screen(TimEvent* e) {
|
||||
tim_label("multi\nliñe\nlabël", 24, 1, A, A, style_default);
|
||||
|
||||
// colors
|
||||
tim_scope(1, 5, 16, 5) {
|
||||
tim_scope(1, 6, 16, 5) {
|
||||
tim_frame(0, 0, ~0, ~0, style_default);
|
||||
tim_label(" Red ", 1, 1, 7, A, (TimStyle){ .bg = 0x09 });
|
||||
tim_label(" ", 8, 1, 7, A, (TimStyle){ .bg = 0xc4 });
|
||||
@@ -64,30 +74,30 @@ static inline void test_screen(TimEvent* e) {
|
||||
|
||||
// button
|
||||
static TimStyle style_button = { .bg = 0x01 };
|
||||
if (tim_button("Click Me", 17, 5, 16, 5, style_button)) {
|
||||
if (tim_button("Click Me", 17, 6, 16, 5, style_button)) {
|
||||
style_button.bg = (style_button.bg + 1) & 0xff;
|
||||
}
|
||||
|
||||
// edit
|
||||
static TimStyle style_edit = { .brd = 0xff, .fg = 0xff };
|
||||
tim_edit(&ed1, 1, 10, 32, style_edit);
|
||||
tim_edit(&ed1, 1, 11, 32, style_edit);
|
||||
sprintf(buf, "cursor: %d length: %d", ed1.cursor, ed1.length);
|
||||
tim_label(buf, 2, 13, A, A, style_default);
|
||||
tim_edit(&ed2, 1, 14, 32, style_edit);
|
||||
tim_label(ed2.s, 2, 17, A, A, style_default);
|
||||
tim_label(buf, 2, 12, A, A, style_default);
|
||||
tim_edit(&ed2, 1, 15, 32, style_edit);
|
||||
tim_label(ed2.s, 2, 18, A, A, style_default);
|
||||
|
||||
// checkbox
|
||||
static TimStyle style_checkbox = { .brd = TimColor16_Cyan, .fg = TimColor16_White };
|
||||
static i32 chk[2] = {-1, 1};
|
||||
tim_checkbox("Check 1", &chk[0], 1, 18, A, style_checkbox);
|
||||
tim_checkbox("Check 2", &chk[1], 14, 18, A, style_checkbox);
|
||||
tim_checkbox("Check 1", &chk[0], 1, 19, A, style_checkbox);
|
||||
tim_checkbox("Check 2", &chk[1], 14, 19, A, style_checkbox);
|
||||
|
||||
// radiobox
|
||||
static i32 rad = 0;
|
||||
tim_radiobutton("Radio 1", &rad, 1, 1, 19, A, style_checkbox);
|
||||
tim_radiobutton("Radio 2", &rad, 2, 14, 19, A, style_checkbox);
|
||||
tim_radiobutton("Radio 3", &rad, 3, 1, 20, A, style_checkbox);
|
||||
tim_radiobutton("Radio 4", &rad, 4, 14, 20, A, style_checkbox);
|
||||
tim_radiobutton("Radio 1", &rad, 1, 1, 20, A, style_checkbox);
|
||||
tim_radiobutton("Radio 2", &rad, 2, 14, 20, A, style_checkbox);
|
||||
tim_radiobutton("Radio 3", &rad, 3, 1, 21, A, style_checkbox);
|
||||
tim_radiobutton("Radio 4", &rad, 4, 14, 21, A, style_checkbox);
|
||||
|
||||
// scope nesting
|
||||
tim_scope(~1, 1, 20, 10) {
|
||||
|
||||
Reference in New Issue
Block a user