Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_dragdrop.c
| Show All 36 Lines | |||||
| #include "BLI_math_color.h" | #include "BLI_math_color.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_idtype.h" | #include "BKE_idtype.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | |||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "GPU_viewport.h" | #include "GPU_viewport.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| ▲ Show 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode) | ||||
| return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : NULL; | return (ELEM(idcode, 0, asset_drag->id_type)) ? asset_drag : NULL; | ||||
| } | } | ||||
| static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag) | static ID *wm_drag_asset_id_import(wmDragAsset *asset_drag) | ||||
| { | { | ||||
| const char *name = asset_drag->name; | const char *name = asset_drag->name; | ||||
| ID_Type idtype = asset_drag->id_type; | ID_Type idtype = asset_drag->id_type; | ||||
| /* FIXME: Link/Append should happens in the operator called at the end of drop process, not from | |||||
| * here. */ | |||||
| Main *bmain = CTX_data_main(asset_drag->evil_C); | |||||
| Scene *scene = CTX_data_scene(asset_drag->evil_C); | |||||
| ViewLayer *view_layer = CTX_data_view_layer(asset_drag->evil_C); | |||||
| View3D *view3d = CTX_wm_view3d(asset_drag->evil_C); | |||||
| switch ((eFileAssetImportType)asset_drag->import_type) { | switch ((eFileAssetImportType)asset_drag->import_type) { | ||||
| case FILE_ASSET_IMPORT_LINK: | case FILE_ASSET_IMPORT_LINK: | ||||
| return WM_file_link_datablock(G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name, 0); | return WM_file_link_datablock(bmain, | ||||
| scene, | |||||
| view_layer, | |||||
| view3d, | |||||
| asset_drag->path, | |||||
| idtype, | |||||
| name, | |||||
| FILE_ACTIVE_COLLECTION); | |||||
| case FILE_ASSET_IMPORT_APPEND: | case FILE_ASSET_IMPORT_APPEND: | ||||
| return WM_file_append_datablock( | return WM_file_append_datablock(bmain, | ||||
| G_MAIN, NULL, NULL, NULL, asset_drag->path, idtype, name, BLO_LIBLINK_APPEND_RECURSIVE); | scene, | ||||
| view_layer, | |||||
| view3d, | |||||
| asset_drag->path, | |||||
| idtype, | |||||
| name, | |||||
| BLO_LIBLINK_APPEND_RECURSIVE | FILE_ACTIVE_COLLECTION); | |||||
| } | } | ||||
| BLI_assert_unreachable(); | BLI_assert_unreachable(); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /** | /** | ||||
| * When dragging a local ID, return that. Otherwise, if dragging an asset-handle, link or append | * When dragging a local ID, return that. Otherwise, if dragging an asset-handle, link or append | ||||
| ▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines | |||||