diff options
| author | Aldrik Ramaekers <aldrik.ramaekers@protonmail.com> | 2020-05-15 18:41:45 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik.ramaekers@protonmail.com> | 2020-05-15 18:41:45 +0200 |
| commit | 67eaee3cc90dbe413d5707b1e259c5036b47f55f (patch) | |
| tree | b04b3444bfc150596f2ba88357dc6e2ec232b7b8 /src/ui.c | |
| parent | a7f382b431e6eed3f180c71d4175970da096eab9 (diff) | |
work
Diffstat (limited to 'src/ui.c')
| -rw-r--r-- | src/ui.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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;
|
