diff options
author | Julian Eisel <julian@blender.org> | 2020-12-14 15:31:55 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-15 19:03:48 +0300 |
commit | b5d778a7d4072bfb091198a2094890157a6d017b (patch) | |
tree | 0a3a1ef47dc6ec1b0407ceec070b9a9bbd84af01 /source/blender/editors/interface/interface_handlers.c | |
parent | 9363132c8601ebca6d89168e09bb10f81d6cb03a (diff) |
Asset System: Support dragging assets and appending on drop
For the Asset Browser, it needs to be possible to drag assets into various
editors, which may not come from the current .blend file. In other words, the
dragging needs to work with just the asset metadata, without direct access to
the data-block itself.
Idea is simple: When dragging an asset, store the source file-path and
data-block name and when dropping, append the data-block. It uses existing drop
operators, but the function to get the dropped data-block is replaced with one
that returns the local data-block, or, in case of an external asset, appends
the data-block first.
The drop operators need to be adjusted to use this new function that respects
assets. With this patch it only works for dragging assets into the 3D view.
Note that I expect this to be a short-lived change. A refactor like D4071 is
needed to make the drag & drop system more future proof for assets and other
use cases.
Part of the first Asset Browser milestone. Check the #asset_browser_milestone_1
project milestone on developer.blender.org.
Differential Revision: https://developer.blender.org/D9721
Reviewed by: Bastien Montagne, Brecht Van Lommel
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index bcb79743b12..f39ad4c4ed5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1987,6 +1987,8 @@ static bool ui_but_drag_init(bContext *C, else { wmDrag *drag = WM_event_start_drag( C, but->icon, but->dragtype, but->dragpoin, ui_but_value_get(but), WM_DRAG_NOP); + /* wmDrag has ownership over dragpoin now, stop messing with it. */ + but->dragpoin = NULL; if (but->imb) { WM_event_drag_image(drag, @@ -2259,10 +2261,11 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */ LISTBASE_FOREACH (wmDrag *, wmd, drags) { + /* TODO asset dropping. */ if (wmd->type == WM_DRAG_ID) { /* align these types with UI_but_active_drop_name */ if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { - ID *id = WM_drag_ID(wmd, 0); + ID *id = WM_drag_get_local_ID(wmd, 0); button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); |