Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-07 11:57:09 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-08-10 18:53:00 +0300
commit86c363a02706b1a5d3cb18d17b4b37bd78461ded (patch)
tree3e10c488d7a10d2e84fa4a647ee7a211ff883427 /source/blender/windowmanager/intern/wm_dragdrop.c
parent74016d73dbebd8c8a0e1aed70295d1a09037d7eb (diff)
WM: pass on wmDrag to drop operators, so they can get the data directly.
Currently drop operators work mostly by specifying the name of the datablock. However there can be datablocks with the same name in different libraries, so this gives wrong results in some cases. Currently only outliner drop operators have been updated to use this mechanism.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_dragdrop.c')
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index 0ae51cc922b..6b9a7fb5430 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -189,6 +189,27 @@ void WM_drag_free_list(struct ListBase *lb)
}
}
+
+ID *WM_drag_ID(const wmDrag *drag, short idcode)
+{
+ if (drag->type != WM_DRAG_ID) {
+ return NULL;
+ }
+
+ ID *id = drag->poin;
+ return (idcode == 0 || GS(id->name) == idcode) ? id : NULL;
+}
+
+ID *WM_drag_ID_from_event(const wmEvent *event, short idcode)
+{
+ if (event->custom != EVT_DATA_DRAGDROP) {
+ return NULL;
+ }
+
+ ListBase *lb = event->customdata;
+ return WM_drag_ID(lb->first, idcode);
+}
+
static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, const wmEvent *event)
{
wmEventHandler *handler = handlers->first;