Merge pull request #110089 from dagarsar/tree-margin-1

Fix `Tree` relationship lines do not apply `h_separation` and `item_margin` correctly
This commit is contained in:
Thaddeus Crews 2025-09-19 20:54:27 -05:00
commit 647546bcac
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -2748,15 +2748,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;