From 67eaee3cc90dbe413d5707b1e259c5036b47f55f Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Fri, 15 May 2020 18:41:45 +0200 Subject: work --- src/ui.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index 8869607..ebc21c8 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1026,10 +1026,10 @@ bool ui_push_hypertext_link(char *text) s32 x = global_ui_context.layout.offset_x + global_ui_context.camera->x; s32 y = global_ui_context.layout.offset_y + global_ui_context.camera->y + ui_get_scroll() - spacing_y; s32 text_x = x + WIDGET_PADDING; - s32 text_h = global_ui_context.font_small->px_h; + s32 text_h = global_ui_context.font_small->px_h + 10; s32 text_y = y + (BLOCK_HEIGHT/2) - (global_ui_context.font_small->px_h/2) + spacing_y; s32 total_w = calculate_text_width(global_ui_context.font_small, text) + - WIDGET_PADDING + WIDGET_PADDING; + WIDGET_PADDING + WIDGET_PADDING + 10; s32 mouse_x = global_ui_context.mouse->x + global_ui_context.camera->x; s32 mouse_y = global_ui_context.mouse->y + global_ui_context.camera->y; @@ -1037,8 +1037,10 @@ bool ui_push_hypertext_link(char *text) global_ui_context.layout.block_height = global_ui_context.font_small->px_h; color bg_color = global_ui_context.style.hypertext_foreground; + bool hovered = false; if (mouse_x >= text_x && mouse_x < text_x + total_w && mouse_y >= text_y && mouse_y < text_y+text_h && !global_ui_context.item_hovered) { + hovered = true; if (is_left_clicked(global_ui_context.mouse)) { result = true; @@ -1046,10 +1048,13 @@ bool ui_push_hypertext_link(char *text) bg_color = global_ui_context.style.hypertext_hover_foreground; } - s32 text_width = render_text(global_ui_context.font_small, text_x, text_y, text, bg_color); + s32 text_width = render_text(global_ui_context.font_small, text_x + 5, text_y + 5, text, bg_color); if (result) - render_rectangle(text_x, text_y + text_h+2, text_width, 1, bg_color); + render_rectangle(text_x, text_y+text_h+2, text_width+10, 1, bg_color); + else if (hovered) + render_rectangle(text_x, text_y+text_h, text_width+10, 1, bg_color); + if (global_ui_context.layout.layout_direction == LAYOUT_HORIZONTAL) global_ui_context.layout.offset_x += total_w; -- cgit v1.2.3-70-g09d2