diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-09 10:15:42 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-09 10:15:42 -0500 |
commit | 7be42dc83ff694da2f1e66a59a14fe51d3e18fba (patch) | |
tree | b4da6d79dcfd52c11a1220860670ff3ac0477e01 /ui.c | |
parent | f9afc00d15f934d8509f3eeb7c62b01ca84ca204 (diff) |
case sensitivity, regex
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -600,12 +600,14 @@ static void popup_render(Ted *ted, u32 options, char const *title, char const *b text_render(font); } -static void checkbox_frame(Ted *ted, bool *value, char const *label, v2 pos) { +// returns the size of the checkbox, including the label +static v2 checkbox_frame(Ted *ted, bool *value, char const *label, v2 pos) { Font *font = ted->font; float char_height = text_font_char_height(font); float checkbox_size = char_height; Settings const *settings = &ted->settings; u32 const *colors = settings->colors; + float padding = settings->padding; Rect checkbox_rect = rect(pos, V2(checkbox_size, checkbox_size)); @@ -615,13 +617,17 @@ static void checkbox_frame(Ted *ted, bool *value, char const *label, v2 pos) { } } - if (*value) - gl_geometry_rect(checkbox_rect, colors[COLOR_TEXT]); - else - gl_geometry_rect_border(checkbox_rect, 1, colors[COLOR_TEXT]); - v2 text_pos = v2_add(pos, V2(checkbox_size, 0)); + checkbox_rect.pos = v2_add(checkbox_rect.pos, V2(0.5f, 0.5f)); + gl_geometry_rect_border(checkbox_rect, 1, colors[COLOR_TEXT]); + if (*value) { + gl_geometry_rect(rect_shrink(checkbox_rect, checkbox_size * 0.2f), colors[COLOR_TEXT]); + } + + v2 text_pos = v2_add(pos, V2(checkbox_size + padding * 0.5f, 0)); + v2 size = text_get_size_v2(font, label); text_utf8(font, label, text_pos.x, text_pos.y, colors[COLOR_TEXT]); gl_geometry_draw(); text_render(font); + return v2_add(size, V2(checkbox_size + padding * 0.5f, 0)); } |