Changeset View
Standalone View
source/blender/editors/space_view3d/space_view3d.c
| Show First 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | static bool view3d_drop_id_in_main_region_poll(bContext *C, | ||||
| return WM_drag_is_ID_type(drag, id_type); | return WM_drag_is_ID_type(drag, id_type); | ||||
| } | } | ||||
| static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool view3d_ob_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| return view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB); | return view3d_drop_id_in_main_region_poll(C, drag, event, ID_OB); | ||||
| } | } | ||||
| static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool view3d_collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
| return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR); | return view3d_drop_id_in_main_region_poll(C, drag, event, ID_GR); | ||||
| } | } | ||||
| static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | static bool view3d_mat_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) | ||||
| { | { | ||||
Severin: The distinction here isn't if something is an asset or not, but if something is an external… | |||||
Done Inline ActionsWould suggest view3d_ob_drop_poll_local_id(), since not every ID is an asset. This will also be the version executed when dragging from the Outliner, which of course isn't asset specific at all. Just note in a comment that this local ID may also be an asset. Severin: Would suggest `view3d_ob_drop_poll_local_id()`, since not every ID is an asset. This will also… | |||||
Done Inline ActionsRenamed to local_id to avoid too many iterations on this patch, I'm concerned this would be confused with local-id / linked-id terminology which is used throughout the code-base. While non_external_asset reads awkwardly, at least it's clear whats happening. campbellbarton: Renamed to `local_id` to avoid too many iterations on this patch, I'm concerned this would be… | |||||
Not Done Inline Actions
I'd argue against that. non_external_asset to me means an asset that isn't external, so local. However this is also used for IDs that are not marked as assets. Severin: > While `non_external_asset` reads awkwardly, at least it's clear whats happening.
I'd argue… | |||||
| return view3d_drop_id_in_main_region_poll(C, drag, event, ID_MA); | return view3d_drop_id_in_main_region_poll(C, drag, event, ID_MA); | ||||
| } | } | ||||
Done Inline ActionsTogether with the suggested naming change, I'd change this to check drag->type != WM_DRAG_ID. Severin: Together with the suggested naming change, I'd change this to check `drag->type != WM_DRAG_ID`. | |||||
| static char *view3d_mat_drop_tooltip(bContext *C, | static char *view3d_mat_drop_tooltip(bContext *C, | ||||
| wmDrag *drag, | wmDrag *drag, | ||||
| const wmEvent *event, | const wmEvent *event, | ||||
| struct wmDropBox *drop) | struct wmDropBox *drop) | ||||
| { | { | ||||
| const char *name = WM_drag_get_item_name(drag); | const char *name = WM_drag_get_item_name(drag); | ||||
| RNA_string_set(drop->ptr, "name", name); | RNA_string_set(drop->ptr, "name", name); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| static bool view3d_volume_drop_poll(bContext *UNUSED(C), | static bool view3d_volume_drop_poll(bContext *UNUSED(C), | ||||
| wmDrag *drag, | wmDrag *drag, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| return (drag->type == WM_DRAG_PATH) && (drag->icon == ICON_FILE_VOLUME); | return (drag->type == WM_DRAG_PATH) && (drag->icon == ICON_FILE_VOLUME); | ||||
| } | } | ||||
| static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) | static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
Not Done Inline Actionsview3d_ob_drop_copy_local_id()? Severin: `view3d_ob_drop_copy_local_id()`? | |||||
| { | { | ||||
| ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_OB); | ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, ID_OB); | ||||
| /* Simple drag and drop for a single object. */ | |||||
| if (drag->type == WM_DRAG_ASSET) { | |||||
| RNA_boolean_set(drop->ptr, "only_place", true); | |||||
| return; | |||||
| } | |||||
| RNA_string_set(drop->ptr, "name", id->name + 2); | RNA_string_set(drop->ptr, "name", id->name + 2); | ||||
| /* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */ | /* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */ | ||||
| const bool is_imported_id = drag->type == WM_DRAG_ASSET; | const bool is_imported_id = drag->type == WM_DRAG_ASSET; | ||||
| RNA_boolean_set(drop->ptr, "duplicate", !is_imported_id); | RNA_boolean_set(drop->ptr, "duplicate", !is_imported_id); | ||||
| } | } | ||||
| static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop) | static void view3d_collection_drop_copy(wmDrag *drag, wmDropBox *drop) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,167 Lines • Show Last 20 Lines | |||||
The distinction here isn't if something is an asset or not, but if something is an external asset that has to be imported first, or a local ID, which may well be marked as asset too.
In hindsight, I find WM_DRAG_ASSET to be named badly, and reusing WM_DRAG_ID for local ID asset makes things even more confusing. Instead there should be WM_DRAG_ASSET_EXTERNAL and WM_DRAG_ASSET_LOCAL_ID or similar, but that's a separate cleanup.