Merge pull request #15314 from poke1024/tree-rlines
Tree: only draw visible relationship lines
This commit is contained in:
commit
465d66be67
1 changed files with 23 additions and 7 deletions
|
@ -1423,17 +1423,33 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||||
#endif
|
#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;
|
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)
|
if (child_h < 0) {
|
||||||
return -1; // break, stop drawing, no need to anymore
|
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;
|
c = c->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue