diff --git a/source/blender/editors/include/UI_abstract_view.hh b/source/blender/editors/include/UI_abstract_view.hh index ca76eb94c3c..2b5035e92f4 100644 --- a/source/blender/editors/include/UI_abstract_view.hh +++ b/source/blender/editors/include/UI_abstract_view.hh @@ -29,6 +29,8 @@ #include "UI_interface.hh" +#include "WM_types.h" + struct bContext; struct uiBlock; struct uiLayout; @@ -244,7 +246,7 @@ class AbstractViewItemDragController { AbstractViewItemDragController(AbstractView &view); virtual ~AbstractViewItemDragController() = default; - virtual int get_drag_type() const = 0; + virtual eWM_DragDataType get_drag_type() const = 0; virtual void *create_drag_data() const = 0; virtual void on_drag_start(); diff --git a/source/blender/editors/interface/interface_intern.hh b/source/blender/editors/interface/interface_intern.hh index bb644249374..b82403ead73 100644 --- a/source/blender/editors/interface/interface_intern.hh +++ b/source/blender/editors/interface/interface_intern.hh @@ -249,8 +249,7 @@ struct uiBut { ListBase extra_op_icons = {nullptr, nullptr}; /** #uiButExtraOpIcon */ - /* Drag-able data, type is WM_DRAG_... */ - char dragtype = WM_DRAG_ID; + eWM_DragDataType dragtype = WM_DRAG_ID; short dragflag = 0; void *dragpoin = nullptr; ImBuf *imb = nullptr; diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index a698e1159cf..5998af1f1da 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -103,7 +103,7 @@ class AssetCatalogDragController : public ui::AbstractViewItemDragController { explicit AssetCatalogDragController(AssetCatalogTreeView &tree_view, AssetCatalogTreeItem &catalog_item); - int get_drag_type() const override; + eWM_DragDataType get_drag_type() const override; void *create_drag_data() const override; void on_drag_start() override; }; @@ -545,7 +545,7 @@ AssetCatalogDragController::AssetCatalogDragController(AssetCatalogTreeView &tre { } -int AssetCatalogDragController::get_drag_type() const +eWM_DragDataType AssetCatalogDragController::get_drag_type() const { return WM_DRAG_ASSET_CATALOG; } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 06cab393097..ba528397f09 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -1461,7 +1461,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator * /*op*/, cons TSE_GPENCIL_EFFECT, TSE_GPENCIL_EFFECT_BASE); - const int wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID; + const eWM_DragDataType wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID; wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, 0.0, WM_DRAG_NOP); if (use_datastack_drag) { diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 211f17b1aca..0027dcf477d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -1360,8 +1360,12 @@ int WM_operator_flag_only_pass_through_on_press(int retval, const struct wmEvent * Start dragging immediately with the given data. * Note that \a poin should be valid allocated and not on stack. */ -void WM_event_start_drag( - struct bContext *C, int icon, int type, void *poin, double value, unsigned int flags); +void WM_event_start_drag(struct bContext *C, + int icon, + eWM_DragDataType type, + void *poin, + double value, + unsigned int flags); /** * Create and fill the dragging data, but don't start dragging just yet (unlike * #WM_event_start_drag()). Must be followed up by #WM_event_start_prepared_drag(), otherwise the @@ -1369,15 +1373,19 @@ void WM_event_start_drag( * * Note that \a poin should be valid allocated and not on stack. */ -wmDrag *WM_drag_data_create( - struct bContext *C, int icon, int type, void *poin, double value, unsigned int flags); +wmDrag *WM_drag_data_create(struct bContext *C, + int icon, + eWM_DragDataType type, + void *poin, + double value, + unsigned int flags); /** * Invoke dragging using the given \a drag data. */ void WM_event_start_prepared_drag(struct bContext *C, wmDrag *drag); void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale); void WM_drag_free(struct wmDrag *drag); -void WM_drag_data_free(int dragtype, void *poin); +void WM_drag_data_free(eWM_DragDataType dragtype, void *poin); void WM_drag_free_list(struct ListBase *lb); struct wmDropBox *WM_dropbox_add( ListBase *lb, diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index e87e510e12a..89aac71e66a 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -1062,19 +1062,21 @@ typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata /* *************** Drag and drop *************** */ -#define WM_DRAG_ID 0 -#define WM_DRAG_ASSET 1 -/** The user is dragging multiple assets. This is only supported in few specific cases, proper - * multi-item support for dragging isn't supported well yet. Therefore this is kept separate from - * #WM_DRAG_ASSET. */ -#define WM_DRAG_ASSET_LIST 2 -#define WM_DRAG_RNA 3 -#define WM_DRAG_PATH 4 -#define WM_DRAG_NAME 5 -#define WM_DRAG_VALUE 6 -#define WM_DRAG_COLOR 7 -#define WM_DRAG_DATASTACK 8 -#define WM_DRAG_ASSET_CATALOG 9 +typedef enum eWM_DragDataType { + WM_DRAG_ID, + WM_DRAG_ASSET, + /** The user is dragging multiple assets. This is only supported in few specific cases, proper + * multi-item support for dragging isn't supported well yet. Therefore this is kept separate from + * #WM_DRAG_ASSET. */ + WM_DRAG_ASSET_LIST, + WM_DRAG_RNA, + WM_DRAG_PATH, + WM_DRAG_NAME, + WM_DRAG_VALUE, + WM_DRAG_COLOR, + WM_DRAG_DATASTACK, + WM_DRAG_ASSET_CATALOG, +} eWM_DragDataType; typedef enum eWM_DragFlags { WM_DRAG_NOP = 0, @@ -1174,8 +1176,7 @@ typedef struct wmDrag { struct wmDrag *next, *prev; int icon; - /** See 'WM_DRAG_' defines above. */ - int type; + eWM_DragDataType type; void *poin; double value; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 68d3e1d414c..8b8e2993fe3 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -177,7 +177,8 @@ static void wm_dropbox_invoke(bContext *C, wmDrag *drag) } } -wmDrag *WM_drag_data_create(bContext *C, int icon, int type, void *poin, double value, uint flags) +wmDrag *WM_drag_data_create( + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, uint flags) { wmDrag *drag = MEM_cnew(__func__); @@ -232,7 +233,8 @@ void WM_event_start_prepared_drag(bContext *C, wmDrag *drag) wm_dropbox_invoke(C, drag); } -void WM_event_start_drag(bContext *C, int icon, int type, void *poin, double value, uint flags) +void WM_event_start_drag( + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, uint flags) { wmDrag *drag = WM_drag_data_create(C, icon, type, poin, value, flags); WM_event_start_prepared_drag(C, drag); @@ -288,7 +290,7 @@ void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale) drag->imbuf_scale = scale; } -void WM_drag_data_free(int dragtype, void *poin) +void WM_drag_data_free(eWM_DragDataType dragtype, void *poin) { /* Don't require all the callers to have a nullptr-check, just allow passing nullptr. */ if (!poin) { @@ -849,6 +851,8 @@ const char *WM_drag_get_item_name(wmDrag *drag) } case WM_DRAG_NAME: return static_cast(drag->poin); + default: + break; } return ""; }