| 6301 | } |
| 6302 | |
| 6303 | Dictionary EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { |
| 6304 | Control *drag_control = memnew(Control); |
| 6305 | TextureRect *drag_preview = memnew(TextureRect); |
| 6306 | Label *label = memnew(Label); |
| 6307 | label->set_focus_mode(Control::FOCUS_ACCESSIBILITY); |
| 6308 | label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); |
| 6309 | |
| 6310 | Ref<Texture2D> preview; |
| 6311 | |
| 6312 | { |
| 6313 | /// @todo Make proper previews |
| 6314 | Ref<Texture2D> texture = theme->get_icon(SNAME("FileBigThumb"), EditorStringName(EditorIcons)); |
| 6315 | if (texture.is_valid()) { |
| 6316 | Ref<Image> img = texture->get_image(); |
| 6317 | img = img->duplicate(); |
| 6318 | img->resize(48, 48); // meh |
| 6319 | preview = ImageTexture::create_from_image(img); |
| 6320 | } |
| 6321 | } |
| 6322 | |
| 6323 | drag_preview->set_texture(preview); |
| 6324 | drag_control->add_child(drag_preview); |
| 6325 | if (p_res->get_path().is_resource_file()) { |
| 6326 | label->set_text(p_res->get_path().get_file()); |
| 6327 | } else if (!p_res->get_name().is_empty()) { |
| 6328 | label->set_text(p_res->get_name()); |
| 6329 | } else { |
| 6330 | label->set_text(p_res->get_class()); |
| 6331 | } |
| 6332 | |
| 6333 | drag_control->add_child(label); |
| 6334 | |
| 6335 | p_from->set_drag_preview(drag_control); // Wait until it enters scene. |
| 6336 | |
| 6337 | label->set_position(Point2((preview->get_width() - label->get_minimum_size().width) / 2, preview->get_height())); |
| 6338 | |
| 6339 | Dictionary drag_data; |
| 6340 | drag_data["type"] = "resource"; |
| 6341 | drag_data["resource"] = p_res; |
| 6342 | drag_data["from"] = p_from; |
| 6343 | |
| 6344 | return drag_data; |
| 6345 | } |
| 6346 | |
| 6347 | Dictionary EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from) { |
| 6348 | bool has_folder = false; |
no test coverage detected