Merge pull request #56063 from KoBeWi/dragging_nodes_over_wifi

This commit is contained in:
Rémi Verschelde 2022-07-31 23:52:54 +02:00 committed by GitHub
commit f2791a75b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View file

@ -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 "";

View file

@ -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.