diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index c3e3088d69f..f9a5d76c806 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -383,7 +383,7 @@ - Color of the [LineEdit]'s caret (text cursor). + Color of the [LineEdit]'s caret (text cursor). This can be set to a fully transparent color to hide the caret entirely. Color used as default tint for the clear button. @@ -406,6 +406,9 @@ Color of the selection rectangle. + + The caret's width in pixels. Greater values can be used to improve accessibility by ensuring the caret is easily visible, or to ensure consistency with a large font size. + Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of 'M' characters (i.e. this amount of 'M' characters can be displayed without scrolling). diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 26ad20e85b0..5c93ca180d9 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -1223,7 +1223,7 @@ [Color] of the text behind the caret when using a block caret. - [Color] of the caret. + [Color] of the caret. This can be set to a fully transparent color to hide the caret entirely. Background [Color] of the line containing the caret. @@ -1252,6 +1252,9 @@ Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. + + The caret's width in pixels. Greater values can be used to improve accessibility by ensuring the caret is easily visible, or to ensure consistency with a large font size. If set to [code]0[/code] or lower, the caret width is automatically set to 1 pixel and multiplied by the display scaling factor. + Sets the spacing between the lines. diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f000f64caf9..00c024ab804 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -780,8 +780,6 @@ void LineEdit::_notification(int p_what) { ofs_max -= r_icon->get_width(); } - int caret_width = Math::round(1 * get_theme_default_base_scale()); - // Draw selections rects. Vector2 ofs = Point2(x_ofs + scroll_offset, y_ofs); if (selection.enabled) { @@ -843,6 +841,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(); + if (ime_text.length() == 0) { // Normal caret. CaretInfo caret = TS->shaped_text_get_carets(text_rid, caret_column); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 817a4453a89..b96302f8dc0 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1244,7 +1244,7 @@ void TextEdit::_notification(int p_what) { } // Carets. - int caret_width = Math::round(1 * get_theme_default_base_scale()); + const int caret_width = get_theme_constant(SNAME("caret_width")) * 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); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 549bd3ba120..ba7f882530d 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -407,6 +407,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_constant("minimum_character_width", "LineEdit", 4); theme->set_constant("outline_size", "LineEdit", 0); + theme->set_constant("caret_width", "LineEdit", 1); theme->set_icon("clear", "LineEdit", make_icon(line_edit_clear_png)); @@ -451,6 +452,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_constant("line_spacing", "TextEdit", 4 * scale); theme->set_constant("outline_size", "TextEdit", 0); + theme->set_constant("caret_width", "TextEdit", 1); // CodeEdit