summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/menu.c b/menu.c
index 7e1db53..c98fbc8 100644
--- a/menu.c
+++ b/menu.c
@@ -19,13 +19,17 @@ static void menu_close(Ted *ted, bool restore_prev_active_buffer) {
buffer_clear(&ted->line_buffer);
}
+static float menu_get_width(Ted *ted) {
+ Settings *settings = &ted->settings;
+ return minf(settings->max_menu_width, ted->window_width - 2.0f * settings->padding);
+}
+
// returns the rectangle of the screen coordinates of the menu
static Rect menu_rect(Ted *ted) {
Settings *settings = &ted->settings;
float window_width = ted->window_width, window_height = ted->window_height;
float padding = settings->padding;
- float menu_width = settings->max_menu_width;
- menu_width = minf(menu_width, window_width - 2 * padding);
+ float menu_width = menu_get_width(ted);
return rect(
V2(window_width * 0.5f - 0.5f * menu_width, padding),
V2(menu_width, window_height - 2 * padding)
@@ -63,27 +67,22 @@ static void menu_render(Ted *ted, Menu menu) {
if (menu == MENU_OPEN) {
float padding = settings->padding;
- float menu_x1 = window_width * 0.5f - 300;
- float menu_x2 = window_width * 0.5f + 300;
- menu_x1 = maxf(menu_x1, padding);
- menu_x2 = minf(menu_x2, window_width - padding);
- float menu_y1 = padding;
- float menu_y2 = window_height - padding;
- Rect menu_rect = rect4(menu_x1, menu_y1, menu_x2, menu_y2);
- float inner_padding = 10;
+ Rect rect = menu_rect(ted);
+ float menu_x1, menu_y1, menu_x2, menu_y2;
+ rect_coords(rect, &menu_x1, &menu_y1, &menu_x2, &menu_y2);
// menu rectangle & border
glBegin(GL_QUADS);
gl_color_rgba(colors[COLOR_MENU_BG]);
- rect_render(menu_rect);
+ rect_render(rect);
gl_color_rgba(colors[COLOR_BORDER]);
- rect_render_border(menu_rect, settings->border_thickness);
+ rect_render_border(rect, settings->border_thickness);
glEnd();
- menu_x1 += inner_padding;
- menu_y1 += inner_padding;
- menu_x2 -= inner_padding;
- menu_y2 -= inner_padding;
+ menu_x1 += padding;
+ menu_y1 += padding;
+ menu_x2 -= padding;
+ menu_y2 -= padding;
FileSelector *fs = &ted->file_selector;