diff options
Diffstat (limited to 'scene/gui/tree.cpp')
-rw-r--r-- | scene/gui/tree.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 47761d724e..2f5ee20373 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1208,8 +1208,9 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (drop_mode_flags && drop_mode_over == p_item) { Rect2 r = cell_rect; + bool has_parent = p_item->get_children() != nullptr; - if (drop_mode_section == -1 || drop_mode_section == 0) { + if (drop_mode_section == -1 || has_parent || drop_mode_section == 0) { RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color); } @@ -1218,7 +1219,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 RenderingServer::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 == 1 || drop_mode_section == 0) { + if ((drop_mode_section == 1 && !has_parent) || drop_mode_section == 0) { RenderingServer::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); } } @@ -1971,7 +1972,7 @@ void Tree::_text_editor_enter(String p_text) { //popup_edited_item->edited_signal.call( popup_edited_item_col ); } break; case TreeItem::CELL_MODE_RANGE: { - c.val = p_text.to_double(); + c.val = p_text.to_float(); if (c.step > 0) { c.val = Math::stepify(c.val, c.step); } @@ -2403,11 +2404,16 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { cache.hover_cell = col; if (it != old_it || col != old_col) { - // Only need to update if mouse enters/exits a button - bool was_over_button = old_it && old_it->cells[old_col].custom_button; - bool is_over_button = it && it->cells[col].custom_button; - if (was_over_button || is_over_button) { + if (old_it && old_col >= old_it->cells.size()) { + // Columns may have changed since last update(). update(); + } else { + // Only need to update if mouse enters/exits a button + bool was_over_button = old_it && old_it->cells[old_col].custom_button; + bool is_over_button = it && it->cells[col].custom_button; + if (was_over_button || is_over_button) { + update(); + } } } } @@ -3419,6 +3425,8 @@ void Tree::scroll_to_item(TreeItem *p_item) { TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) { TreeItem *from = p_at; + TreeItem *loop = nullptr; // Safe-guard against infinite loop. + while (p_at) { for (int i = 0; i < columns.size(); i++) { if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) { @@ -3438,6 +3446,12 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c if ((p_at) == from) { break; } + + if (!loop) { + loop = p_at; + } else if (loop == p_at) { + break; + } } return nullptr; @@ -3878,7 +3892,7 @@ Tree::Tree() { popup_menu = memnew(PopupMenu); popup_menu->hide(); add_child(popup_menu); - // popup_menu->set_as_toplevel(true); + // popup_menu->set_as_top_level(true); popup_editor = memnew(Popup); popup_editor->set_wrap_controls(true); |