summaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-27 19:47:31 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-27 19:47:31 -0500
commitaea002f290e5eddde98eb394fa7a9145c325fffe (patch)
tree11533f72e6f56cabf26d02cd5e48d69f666b51f4 /ui.c
parent4554db338221f8fd1c7b4855b8d5bc50780815d2 (diff)
buttons (for warn overwrite popup)
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ui.c b/ui.c
index 05e4110..827f73c 100644
--- a/ui.c
+++ b/ui.c
@@ -461,6 +461,24 @@ static void file_selector_render(Ted *ted, FileSelector *fs) {
}
}
+static void button_render(Ted *ted, Rect button, char const *text, u32 color) {
+ u32 const *colors = ted->settings.colors;
+
+ glBegin(GL_QUADS);
+ if (rect_contains_point(button, ted->mouse_pos)) {
+ // highlight button when hovering over it
+ gl_color_rgba((color & 0xffffff00) | ((color & 0xff) / 3));
+ rect_render(button);
+ }
+ gl_color_rgba(colors[COLOR_BORDER]);
+ rect_render_border(button, 1);
+ glEnd();
+
+ gl_color_rgba(color);
+ v2 pos = rect_center(button);
+ text_render_anchored(ted->font, text, pos.x, pos.y, ANCHOR_MIDDLE);
+}
+
typedef enum {
POPUP_NONE,
POPUP_YES,
@@ -519,4 +537,15 @@ static void popup_render(Ted *ted, char const *title, char const *body) {
.min_y = -FLT_MAX, .max_y = +FLT_MAX
};
text_render_with_state(font, &state, body, text_x1, y);
+
+ float button_height = 30;
+ u16 nbuttons = 3;
+ float button_width = r.size.x / nbuttons;
+ Rect button_yes = rect(V2(r.pos.x, rect_y2(r) - button_height), V2(button_width, button_height));
+ Rect button_no = rect_translate(button_yes, V2(button_width, 0));
+ Rect button_cancel = rect_translate(button_no, V2(button_width, 0));
+
+ button_render(ted, button_yes, "Yes", colors[COLOR_YES]);
+ button_render(ted, button_no, "No", colors[COLOR_NO]);
+ button_render(ted, button_cancel, "Cancel", colors[COLOR_CANCEL]);
}