From e8027ec2a0cac4b0e92d51a64ccc40fd3f190a20 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 25 Oct 2021 10:07:00 -0300 Subject: UI Drag Drop: allow customizable drawing No functional changes. This commit adds 3 callbacks for `wmDropBox` which allow custom drawing without affecting the internal dropbox API. Differential Revision: https://developer.blender.org/D12948 --- source/blender/windowmanager/WM_types.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source/blender/windowmanager/WM_types.h') diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index f4595869baf..bbfc9d53e44 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -1020,7 +1020,7 @@ typedef struct wmDragAssetListItem { typedef char *(*WMDropboxTooltipFunc)(struct bContext *, struct wmDrag *, - const struct wmEvent *event, + const int xy[2], struct wmDropBox *drop); typedef struct wmDrag { @@ -1038,8 +1038,11 @@ typedef struct wmDrag { float scale; int sx, sy; - /** If filled, draws operator tooltip/operator name. */ - char tooltip[200]; + /** Informs which dropbox is activated with the drag item. + * When this value changes, the #draw_activate and #draw_deactivate dropbox callbacks are + * triggered. + */ + struct wmDropBox *active_dropbox; unsigned int flags; /** List of wmDragIDs, all are guaranteed to have the same ID type. */ @@ -1067,6 +1070,18 @@ typedef struct wmDropBox { */ void (*cancel)(struct Main *, struct wmDrag *, struct wmDropBox *); + /** Override the default drawing function. */ + void (*draw)(struct bContext *, struct wmWindow *, struct wmDrag *, const int *); + + /** Called when pool returns true the first time. */ + void (*draw_activate)(struct wmDropBox *, struct wmDrag *drag); + + /** Called when pool returns false the first time or when the drag event ends. */ + void (*draw_deactivate)(struct wmDropBox *, struct wmDrag *drag); + + /** Custom data for drawing. */ + void *draw_data; + /** Custom tooltip shown during dragging. */ WMDropboxTooltipFunc tooltip; -- cgit v1.2.3