tim_button_noborder
This commit is contained in:
@@ -23,14 +23,26 @@ void tim_label(cstr s, i32 x, i32 y, i32 w, i32 h, TimStyle style) {
|
||||
}
|
||||
|
||||
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;
|
||||
i32 txt_w = tim_utf8_len(txt);
|
||||
w = (w == A) ? (txt_w + 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, style.brd, style.bg);
|
||||
tim_draw_str(txt, r.x + (w - tw) / 2, r.y + h / 2, w, style.fg, style.bg);
|
||||
tim_draw_str(txt, r.x + (w - txt_w) / 2, r.y + h / 2, w, style.fg, style.bg);
|
||||
}
|
||||
return tim_is_mouse_click_over(r);
|
||||
}
|
||||
|
||||
bool tim_button_noborder(cstr txt, i32 x, i32 y, i32 w, i32 h, TimStyle style) {
|
||||
i32 txt_w = tim_utf8_len(txt);
|
||||
w = (w == A) ? txt_w : w;
|
||||
h = (h == A) ? 1 : h;
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, h);
|
||||
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
tim_draw_str(txt, r.x + (w - txt_w) / 2, r.y + h / 2, w, style.fg, style.bg);
|
||||
}
|
||||
return tim_is_mouse_click_over(r);
|
||||
}
|
||||
@@ -67,5 +79,3 @@ bool tim_radiobutton(cstr txt, i32* state, i32 v, i32 x, i32 y, i32 w, TimStyle
|
||||
*state = click ? v : *state;
|
||||
return click;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user