diff options
author | Paulb23 <p_batty@hotmail.co.uk> | 2018-06-23 16:19:27 +0100 |
---|---|---|
committer | Paulb23 <p_batty@hotmail.co.uk> | 2018-06-24 10:38:53 +0100 |
commit | 8a168637fec47d2403f7697c32b570a76a5e4615 (patch) | |
tree | 36925bd22bdc6ccabc7ee01e8674551942600b2b /scene | |
parent | 25275de50e31aa081cdefe0c8b3b76b6389cb6a6 (diff) |
Fixed text drawing too high in TextEdit, issue 15688
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 215ba0271f..b9f3e7c6b5 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -960,12 +960,13 @@ void TextEdit::_notification(int p_what) { // draw line numbers if (cache.line_number_w) { + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; String fc = String::num(line + 1); while (fc.length() < line_number_char_count) { fc = line_num_padding + fc; } - cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + ofs_x, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color); + cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + ofs_x, yofs + cache.font->get_ascent()), fc, cache.line_number_color); } } @@ -1088,12 +1089,13 @@ void TextEdit::_notification(int p_what) { } if (brace_matching_enabled) { + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; if ((brace_open_match_line == line && brace_open_match_column == last_wrap_column + j) || (cursor.column == last_wrap_column + j && cursor.line == line && cursor_wrap_index == line_wrap_index && (brace_open_matching || brace_open_mismatch))) { if (brace_open_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } if ((brace_close_match_line == line && brace_close_match_column == last_wrap_column + j) || @@ -1101,7 +1103,7 @@ void TextEdit::_notification(int p_what) { if (brace_close_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } } @@ -1161,9 +1163,10 @@ void TextEdit::_notification(int p_what) { } if (str[j] >= 32) { - int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; + int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); if (underlined) { - draw_rect(Rect2(char_ofs + char_margin + ofs_x, ofs_y + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; |