diff options
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r-- | scene/gui/tree.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index f5eafba513..b1a421c24f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1423,17 +1423,33 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 #endif Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs; - VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width); - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color, line_width); + + if (root_pos.y + line_width >= 0) { + VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width); + VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color, line_width); + } + + if (htotal < 0) { + return -1; + } } - int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c); + if (htotal >= 0) { + int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c); - if (child_h < 0 && cache.draw_relationship_lines == 0) - return -1; // break, stop drawing, no need to anymore + if (child_h < 0) { + if (cache.draw_relationship_lines == 0) { + return -1; // break, stop drawing, no need to anymore + } else { + htotal = -1; + children_pos.y = cache.offset.y + p_draw_size.height; + } + } else { + htotal += child_h; + children_pos.y += child_h; + } + } - htotal += child_h; - children_pos.y += child_h; c = c->next; } } |