From bf7422e2c74e7310061b396058089179157fc974 Mon Sep 17 00:00:00 2001 From: danielgsilva Date: Fri, 29 Aug 2025 14:03:39 +0100 Subject: [PATCH] Take into account parent and child folding status when drawing relatioship lines --- scene/gui/tree.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 7d6ca962083..cf378e91b00 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2744,15 +2744,12 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 // Draw relationship lines. if (theme_cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root) && c->is_visible_in_tree()) { - int parent_ofs = p_pos.x + theme_cache.item_margin; - Point2i parent_pos = Point2i(parent_ofs - theme_cache.arrow->get_width() * 0.5, p_pos.y + label_h * 0.5 + theme_cache.arrow->get_height() * 0.5) - theme_cache.offset + p_draw_ofs; + int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? theme_cache.h_separation : theme_cache.item_margin - theme_cache.arrow->get_width() * 0.5); + Point2i parent_pos = Point2i(parent_ofs, p_pos.y + label_h * 0.5 + theme_cache.arrow->get_height() * 0.5) - theme_cache.offset + p_draw_ofs; - int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? theme_cache.h_separation : theme_cache.item_margin); + int root_ofs = children_pos.x + ((c->disable_folding || hide_folding) ? theme_cache.h_separation : theme_cache.item_margin - (c->get_visible_child_count() > 0 ? theme_cache.arrow->get_width() : 0)); + root_ofs = MIN(root_ofs, get_column_width(0) + p_draw_ofs.x); Point2i root_pos = Point2i(root_ofs, children_pos.y + child_self_height * 0.5) - theme_cache.offset + p_draw_ofs; - if (!hide_folding && !p_item->disable_folding && c->get_visible_child_count() > 0) { - root_pos -= Point2i(theme_cache.arrow->get_width(), 0); - } - root_pos.x = MIN(root_pos.x, get_column_width(0) + p_draw_ofs.x); bool is_no_space = root_pos.x <= parent_pos.x;