From 0c424abe3c77fd488944aeff0ed9f36c1d5372ba Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 9 May 2021 12:41:47 +0200 Subject: [PATCH] Fix Tree's background focus outline displaying behind section headings (cherry picked from commit 63897f16b12d0f61a3c314a7a9836222c29bb646) --- scene/gui/tree.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 7eff2028392..8ebe102fb2a 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2872,18 +2872,12 @@ void Tree::_notification(int p_what) { RID ci = get_canvas_item(); Ref bg = cache.bg; - Ref bg_focus = get_stylebox("bg_focus"); Point2 draw_ofs; draw_ofs += bg->get_offset(); Size2 draw_size = get_size() - bg->get_minimum_size(); bg->draw(ci, Rect2(Point2(), get_size())); - if (has_focus()) { - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); - bg_focus->draw(ci, Rect2(Point2(), get_size())); - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); - } int tbh = _get_title_button_height(); @@ -2908,6 +2902,15 @@ void Tree::_notification(int p_what) { f->draw_halign(ci, tbrect.position + Point2i(sb->get_offset().x, (tbrect.size.height - f->get_height()) / 2 + f->get_ascent()), HALIGN_CENTER, clip_w, columns[i].title, cache.title_button_color); } } + + // Draw the background focus outline last, so that it is drawn in front of the section headings. + // Otherwise, section heading backgrounds can appear to be in front of the focus outline when scrolling. + if (has_focus()) { + VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); + const Ref bg_focus = get_stylebox("bg_focus"); + bg_focus->draw(ci, Rect2(Point2(), get_size())); + VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); + } } if (p_what == NOTIFICATION_THEME_CHANGED) {