From 77794b1a7b99bd689d1d9872c61d7990fbad2ce4 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Thu, 28 Apr 2022 12:50:22 +0200 Subject: VSE: Add precise drag and drop and strip previews This patch adds the drag and drop strip previews in the VSE. It also adds two new functions to the drag and drop API. 1. "draw_in_view" for callbacks that wants to draw elements in local viewport coordinates 2. "on_drag_start" that can be used for prefetching data only once at the start of the drag. Reviewed By: Julian, Campbell Differential Revision: http://developer.blender.org/D14560 --- source/blender/windowmanager/WM_types.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 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 11603b9e5f7..a9b8d91ca03 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -1169,8 +1169,13 @@ typedef struct wmDropBox { /** Test if the dropbox is active. */ bool (*poll)(struct bContext *C, struct wmDrag *drag, const wmEvent *event); + /** Called when the drag action starts. Can be used to prefetch data for previews. + * \note The dropbox that will be called eventually is not known yet when starting the drag. + * So this callback is called on every dropbox that is registered in the current screen. */ + void (*on_drag_start)(struct bContext *C, struct wmDrag *drag); + /** Before exec, this copies drag info to #wmDrop properties. */ - void (*copy)(struct wmDrag *drag, struct wmDropBox *drop); + void (*copy)(struct bContext *C, struct wmDrag *drag, struct wmDropBox *drop); /** * If the operator is canceled (returns `OPERATOR_CANCELLED`), this can be used for cleanup of @@ -1179,15 +1184,29 @@ typedef struct wmDropBox { void (*cancel)(struct Main *bmain, struct wmDrag *drag, struct wmDropBox *drop); /** - * Override the default drawing function. + * Override the default cursor overlay drawing function. + * Can be used to draw text or thumbnails. IE a tooltip for drag and drop. + * \param xy: Cursor location in window coordinates (#wmEvent.xy compatible). + */ + void (*draw_droptip)(struct bContext *C, + struct wmWindow *win, + struct wmDrag *drag, + const int xy[2]); + + /** Called with the draw buffer (#GPUViewport) set up for drawing into the region's view. + * \note Only setups the drawing buffer for drawing in view, not the GPU transform matricies. + * The callback has to do that itself, with for example #UI_view2d_view_ortho. * \param xy: Cursor location in window coordinates (#wmEvent.xy compatible). */ - void (*draw)(struct bContext *C, struct wmWindow *win, struct wmDrag *drag, const int xy[2]); + void (*draw_in_view)(struct bContext *C, + struct wmWindow *win, + struct wmDrag *drag, + const int xy[2]); - /** Called when pool returns true the first time. */ + /** Called when poll returns true the first time. */ void (*draw_activate)(struct wmDropBox *drop, struct wmDrag *drag); - /** Called when pool returns false the first time or when the drag event ends. */ + /** Called when poll returns false the first time or when the drag event ends. */ void (*draw_deactivate)(struct wmDropBox *drop, struct wmDrag *drag); /** Custom data for drawing. */ -- cgit v1.2.3