Skip to content

Commit a9881bb

Browse files
committed
Fix TextEdit drawing both normal and read_only styles together.
1 parent 149a4b4 commit a9881bb

File tree

4 files changed

+90
-109
lines changed

4 files changed

+90
-109
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 = Math::ceil(style->get_margin(SIDE_LEFT)) + get_total_gutter_width();
275+
const int xmargin_end = size.width - Math::ceil(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;
@@ -3008,6 +3009,7 @@ void CodeEdit::_bind_methods() {
30083009

30093010
/* Other visuals */
30103011
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, CodeEdit, style_normal, "normal");
3012+
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, CodeEdit, style_readonly, "read_only");
30113013

30123014
BIND_THEME_ITEM(Theme::DATA_TYPE_COLOR, CodeEdit, brace_mismatch_color);
30133015

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)