summaryrefslogtreecommitdiff
path: root/ui.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-27 17:45:04 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-27 17:45:04 -0500
commit4554db338221f8fd1c7b4855b8d5bc50780815d2 (patch)
tree330e1f1130c758190c68830d7367927e9b9035a4 /ui.c
parentf02fa3b6e1f6c3b1c1325b999f101b5ca6e02558 (diff)
more warn overwrite
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/ui.c b/ui.c
index b09c8f6..05e4110 100644
--- a/ui.c
+++ b/ui.c
@@ -476,15 +476,47 @@ static PopupOption popup_update(Ted *ted) {
static void popup_render(Ted *ted, char const *title, char const *body) {
float window_width = ted->window_width;
float window_height = ted->window_height;
+ Font *font = ted->font;
+ Font *font_bold = ted->font_bold;
Rect r = rect_centered(V2(window_width * 0.5f, window_height * 0.5f), V2(300, 200));
Settings const *settings = &ted->settings;
u32 const *colors = settings->colors;
+ float const char_height_bold = text_font_char_height(font_bold);
+ float const padding = settings->padding;
glBegin(GL_QUADS);
gl_color_rgba(colors[COLOR_MENU_BG]);
rect_render(r);
+ gl_color_rgba(colors[COLOR_BORDER]);
+ rect_render_border(r, 1);
+ glEnd();
+
+ float y = r.pos.y;
+ // title text
+ v2 title_size = {0};
+ text_get_size(font_bold, title, &title_size.x, &title_size.y);
+ v2 title_pos = v2_sub(V2(window_width * 0.5f, y), V2(title_size.x * 0.5f, 0));
+ gl_color_rgba(colors[COLOR_TEXT]);
+ text_render(font_bold, title, title_pos.x, title_pos.y);
+
+ y += char_height_bold;
+ // line separating text from body
+ glBegin(GL_LINES);
+ gl_color_rgba(colors[COLOR_BORDER]);
+ glVertex2f(rect_x1(r), y);
+ glVertex2f(rect_x2(r), y);
glEnd();
- (void)title;
- (void)body;
+ y += padding;
+
+ // body text
+ gl_color_rgba(colors[COLOR_TEXT]);
+ float text_x1 = rect_x1(r) + padding;
+ float text_x2 = rect_x2(r) - padding;
+ TextRenderState state = {
+ .render = true, .wrap = true,
+ .min_x = text_x1, .max_x = text_x2,
+ .min_y = -FLT_MAX, .max_y = +FLT_MAX
+ };
+ text_render_with_state(font, &state, body, text_x1, y);
}