diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-03 08:08:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-03 08:08:37 +0100 |
commit | 33fc69dfb055175bfd16372473fa63405a3463f8 (patch) | |
tree | fce549a6db56563cbdc740c063f5891208e9ab0c | |
parent | 65dce481b06dbdeda8490bbfa9d5a9c1379870b6 (diff) | |
parent | 816d332e51c4dc72aa4122d614782ff4dc5194c7 (diff) |
Merge pull request #58699 from Calinou/lineedit-textedit-fix-caret-disappearing
Fix LineEdit and TextEdit carets disappearing at theme scales below 1.0
-rw-r--r-- | scene/gui/line_edit.cpp | 3 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 883eb1a1ba..ff4e071a95 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -847,7 +847,8 @@ void LineEdit::_notification(int p_what) { // Draw carets. ofs.x = x_ofs + scroll_offset; if (draw_caret || drag_caret_force_displayed) { - const int caret_width = get_theme_constant(SNAME("caret_width")) * get_theme_default_base_scale(); + // Prevent carets from disappearing at theme scales below 1.0 (if the caret width is 1). + const int caret_width = get_theme_constant(SNAME("caret_width")) * MAX(1, get_theme_default_base_scale()); if (ime_text.length() == 0) { // Normal caret. diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index bbb2bdc5af..854a9e463c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1283,7 +1283,8 @@ void TextEdit::_notification(int p_what) { } // Carets. - const int caret_width = get_theme_constant(SNAME("caret_width")) * get_theme_default_base_scale(); + // Prevent carets from disappearing at theme scales below 1.0 (if the caret width is 1). + const int caret_width = get_theme_constant(SNAME("caret_width")) * MAX(1, get_theme_default_base_scale()); if (!clipped && caret.line == line && line_wrap_index == caret_wrap_index) { caret.draw_pos.y = ofs_y + ldata->get_line_descent(line_wrap_index); |