diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-07-31 23:52:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-31 23:52:54 +0200 |
commit | f2791a75b39bd7c4060d837df8eaec807cc51dc2 (patch) | |
tree | b4caff14e3bf96d2d62051b5926cfbf24c9b7d19 /editor/debugger | |
parent | 8ad80f054775e14541c2981b1a8985f8a7a4512e (diff) | |
parent | 64d133747b6fa13df4d356197dcd27f8e8f4936e (diff) |
Merge pull request #56063 from KoBeWi/dragging_nodes_over_wifi
Diffstat (limited to 'editor/debugger')
-rw-r--r-- | editor/debugger/editor_debugger_tree.cpp | 33 | ||||
-rw-r--r-- | editor/debugger/editor_debugger_tree.h | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index bdab1cfecb..dbd2c61d44 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -225,6 +225,39 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int updating_scene_tree = false; } +Variant EditorDebuggerTree::get_drag_data(const Point2 &p_point) { + if (get_button_id_at_position(p_point) != -1) { + return Variant(); + } + + TreeItem *selected = get_selected(); + if (!selected) { + return Variant(); + } + + String path = selected->get_text(0); + + HBoxContainer *hb = memnew(HBoxContainer); + TextureRect *tf = memnew(TextureRect); + tf->set_texture(selected->get_icon(0)); + tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); + hb->add_child(tf); + Label *label = memnew(Label(path)); + hb->add_child(label); + set_drag_preview(hb); + + if (!selected->get_parent() || !selected->get_parent()->get_parent()) { + path = "."; + } else { + while (selected->get_parent()->get_parent() != get_root()) { + selected = selected->get_parent(); + path = selected->get_text(0) + "/" + path; + } + } + + return vformat("\"%s\"", path); +} + String EditorDebuggerTree::get_selected_path() { if (!get_selected()) { return ""; diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 9d163fd548..5b2df8abd5 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -65,6 +65,8 @@ protected: void _notification(int p_what); public: + virtual Variant get_drag_data(const Point2 &p_point) override; + String get_selected_path(); ObjectID get_selected_object(); int get_current_debugger(); // Would love to have one tree for every debugger. |