diff options
author | Julian Eisel <julian@blender.org> | 2021-10-27 15:50:48 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-10-27 15:56:57 +0300 |
commit | aae5f15238f73fcac762a1690e052b86fad23be1 (patch) | |
tree | 5549df5789c1b586404a2bae575f0043c56d51db /source/blender/windowmanager | |
parent | 1832e11f39a36681533c148de9300b290a8c309c (diff) |
Asset Browser: Support dragging catalogs to move them in the hierarchy
Uses the additions to the UI tree-view API from the previous commit to
enable drag & drop of asset catalogs. The catalogs will be moved in the
tree including children.
A remaining issue is that a catalog with children will always be
collapsed when dropping. I need to find a way to fix that in the
tree-view API.
There are a few improvements I can think of for the tree-item drag &
drop support, but time for these is too short. These can be done as
normal cleanups at some point.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 10 |
3 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 26db02be289..b5acecc4762 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -770,6 +770,8 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, struct wmDrag *drag, struct wmDropBox *drop); +struct wmDragAssetCatalog *WM_drag_get_asset_catalog_data(const struct wmDrag *drag); + void WM_drag_add_asset_list_item(wmDrag *drag, const struct bContext *C, const struct AssetLibraryReference *asset_library_ref, diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 1f1b1a70685..9f427a90353 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -119,6 +119,7 @@ struct wmWindowManager; #include "BLI_compiler_attrs.h" #include "DNA_listBase.h" +#include "DNA_uuid_types.h" #include "DNA_vec_types.h" #include "DNA_xr_types.h" #include "RNA_types.h" @@ -967,6 +968,7 @@ typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata #define WM_DRAG_VALUE 6 #define WM_DRAG_COLOR 7 #define WM_DRAG_DATASTACK 8 +#define WM_DRAG_ASSET_CATALOG 9 typedef enum wmDragFlags { WM_DRAG_NOP = 0, @@ -1000,6 +1002,10 @@ typedef struct wmDragAsset { struct bContext *evil_C; } wmDragAsset; +typedef struct wmDragAssetCatalog { + bUUID drag_catalog_id; +} wmDragAssetCatalog; + /** * For some specific cases we support dragging multiple assets (#WM_DRAG_ASSET_LIST). There is no * proper support for dragging multiple items in the `wmDrag`/`wmDrop` API yet, so this is really diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 50ac046ed54..df6d3d5e9e7 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -181,6 +181,7 @@ wmDrag *WM_event_start_drag( } break; case WM_DRAG_ASSET: + case WM_DRAG_ASSET_CATALOG: /* Move ownership of poin to wmDrag. */ drag->poin = poin; drag->flags |= WM_DRAG_FREE_DATA; @@ -649,6 +650,15 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox * } } +wmDragAssetCatalog *WM_drag_get_asset_catalog_data(const wmDrag *drag) +{ + if (drag->type != WM_DRAG_ASSET_CATALOG) { + return NULL; + } + + return drag->poin; +} + /** * \note: Does not store \a asset in any way, so it's fine to pass a temporary. */ |