From 0ee78a79cf351aaeab25ad9771a20ae8e5794023 Mon Sep 17 00:00:00 2001 From: havi05 Date: Sun, 15 Dec 2024 14:08:47 +0100 Subject: [PATCH] Itemlist - draw focus stylebox after items --- scene/gui/item_list.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index a79835dc527..e114aa0452a 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1087,12 +1087,6 @@ void ItemList::_notification(int p_what) { } bool rtl = is_layout_rtl(); - if (has_focus()) { - RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true); - draw_style_box(theme_cache.focus_style, Rect2(Point2(), size)); - RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false); - } - // 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; @@ -1381,6 +1375,7 @@ void ItemList::_notification(int p_what) { cursor_rcache = rcache; } } + if (cursor_rcache.size != Size2()) { // Draw cursor last, so border isn't cut off. cursor_rcache.position += base_ofs; @@ -1390,6 +1385,12 @@ void ItemList::_notification(int p_what) { draw_style_box(cursor, cursor_rcache); } + + if (has_focus()) { + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true); + draw_style_box(theme_cache.focus_style, Rect2(Point2(), size)); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false); + } } break; } }