From dba0d5234989580117ddf6c7bec63364cac627b7 Mon Sep 17 00:00:00 2001 From: albertfay1121 Date: Wed, 23 Feb 2022 12:31:51 -0800 Subject: [PATCH] Fixed bug with text going under scrollbar added classes reference update --- doc/classes/ItemList.xml | 2 +- scene/gui/item_list.cpp | 6 ++++-- scene/gui/item_list.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 875d8d27b21..8b564c01c97 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -401,7 +401,7 @@ Allows single or multiple item selection. See the [enum SelectMode] constants. - + Sets the clipping behavior when the text exceeds an item's bounding rectangle. See [enum TextParagraph.OverrunBehavior] for a description of all modes. diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 9585b4d51d6..e83524b06c9 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1241,7 +1241,7 @@ void ItemList::_notification(int p_what) { text_ofs.x = size.width - text_ofs.x - max_len; } - items.write[i].text_buf->set_width(max_len); + items.write[i].text_buf->set_width(width - text_ofs.x); if (rtl) { items.write[i].text_buf->set_alignment(HORIZONTAL_ALIGNMENT_RIGHT); @@ -1253,7 +1253,9 @@ void ItemList::_notification(int p_what) { items[i].text_buf->draw_outline(get_canvas_item(), text_ofs, outline_size, font_outline_color); } - items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate); + if (width - text_ofs.x > 0) { + items[i].text_buf->draw(get_canvas_item(), text_ofs, modulate); + } } } diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 77e910870f8..96735678c1b 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -99,7 +99,7 @@ private: SelectMode select_mode = SELECT_SINGLE; IconMode icon_mode = ICON_MODE_LEFT; VScrollBar *scroll_bar; - TextParagraph::OverrunBehavior text_overrun_behavior = TextParagraph::OVERRUN_NO_TRIMMING; + TextParagraph::OverrunBehavior text_overrun_behavior = TextParagraph::OVERRUN_TRIM_ELLIPSIS; uint64_t search_time_msec = 0; String search_string;