diff --git a/scripts/startup/bl_operators/view3d.py b/scripts/startup/bl_operators/view3d.py index bb09082d218..6a7b9460030 100644 --- a/scripts/startup/bl_operators/view3d.py +++ b/scripts/startup/bl_operators/view3d.py @@ -3,7 +3,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later import bpy -from bpy.types import Operator +from bpy.types import ( + Operator, + FileHandler, +) from bpy.props import ( BoolProperty, EnumProperty, @@ -258,10 +261,40 @@ class VIEW3D_OT_transform_gizmo_set(Operator): return self.execute(context) +class VIEW3D_FH_empty_image(FileHandler): + bl_idname = "VIEW3D_FH_empty_image" + bl_label = "Add empty image" + bl_import_operator = "OBJECT_OT_empty_image_add" + bl_file_extensions = ';'.join(bpy.path.extensions_image) + ';' + ';'.join(bpy.path.extensions_movie) + + @classmethod + def poll_drop(cls, context): + if not context.space_data or context.space_data.type != 'VIEW_3D': + return False + rv3d = context.space_data.region_3d + return rv3d.view_perspective == 'PERSP' or rv3d.view_perspective == 'ORTHO' + + +class VIEW3D_FH_camera_background_image(FileHandler): + bl_idname = "VIEW3D_FH_camera_background_image" + bl_label = "Add camera background image" + bl_import_operator = "VIEW3D_OT_camera_background_image_add" + bl_file_extensions = ';'.join(bpy.path.extensions_image) + ';' + ';'.join(bpy.path.extensions_movie) + + @classmethod + def poll_drop(cls, context): + if not context.space_data or context.space_data.type != 'VIEW_3D': + return False + rv3d = context.space_data.region_3d + return rv3d.view_perspective == 'CAMERA' + + classes = ( VIEW3D_OT_edit_mesh_extrude_individual_move, VIEW3D_OT_edit_mesh_extrude_move, VIEW3D_OT_edit_mesh_extrude_shrink_fatten, VIEW3D_OT_edit_mesh_extrude_manifold_normal, VIEW3D_OT_transform_gizmo_set, + VIEW3D_FH_camera_background_image, + VIEW3D_FH_empty_image, ) diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index d426cccc32f..388081bf40e 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -620,11 +620,6 @@ static bool view3d_ima_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event if (ED_region_overlap_isect_any_xy(CTX_wm_area(C), event->xy)) { return false; } - if (drag->type == WM_DRAG_PATH) { - const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag)); - return ELEM(file_type, FILE_TYPE_IMAGE, FILE_TYPE_MOVIE); - } - return WM_drag_is_ID_type(drag, ID_IM); } @@ -887,11 +882,6 @@ static void view3d_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop) RNA_struct_property_unset(drop->ptr, "filepath"); return; } - const char *path = WM_drag_get_single_path(drag); - if (path) { - RNA_string_set(drop->ptr, "filepath", path); - RNA_struct_property_unset(drop->ptr, "image"); - } } static void view3d_lightcache_update(bContext *C)