Cleanup: Add/use helper to check if dragging a certain ID type or asset ID type
This check is a common pattern, avoid duplication by using a helper function.
This commit is contained in:
parent
e747c07156
commit
f04206cbc7
|
@ -664,7 +664,7 @@ static bool node_ima_drop_poll(bContext *UNUSED(C),
|
|||
/* rule might not work? */
|
||||
return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE));
|
||||
}
|
||||
return WM_drag_get_local_ID(drag, ID_IM) || WM_drag_get_asset_data(drag, ID_IM);
|
||||
return WM_drag_is_ID_type(drag, ID_IM);
|
||||
}
|
||||
|
||||
static bool node_mask_drop_poll(bContext *UNUSED(C),
|
||||
|
@ -672,7 +672,7 @@ static bool node_mask_drop_poll(bContext *UNUSED(C),
|
|||
const wmEvent *UNUSED(event),
|
||||
const char **UNUSED(r_tooltip))
|
||||
{
|
||||
return WM_drag_get_local_ID(drag, ID_MSK) || WM_drag_get_asset_data(drag, ID_MSK);
|
||||
return WM_drag_is_ID_type(drag, ID_MSK);
|
||||
}
|
||||
|
||||
static void node_id_drop_copy(wmDrag *drag, wmDropBox *drop)
|
||||
|
|
|
@ -489,7 +489,7 @@ static bool view3d_drop_id_in_main_region_poll(bContext *C,
|
|||
return false;
|
||||
}
|
||||
|
||||
return WM_drag_get_local_ID(drag, id_type) || WM_drag_get_asset_data(drag, id_type);
|
||||
return WM_drag_is_ID_type(drag, id_type);
|
||||
}
|
||||
|
||||
static bool view3d_ob_drop_poll(bContext *C,
|
||||
|
@ -544,7 +544,7 @@ static bool view3d_ima_drop_poll(bContext *C,
|
|||
return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE));
|
||||
}
|
||||
|
||||
return WM_drag_get_local_ID(drag, ID_IM) || WM_drag_get_asset_data(drag, ID_IM);
|
||||
return WM_drag_is_ID_type(drag, ID_IM);
|
||||
}
|
||||
|
||||
static bool view3d_ima_bg_is_camera_view(bContext *C)
|
||||
|
|
|
@ -685,6 +685,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
|
|||
void WM_drag_add_local_ID(struct wmDrag *drag, struct ID *id, struct ID *from_parent);
|
||||
struct ID *WM_drag_get_local_ID(const struct wmDrag *drag, short idcode);
|
||||
struct ID *WM_drag_get_local_ID_from_event(const struct wmEvent *event, short idcode);
|
||||
bool WM_drag_is_ID_type(const struct wmDrag *drag, int idcode);
|
||||
|
||||
struct wmDragAsset *WM_drag_get_asset_data(const struct wmDrag *drag, int idcode);
|
||||
struct ID *WM_drag_get_local_ID_or_import_from_asset(const struct wmDrag *drag, int idcode);
|
||||
|
|
|
@ -353,6 +353,14 @@ ID *WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
|
|||
return WM_drag_get_local_ID(lb->first, idcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the drag data is either a local ID or an external ID asset of type \a idcode.
|
||||
*/
|
||||
bool WM_drag_is_ID_type(const wmDrag *drag, int idcode)
|
||||
{
|
||||
return WM_drag_get_local_ID(drag, idcode) || WM_drag_get_asset_data(drag, idcode);
|
||||
}
|
||||
|
||||
wmDragAsset *WM_drag_get_asset_data(const wmDrag *drag, int idcode)
|
||||
{
|
||||
if (drag->type != WM_DRAG_ASSET) {
|
||||
|
|
Loading…
Reference in New Issue