Browse Source

Fix incorrect offsets of tooltip content in `CodeEdit`

Fix incorrect offsets of tooltip content in `CodeEdit`
Yuri Roubinsky 3 years ago
parent
commit
e70a0d950a
1 changed files with 3 additions and 3 deletions
  1. 3 3
      scene/gui/code_edit.cpp

+ 3 - 3
scene/gui/code_edit.cpp

@@ -227,17 +227,17 @@ void CodeEdit::_notification(int p_what) {
 						end = font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), font_size).x;
 						end = font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), font_size).x;
 					}
 					}
 
 
-					Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent() + font_height * i + yofs);
+					Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs);
 					round_ofs = round_ofs.round();
 					round_ofs = round_ofs.round();
 					draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HALIGN_LEFT, -1, font_size, font_color);
 					draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HALIGN_LEFT, -1, font_size, font_color);
 					if (end > 0) {
 					if (end > 0) {
 						// Draw an underline for the currently edited function parameter.
 						// Draw an underline for the currently edited function parameter.
-						const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + line_spacing);
+						const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs);
 						draw_line(b, b + Vector2(end - begin, 0), font_color, 2);
 						draw_line(b, b + Vector2(end - begin, 0), font_color, 2);
 
 
 						// Draw a translucent text highlight as well.
 						// Draw a translucent text highlight as well.
 						const Rect2 highlight_rect = Rect2(
 						const Rect2 highlight_rect = Rect2(
-								hint_ofs + sb->get_offset() + Vector2(begin, 0),
+								b - Vector2(0, font_height),
 								Vector2(end - begin, font_height));
 								Vector2(end - begin, font_height));
 						draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2));
 						draw_rect(highlight_rect, font_color * Color(1, 1, 1, 0.2));
 					}
 					}