From 08844b6143b4f6e52c66e679ff76d41e3e2affe4 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Sun, 21 Aug 2022 22:10:41 -0300 Subject: [PATCH] Fix `ItemList` selection visual when the scrollbar visibility changes (cherry picked from commit e298144a41338d80b5f0090ce8f28aef888c13dd) --- scene/gui/item_list.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 3ed6bdbe4a5..5c512bc05d0 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -754,11 +754,7 @@ void ItemList::_notification(int p_what) { scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -bg->get_margin(MARGIN_BOTTOM)); Size2 size = get_size(); - int width = size.width - bg->get_minimum_size().width; - if (scroll_bar->is_visible()) { - width -= mw; - } draw_style_box(bg, Rect2(Point2(), size)); @@ -917,6 +913,10 @@ void ItemList::_notification(int p_what) { shape_changed = false; } + if (scroll_bar->is_visible()) { + width -= mw; + } + //ensure_selected_visible needs to be checked before we draw the list. if (ensure_selected_visible && current >= 0 && current < items.size()) { Rect2 r = items[current].rect_cache;