Fixed cases where labels with autowrap can overflow the editor ui
Fixes #33155
This commit is contained in:
parent
5dac35a300
commit
13c88878c4
7 changed files with 16 additions and 3 deletions
|
@ -5818,6 +5818,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
|
|||
info_message->set_valign(Label::VALIGN_CENTER);
|
||||
info_message->set_align(Label::ALIGN_CENTER);
|
||||
info_message->set_autowrap(true);
|
||||
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
|
||||
main_panel->add_child(info_message);
|
||||
|
||||
|
|
|
@ -529,6 +529,7 @@ GroupDialog::GroupDialog() {
|
|||
group_empty->set_valign(Label::VALIGN_CENTER);
|
||||
group_empty->set_align(Label::ALIGN_CENTER);
|
||||
group_empty->set_autowrap(true);
|
||||
group_empty->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
nodes_to_remove->add_child(group_empty);
|
||||
group_empty->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
|
||||
|
||||
|
|
|
@ -1996,6 +1996,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
|
|||
info_message->set_valign(Label::VALIGN_CENTER);
|
||||
info_message->set_align(Label::ALIGN_CENTER);
|
||||
info_message->set_autowrap(true);
|
||||
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
|
||||
palette->add_child(info_message);
|
||||
|
||||
|
|
|
@ -584,6 +584,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
|
|||
empty_message->set_valign(Label::VALIGN_CENTER);
|
||||
empty_message->set_align(Label::ALIGN_CENTER);
|
||||
empty_message->set_autowrap(true);
|
||||
empty_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
empty_message->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
main_vb->add_child(empty_message);
|
||||
|
||||
|
|
|
@ -2424,6 +2424,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||
info_message->set_valign(Label::VALIGN_CENTER);
|
||||
info_message->set_align(Label::ALIGN_CENTER);
|
||||
info_message->set_autowrap(true);
|
||||
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
|
||||
perf_draw->add_child(info_message);
|
||||
}
|
||||
|
|
|
@ -1330,6 +1330,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
|||
info_message->set_valign(Label::VALIGN_CENTER);
|
||||
info_message->set_align(Label::ALIGN_CENTER);
|
||||
info_message->set_autowrap(true);
|
||||
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
|
||||
mesh_library_palette->add_child(info_message);
|
||||
|
||||
|
|
|
@ -296,8 +296,9 @@ Size2 Label::get_minimum_size() const {
|
|||
Size2 min_style = get_stylebox("normal")->get_minimum_size();
|
||||
|
||||
// don't want to mutable everything
|
||||
if (word_cache_dirty)
|
||||
if (word_cache_dirty) {
|
||||
const_cast<Label *>(this)->regenerate_word_cache();
|
||||
}
|
||||
|
||||
if (autowrap)
|
||||
return Size2(1, clip ? 1 : minsize.height) + min_style;
|
||||
|
@ -377,8 +378,14 @@ void Label::regenerate_word_cache() {
|
|||
memdelete(current);
|
||||
}
|
||||
|
||||
Ref<StyleBox> style = get_stylebox("normal");
|
||||
int width = autowrap ? (get_size().width - style->get_minimum_size().width) : get_longest_line_width();
|
||||
int width;
|
||||
if (autowrap) {
|
||||
Ref<StyleBox> style = get_stylebox("normal");
|
||||
width = MAX(get_size().width, get_custom_minimum_size().width) - style->get_minimum_size().width;
|
||||
} else {
|
||||
width = get_longest_line_width();
|
||||
}
|
||||
|
||||
Ref<Font> font = get_font("font");
|
||||
|
||||
int current_word_size = 0;
|
||||
|
|
Loading…
Reference in a new issue