From 8dc16e3a6926fe51b9beb11c6e98062c0a27332b Mon Sep 17 00:00:00 2001 From: eddebaby Date: Thu, 22 Apr 2021 19:17:41 +0100 Subject: [PATCH] Position tool tips correctly on high resolutions (#1020) Fixes #1003 --- src/gui_tooltips.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui_tooltips.c b/src/gui_tooltips.c index d1fd13bec3..e1aace0b96 100644 --- a/src/gui_tooltips.c +++ b/src/gui_tooltips.c @@ -72,7 +72,9 @@ void set_gui_tooltip_box_fmt(int bxtype,const char *format, ...) va_end(val); if (bxtype != 0) { tool_tip_box.pos_x = GetMouseX(); - tool_tip_box.pos_y = GetMouseY()+86; + long y_offset_times_two = (43 * units_per_pixel) >> 2; + long y_offset = (y_offset_times_two + (y_offset_times_two & 1)) >> 1; // equivalent to (86 * (units_per_pixel/16)) but accounts for rounding, 86 was the previous hard value of y_offset (meant for 640x400) + tool_tip_box.pos_y = GetMouseY() + y_offset; } tool_tip_box.field_809 = bxtype; } @@ -102,7 +104,9 @@ static inline TbBool update_gui_tooltip_button(struct GuiButton *gbtn) { tool_tip_box.gbutton = gbtn; tool_tip_box.pos_x = GetMouseX(); - tool_tip_box.pos_y = GetMouseY()+86; + long y_offset_times_two = (43 * units_per_pixel) >> 2; + long y_offset = (y_offset_times_two + (y_offset_times_two & 1)) >> 1; // equivalent to (86 * (units_per_pixel/16)) but accounts for rounding, 86 was the previous hard value of y_offset (meant for 640x400) + tool_tip_box.pos_y = GetMouseY() + y_offset; tool_tip_box.field_809 = 0; return true; }