diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-07 11:38:20 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-08-10 18:53:00 +0300 |
commit | 74016d73dbebd8c8a0e1aed70295d1a09037d7eb (patch) | |
tree | f21c0f5f22452072b2c97a0a11aa70cb18d0bd6f /source/blender/windowmanager | |
parent | 9e83283f7312c565e32c68bb544177bbfec7ceb2 (diff) |
WM: drag and drop poll functions can now specify a custom tooltip.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 3 |
4 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 67ca5f8a08a..3521c4d1bd5 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -485,7 +485,8 @@ void WM_drag_free(struct wmDrag *drag); void WM_drag_free_list(struct ListBase *lb); struct wmDropBox *WM_dropbox_add( - ListBase *lb, const char *idname, bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event), + ListBase *lb, const char *idname, + bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event, const char **), void (*copy)(struct wmDrag *, struct wmDropBox *)); ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 6b1bb8f4806..809588b1a36 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -682,7 +682,7 @@ typedef struct wmDropBox { struct wmDropBox *next, *prev; /* test if the dropbox is active, then can print optype name */ - bool (*poll)(struct bContext *, struct wmDrag *, const wmEvent *); + bool (*poll)(struct bContext *, struct wmDrag *, const wmEvent *, const char **); /* before exec, this copies drag info to wmDrop properties */ void (*copy)(struct wmDrag *, struct wmDropBox *); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index eca3a838c0f..0ae51cc922b 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -98,7 +98,8 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) wmDropBox *WM_dropbox_add( - ListBase *lb, const char *idname, bool (*poll)(bContext *, wmDrag *, const wmEvent *), + ListBase *lb, const char *idname, + bool (*poll)(bContext *, wmDrag *, const wmEvent *, const char **), void (*copy)(wmDrag *, wmDropBox *)) { wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox"); @@ -195,10 +196,12 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, if (handler->dropboxes) { wmDropBox *drop = handler->dropboxes->first; for (; drop; drop = drop->next) { - if (drop->poll(C, drag, event)) + const char *tooltip = NULL; + if (drop->poll(C, drag, event, &tooltip)) { /* XXX Doing translation here might not be ideal, but later we have no more * access to ot (and hence op context)... */ - return RNA_struct_ui_name(drop->ot->srna); + return (tooltip) ? tooltip : RNA_struct_ui_name(drop->ot->srna); + } } } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8b1cce27502..5d343c5e0fe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2368,7 +2368,8 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers wmDrag *drag; for (drag = lb->first; drag; drag = drag->next) { - if (drop->poll(C, drag, event)) { + const char *tooltip = NULL; + if (drop->poll(C, drag, event, &tooltip)) { drop->copy(drag, drop); /* free the drags before calling operator */ |