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 +++++++++---- src/windows/platform.c | 10 +++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') 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; diff --git a/src/windows/platform.c b/src/windows/platform.c index 375024a..0a1357b 100644 --- a/src/windows/platform.c +++ b/src/windows/platform.c @@ -4,6 +4,7 @@ * All rights reserved. */ +#include #include #include #include @@ -520,7 +521,14 @@ LRESULT CALLBACK main_window_callback(HWND window, UINT message, WPARAM wparam, void platform_window_set_title(platform_window *window, char *name) { - SetWindowText(window->window_handle, name); + s32 len = strlen(name)+1; + wchar_t wc[len]; + mbstowcs(wc, name, len); + + LONG_PTR originalWndProc = GetWindowLongPtrW(window->window_handle, GWLP_WNDPROC); + SetWindowLongPtrW(window->window_handle, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); + SetWindowTextW(window->window_handle, wc); + SetWindowLongPtrW(window->window_handle, GWLP_WNDPROC, originalWndProc); } vec2 platform_get_window_size(platform_window *window) -- cgit v1.2.3-70-g09d2