Skip to content

Commit caefb0f

Browse files
committed
Merge pull request #110527 from WhalesState/text-edit-styles
Fix TextEdit `read_only` drawing.
2 parents 817974e + c079665 commit caefb0f

File tree

4 files changed

+86
-107
lines changed

4 files changed

+86
-107
lines changed

scene/gui/code_edit.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ void CodeEdit::_draw_guidelines() {
270270
const Size2 size = get_size();
271271
const bool rtl = is_layout_rtl();
272272

273-
const int xmargin_beg = theme_cache.style_normal->get_margin(SIDE_LEFT) + get_total_gutter_width();
274-
const int xmargin_end = size.width - theme_cache.style_normal->get_margin(SIDE_RIGHT) - (is_drawing_minimap() ? get_minimap_width() : 0);
273+
Ref<StyleBox> style = is_editable() ? theme_cache.style_normal : theme_cache.style_readonly;
274+
const int xmargin_beg = style->get_margin(SIDE_LEFT) + get_total_gutter_width();
275+
const int xmargin_end = size.width - style->get_margin(SIDE_RIGHT) - (is_drawing_minimap() ? get_minimap_width() : 0);
275276

276277
for (int i = 0; i < line_length_guideline_columns.size(); i++) {
277278
const int column_pos = theme_cache.font->get_string_size(String("0").repeat((int)line_length_guideline_columns[i]), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x;
@@ -3010,6 +3011,7 @@ void CodeEdit::_bind_methods() {
30103011

30113012
/* Other visuals */
30123013
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, CodeEdit, style_normal, "normal");
3014+
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, CodeEdit, style_readonly, "read_only");
30133015

30143016
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CodeEdit, brace_mismatch_color);
30153017

scene/gui/code_edit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ class CodeEdit : public TextEdit {
290290

291291
/* Other visuals */
292292
Ref<StyleBox> style_normal;
293+
Ref<StyleBox> style_readonly;
293294

294295
Color brace_mismatch_color;
295296

0 commit comments

Comments
 (0)