| 3214 | } |
| 3215 | |
| 3216 | Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { |
| 3217 | if (tab_container->get_tab_count() == 0) { |
| 3218 | return Variant(); |
| 3219 | } |
| 3220 | |
| 3221 | Node *cur_node = tab_container->get_tab_control(tab_container->get_current_tab()); |
| 3222 | |
| 3223 | HBoxContainer *drag_preview = memnew(HBoxContainer); |
| 3224 | String preview_name = ""; |
| 3225 | Ref<Texture2D> preview_icon; |
| 3226 | |
| 3227 | ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node); |
| 3228 | if (se) { |
| 3229 | preview_name = se->get_name(); |
| 3230 | preview_icon = se->get_theme_icon(); |
| 3231 | } |
| 3232 | EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); |
| 3233 | if (eh) { |
| 3234 | preview_name = eh->get_class(); |
| 3235 | preview_icon = get_editor_theme_icon(SNAME("Help")); |
| 3236 | } |
| 3237 | |
| 3238 | if (preview_icon.is_valid()) { |
| 3239 | TextureRect *tf = memnew(TextureRect); |
| 3240 | tf->set_texture(preview_icon); |
| 3241 | tf->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); |
| 3242 | drag_preview->add_child(tf); |
| 3243 | } |
| 3244 | Label *label = memnew(Label(preview_name)); |
| 3245 | label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); // Don't translate script names and class names. |
| 3246 | drag_preview->add_child(label); |
| 3247 | set_drag_preview(drag_preview); |
| 3248 | |
| 3249 | Dictionary drag_data; |
| 3250 | drag_data["type"] = "script_list_element"; // using a custom type because node caused problems when dragging to scene tree |
| 3251 | drag_data["script_list_element"] = cur_node; |
| 3252 | |
| 3253 | return drag_data; |
| 3254 | } |
| 3255 | |
| 3256 | bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { |
| 3257 | Dictionary d = p_data; |
nothing calls this directly
no test coverage detected