From bacfe7a557838832a51add41e1d2ca7d08b886a7 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 19 Aug 2017 10:50:54 -0300 Subject: [PATCH] Fixes to label and code editor to make editing code hopefully fast again. --- editor/code_editor.cpp | 11 +++++++---- scene/gui/label.cpp | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 07c09451145..51b22df331a 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1222,10 +1222,11 @@ CodeTextEditor::CodeTextEditor() { error = memnew(Label); status_bar->add_child(error); error->hide(); + error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right error->set_valign(Label::VALIGN_CENTER); error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9)); - - status_bar->add_spacer(); + error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch + //status_bar->add_spacer(); Label *line_txt = memnew(Label); status_bar->add_child(line_txt); @@ -1238,7 +1239,8 @@ CodeTextEditor::CodeTextEditor() { status_bar->add_child(line_nb); line_nb->set_valign(Label::VALIGN_CENTER); line_nb->set_v_size_flags(SIZE_FILL); - line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change + line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch + line_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); Label *col_txt = memnew(Label); @@ -1252,7 +1254,8 @@ CodeTextEditor::CodeTextEditor() { status_bar->add_child(col_nb); col_nb->set_valign(Label::VALIGN_CENTER); col_nb->set_v_size_flags(SIZE_FILL); - col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change + col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch + col_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); text_editor->connect("gui_input", this, "_text_editor_gui_input"); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index b2afca8766f..84074f96a89 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -493,7 +493,10 @@ void Label::regenerate_word_cache() { minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1)); } - minimum_size_changed(); + if (!autowrap || !clip) { + //helps speed up some labels that may change a lot, as no resizing is requested. Do not change. + minimum_size_changed(); + } word_cache_dirty = false; }