summaryrefslogtreecommitdiffstats
path: root/editor/debugger/editor_debugger_tree.cpp
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-02 03:14:40 -0400
committerSpartan322 <Megacake1234@gmail.com>2024-11-02 03:22:12 -0400
commita684ee1dec108bb1a050f07ec3dd73fd5ef02dbc (patch)
treee9de2ee4820e24a159d2c06b1ace11f89c4e97c4 /editor/debugger/editor_debugger_tree.cpp
parent3302f803aa4ea09b16a8824ca3bea33f3e2b48ba (diff)
parentc6c464cf9ae56e8b68620af65125dd980d0e8122 (diff)
downloadredot-engine-a684ee1dec108bb1a050f07ec3dd73fd5ef02dbc.tar.gz
Merge commit godotengine/godot@c6c464cf9ae56e8b68620af65125dd980d0e8122
Diffstat (limited to 'editor/debugger/editor_debugger_tree.cpp')
-rw-r--r--editor/debugger/editor_debugger_tree.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index 4a63025122..85727c7895 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -32,6 +32,7 @@
#include "editor_debugger_tree.h"
+#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_file_dialog.h"
@@ -150,7 +151,8 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
updating_scene_tree = true;
const String last_path = get_selected_path();
const String filter = SceneTreeDock::get_singleton()->get_filter();
- bool filter_changed = filter != last_filter;
+ bool should_scroll = scrolling_to_item || filter != last_filter;
+ scrolling_to_item = false;
TreeItem *scroll_item = nullptr;
// Nodes are in a flatten list, depth first. Use a stack of parents, avoid recursion.
@@ -187,8 +189,18 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
// Select previously selected node.
if (debugger_id == p_debugger) { // Can use remote id.
if (node.id == inspected_object_id) {
+ if (selection_uncollapse_all) {
+ selection_uncollapse_all = false;
+
+ // Temporarily set to `false`, to allow caching the unfolds.
+ updating_scene_tree = false;
+ item->uncollapse_tree();
+ updating_scene_tree = true;
+ }
+
item->select(0);
- if (filter_changed) {
+
+ if (should_scroll) {
scroll_item = item;
}
}
@@ -196,7 +208,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
if (last_path == _get_path(item)) {
updating_scene_tree = false; // Force emission of new selection.
item->select(0);
- if (filter_changed) {
+ if (should_scroll) {
scroll_item = item;
}
updating_scene_tree = true;
@@ -260,14 +272,30 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int
}
}
}
- debugger_id = p_debugger; // Needed by hook, could be avoided if every debugger had its own tree
+
+ debugger_id = p_debugger; // Needed by hook, could be avoided if every debugger had its own tree.
if (scroll_item) {
- callable_mp((Tree *)this, &Tree::scroll_to_item).call_deferred(scroll_item, false);
+ scroll_to_item(scroll_item, false);
}
last_filter = filter;
updating_scene_tree = false;
}
+void EditorDebuggerTree::select_node(ObjectID p_id) {
+ // Manually select, as the tree control may be out-of-date for some reason (e.g. not shown yet).
+ selection_uncollapse_all = true;
+ inspected_object_id = uint64_t(p_id);
+ scrolling_to_item = true;
+ emit_signal(SNAME("object_selected"), inspected_object_id, debugger_id);
+
+ if (!updating_scene_tree) {
+ // Request a tree refresh.
+ EditorDebuggerNode::get_singleton()->request_remote_tree();
+ }
+ // Set the value immediately, so no update flooding happens and causes a crash.
+ updating_scene_tree = true;
+}
+
Variant EditorDebuggerTree::get_drag_data(const Point2 &p_point) {
if (get_button_id_at_position(p_point) != -1) {
return Variant();