replaced confusing u64 joinded colors with struct TimStyle
This commit is contained in:
@@ -85,18 +85,18 @@ static TimKey edit_event(TimEditState* e, TimRect r) {
|
||||
return tim->event.key;
|
||||
}
|
||||
|
||||
TimKey tim_edit(TimEditState* e, i32 x, i32 y, i32 w, u64 color) {
|
||||
TimKey tim_edit(TimEditState* e, i32 x, i32 y, i32 w, TimStyle style) {
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, 3);
|
||||
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, color >> 16, color >> 8);
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, style.brd, style.bg);
|
||||
if (tim->focus == e) {
|
||||
char* s = e->s + tim_utf8_pos(e->s, e->cursor - r.w + 4);
|
||||
i32 cur = MIN(r.w - 4, e->cursor);
|
||||
tim_draw_str(s, r.x + 2, r.y + 1, r.w - 3, color, color >> 8);
|
||||
tim_draw_str(s, r.x + 2, r.y + 1, r.w - 3, style.fg, style.bg);
|
||||
tim_draw_invert(r.x + cur + 2, r.y + 1, 1);
|
||||
} else {
|
||||
tim_draw_str(e->s, r.x + 2, r.y + 1, r.w - 3, color, color >> 8);
|
||||
tim_draw_str(e->s, r.x + 2, r.y + 1, r.w - 3, style.fg, style.bg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "tim.h"
|
||||
|
||||
void tim_frame(i32 x, i32 y, i32 w, i32 h, u64 color) {
|
||||
void tim_frame(i32 x, i32 y, i32 w, i32 h, TimStyle style) {
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, h);
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, color, color >> 8);
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, style.brd, style.bg);
|
||||
}
|
||||
}
|
||||
|
||||
void tim_label(cstr s, i32 x, i32 y, i32 w, i32 h, u64 color) {
|
||||
void tim_label(cstr s, i32 x, i32 y, i32 w, i32 h, TimStyle style) {
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
TimText t = tim_scan_str(s);
|
||||
w = (w == A) ? t.width : w;
|
||||
h = (h == A) ? t.lines : h;
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, h);
|
||||
TimCell c = tim_cell(" ", color, color >> 8);
|
||||
TimCell c = tim_cell(" ", style.fg, style.bg);
|
||||
tim_draw_lot(c, r.x, r.y, r.w, r.h);
|
||||
TimLine l = {.s = s, .line = ""};
|
||||
for (i32 i = 0; tim_next_line(&l); i++) {
|
||||
@@ -22,28 +22,28 @@ void tim_label(cstr s, i32 x, i32 y, i32 w, i32 h, u64 color) {
|
||||
}
|
||||
}
|
||||
|
||||
bool tim_button(cstr txt, i32 x, i32 y, i32 w, i32 h, u64 color) {
|
||||
bool tim_button(cstr txt, i32 x, i32 y, i32 w, i32 h, TimStyle style) {
|
||||
i32 tw = tim_utf8_len(txt);
|
||||
w = (w == A) ? (tw + 4) : w;
|
||||
h = (h == A) ? 3 : h;
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, h);
|
||||
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, color >> 16, color >> 8);
|
||||
tim_draw_str(txt, r.x + (w - tw) / 2, r.y + h / 2, w, color, color >> 8);
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, style.brd, style.bg);
|
||||
tim_draw_str(txt, r.x + (w - tw) / 2, r.y + h / 2, w, style.fg, style.bg);
|
||||
}
|
||||
return tim_is_mouse_click_over(r);
|
||||
}
|
||||
|
||||
bool tim_checkbox(cstr txt, i32* state, i32 x, i32 y, i32 w, u64 color) {
|
||||
bool tim_checkbox(cstr txt, i32* state, i32 x, i32 y, i32 w, TimStyle style) {
|
||||
w = (w == A) ? tim_utf8_len(txt) + 4 : w;
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, 1);
|
||||
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
cstr st = *state == -1 ? "-" : *state ? "x" : " ";
|
||||
tim_draw_str("[ ] ", r.x, r.y, 4, color, color >> 8);
|
||||
tim_draw_str(st, r.x + 1, r.y, 1, color >> 16, color >> 8);
|
||||
tim_draw_str(txt, r.x + 4, r.y, r.w - 4, color, color >> 8);
|
||||
tim_draw_str("[ ] ", r.x, r.y, 4, style.fg, style.bg);
|
||||
tim_draw_str(st, r.x + 1, r.y, 1, style.brd, style.bg);
|
||||
tim_draw_str(txt, r.x + 4, r.y, r.w - 4, style.fg, style.bg);
|
||||
}
|
||||
|
||||
bool click = tim_is_mouse_click_over(r);
|
||||
@@ -52,15 +52,15 @@ bool tim_checkbox(cstr txt, i32* state, i32 x, i32 y, i32 w, u64 color) {
|
||||
}
|
||||
|
||||
|
||||
bool tim_radiobutton(cstr txt, i32* state, i32 v, i32 x, i32 y, i32 w, u64 color) {
|
||||
bool tim_radiobutton(cstr txt, i32* state, i32 v, i32 x, i32 y, i32 w, TimStyle style) {
|
||||
w = (w == A) ? tim_utf8_len(txt) + 4 : w;
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, 1);
|
||||
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
cstr st = *state == v ? "o" : " ";
|
||||
tim_draw_str("( ) ", r.x, r.y, 4, color, color >> 8);
|
||||
tim_draw_str(st, r.x + 1, r.y, 1, color >> 16, color >> 8);
|
||||
tim_draw_str(txt, r.x + 4, r.y, r.w - 4, color, color >> 8);
|
||||
tim_draw_str("( ) ", r.x, r.y, 4, style.fg, style.bg);
|
||||
tim_draw_str(st, r.x + 1, r.y, 1, style.brd, style.bg);
|
||||
tim_draw_str(txt, r.x + 4, r.y, r.w - 4, style.fg, style.bg);
|
||||
}
|
||||
|
||||
bool click = tim_is_mouse_click_over(r);
|
||||
|
||||
Reference in New Issue
Block a user