diff options
author | Julian Eisel <julian@blender.org> | 2022-07-14 20:21:56 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-07-14 20:21:56 +0300 |
commit | bdd0ac5bcebd6deb3d590ada9a3f25c6ddd58ea4 (patch) | |
tree | b60a608dc46c970e71eba27b8f753c60e9a030fd /source/blender/windowmanager/WM_api.h | |
parent | 1ef686bd26cc3c89849f41770ce76d7b94f169db (diff) |
Fix `on_drag_start` handler not getting ID when dragging from Outliner
We would first invoke the dragging, and then set the drag data (like the
ID or the dragged modifier), so the `wmDropBox.on_drag_start()` handler
wouldn't be able to access this. This broke dragging some IDs from the
Outliner, noticed in D15333.
It's now possible to first create/request drag data, extend it, and then
invoke the actual dragging. The normal function to start dragging
returns `void` now instead of `wmDrag *`, so the drag data can't easily
be modified after starting anymore.
Diffstat (limited to 'source/blender/windowmanager/WM_api.h')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index f337dd9d89a..44c5b86857d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -1214,10 +1214,24 @@ int WM_operator_flag_only_pass_through_on_press(int retval, const struct wmEvent /* Drag and drop. */ /** - * Note that the pointer should be valid allocated and not on stack. + * Start dragging immediately with the given data. + * Note that \a poin should be valid allocated and not on stack. */ -struct wmDrag *WM_event_start_drag( +void WM_event_start_drag( struct bContext *C, int icon, int 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 + * returned pointer will leak memory. + * + * 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); +/** + * 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); |