Tree Fix line rendering when drag and dropping TreeItem
This commit is contained in:
parent
f5e83e7305
commit
92ea0f7dd9
|
@ -1206,21 +1206,27 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drop_mode_flags && drop_mode_over == p_item) {
|
if (drop_mode_flags && drop_mode_over) {
|
||||||
Rect2 r = cell_rect;
|
Rect2 r = cell_rect;
|
||||||
bool has_parent = p_item->get_children() != nullptr;
|
if (drop_mode_over == p_item) {
|
||||||
|
if (drop_mode_section == 0 || drop_mode_section == -1) {
|
||||||
if (drop_mode_section == -1 || has_parent || drop_mode_section == 0) {
|
// Line above.
|
||||||
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color);
|
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color);
|
||||||
}
|
}
|
||||||
|
if (drop_mode_section == 0) {
|
||||||
if (drop_mode_section == 0) {
|
// Side lines.
|
||||||
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color);
|
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color);
|
||||||
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color);
|
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color);
|
||||||
}
|
}
|
||||||
|
if (drop_mode_section == 0 || (drop_mode_section == 1 && (!p_item->get_children() || p_item->is_collapsed()))) {
|
||||||
if ((drop_mode_section == 1 && !has_parent) || drop_mode_section == 0) {
|
// Line below.
|
||||||
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color);
|
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color);
|
||||||
|
}
|
||||||
|
} else if (drop_mode_over == p_item->get_parent()) {
|
||||||
|
if (drop_mode_section == 1 && !p_item->get_prev() /* && !drop_mode_over->is_collapsed() */) { // The drop_mode_over shouldn't ever be collapsed in here, otherwise we would be drawing a child of a collapsed item.
|
||||||
|
// Line above.
|
||||||
|
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue