Skip to content

Commit 1794098

Browse files
committed
[TextEdit] Fix margin rounding at sub 100% scale.
1 parent 1b4ed4c commit 1794098

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

scene/gui/text_edit.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ void TextEdit::_notification(int p_what) {
694694

695695
int first_vis_line = get_first_visible_line();
696696
int row_height = get_line_height();
697-
int xmargin_beg = theme_cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding;
697+
int xmargin_beg = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT)) + gutters_width + gutter_padding;
698698
Size2 size = get_size();
699699
bool rtl = is_layout_rtl();
700700
int lines_drawn = 0;
@@ -855,9 +855,9 @@ void TextEdit::_notification(int p_what) {
855855
_update_scrollbars();
856856

857857
RID ci = get_canvas_item();
858-
int xmargin_beg = theme_cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding;
858+
int xmargin_beg = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT)) + gutters_width + gutter_padding;
859859

860-
int xmargin_end = size.width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
860+
int xmargin_end = size.width - Math::ceil(theme_cache.style_normal->get_margin(SIDE_RIGHT));
861861
if (draw_minimap) {
862862
xmargin_end -= minimap_width;
863863
}
@@ -1345,7 +1345,7 @@ void TextEdit::_notification(int p_what) {
13451345

13461346
cache_entry.y_offset = ofs_y;
13471347

1348-
int gutter_offset = theme_cache.style_normal->get_margin(SIDE_LEFT);
1348+
int gutter_offset = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT));
13491349
for (int g = 0; g < gutters.size(); g++) {
13501350
const GutterInfo &gutter = gutters[g];
13511351

@@ -2186,7 +2186,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
21862186
emit_signal(SNAME("gutter_clicked"), hovered_gutter.y, hovered_gutter.x);
21872187
return;
21882188
}
2189-
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
2189+
int left_margin = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT));
21902190
if (mpos.x < left_margin + gutters_width + gutter_padding) {
21912191
return;
21922192
}
@@ -3468,12 +3468,12 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
34683468
return CURSOR_ARROW;
34693469
}
34703470
}
3471-
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
3471+
int left_margin = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT));
34723472
if (p_pos.x < left_margin + gutters_width + gutter_padding) {
34733473
return CURSOR_ARROW;
34743474
}
34753475

3476-
int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
3476+
int xmargin_end = get_size().width - Math::ceil(theme_cache.style_normal->get_margin(SIDE_RIGHT));
34773477
if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) {
34783478
return CURSOR_ARROW;
34793479
}
@@ -4872,7 +4872,7 @@ Point2i TextEdit::get_line_column_at_pos(const Point2i &p_pos, bool p_clamp_line
48724872
return Point2i(-1, -1);
48734873
}
48744874

4875-
int colx = p_pos.x - (theme_cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding);
4875+
int colx = p_pos.x - (Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT)) + gutters_width + gutter_padding);
48764876
colx += first_visible_col;
48774877
if (!editable) {
48784878
colx -= theme_cache.style_readonly->get_offset().x / 2;
@@ -4941,7 +4941,7 @@ Rect2i TextEdit::get_rect_at_line_column(int p_line, int p_column) const {
49414941

49424942
Point2i pos, size;
49434943
pos.y = cache_entry.y_offset + get_line_height() * wrap_index;
4944-
pos.x = get_total_gutter_width() + theme_cache.style_normal->get_margin(SIDE_LEFT) - get_h_scroll();
4944+
pos.x = get_total_gutter_width() + Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT)) - get_h_scroll();
49454945

49464946
RID text_rid = text.get_line_data(p_line)->get_line_rid(wrap_index);
49474947
Vector2 col_bounds = TS->shaped_text_get_grapheme_bounds(text_rid, p_column);
@@ -8718,7 +8718,7 @@ void TextEdit::_adjust_viewport_to_caret_horizontally(int p_caret, bool p_maximi
87188718

87198719
void TextEdit::_update_minimap_hover() {
87208720
const Point2 mp = get_local_mouse_pos();
8721-
const int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
8721+
const int xmargin_end = get_size().width - Math::ceil(theme_cache.style_normal->get_margin(SIDE_RIGHT));
87228722

87238723
bool hovering_sidebar = mp.x > xmargin_end - minimap_width && mp.x < xmargin_end;
87248724
if (!hovering_sidebar) {
@@ -8745,7 +8745,7 @@ void TextEdit::_update_minimap_hover() {
87458745
void TextEdit::_update_minimap_click() {
87468746
Point2 mp = get_local_mouse_pos();
87478747

8748-
int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
8748+
int xmargin_end = get_size().width - Math::ceil(theme_cache.style_normal->get_margin(SIDE_RIGHT));
87498749
if (!dragging_minimap && (mp.x < xmargin_end - minimap_width || mp.x > xmargin_end)) {
87508750
minimap_clicked = false;
87518751
return;
@@ -8808,7 +8808,7 @@ void TextEdit::_update_gutter_width() {
88088808
}
88098809

88108810
Vector2i TextEdit::_get_hovered_gutter(const Point2 &p_mouse_pos) const {
8811-
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
8811+
int left_margin = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT));
88128812
if (p_mouse_pos.x > left_margin + gutters_width + gutter_padding) {
88138813
return Vector2i(-1, -1);
88148814
}

0 commit comments

Comments
 (0)