diff options
author | Julian Eisel <julian@blender.org> | 2021-06-11 17:35:39 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-06-11 17:46:20 +0300 |
commit | f6c5af3d47539d710f8a0542fcd8340a6e67f65a (patch) | |
tree | 77aefbc2057bbcc7c498f640471cec90c838a082 /source/blender/editors | |
parent | c8fcea0c33ef3d371d3aba0c16889cc319811ec6 (diff) |
Add option to link assets on drag & drop
Note: Linking in this case as in link vs. append. Easily confused with linking
a data-block to multiple usages (e.g. single material used by multiple
objects).
Adds a drop-down to the Asset Browser header to choose between Link and Append.
This is probably gonna be a temporary place, T54642 shows where this could be
placed eventually.
Linking support is crucial for usage of the asset browser in production
environments. It just wasn't enabled yet because a) the asset project currently
focuses on single user, not production assets, and b) because there were many
unkowns still for the workflow that have big impact on production use as well.
With the recently held asset workshop I'm more confident with enabling linking,
as design ideas relevant to production use were confirmed.
Differential Revision: https://developer.blender.org/D11536
Reviewed by: Bastien Montagne
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 1 |
4 files changed, 28 insertions, 6 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 338b12f7985..1d335c500ca 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -723,6 +723,7 @@ void UI_but_drag_set_asset(uiBut *but, const char *name, const char *path, int id_type, + int import_type, /* eFileAssetImportType */ int icon, struct ImBuf *imb, float scale); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f6b2a6a1bc6..26ea5f8e24a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6144,6 +6144,7 @@ void UI_but_drag_set_asset(uiBut *but, const char *name, const char *path, int id_type, + int import_type, int icon, struct ImBuf *imb, float scale) @@ -6153,6 +6154,7 @@ void UI_but_drag_set_asset(uiBut *but, BLI_strncpy(asset_drag->name, name, sizeof(asset_drag->name)); asset_drag->path = path; asset_drag->id_type = id_type; + asset_drag->import_type = import_type; but->dragtype = WM_DRAG_ASSET; ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */ diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 189b9b4c874..17d029f7541 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -142,7 +142,8 @@ static void draw_tile(int sx, int sy, int width, int height, int colorid, int sh color); } -static void file_draw_icon(uiBlock *block, +static void file_draw_icon(const SpaceFile *sfile, + uiBlock *block, const FileDirEntry *file, const char *path, int sx, @@ -177,10 +178,14 @@ static void file_draw_icon(uiBlock *block, ImBuf *preview_image = filelist_file_getimage(file); char blend_path[FILE_MAX_LIBEXTRA]; if (BLO_library_path_explode(path, blend_path, NULL, NULL)) { + const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile); + BLI_assert(asset_params != NULL); + UI_but_drag_set_asset(but, file->name, BLI_strdup(blend_path), file->blentype, + asset_params->import_type, icon, preview_image, UI_DPI_FAC); @@ -299,7 +304,8 @@ void file_calc_previews(const bContext *C, ARegion *region) UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } -static void file_draw_preview(uiBlock *block, +static void file_draw_preview(const SpaceFile *sfile, + uiBlock *block, const FileDirEntry *file, const char *path, int sx, @@ -484,9 +490,19 @@ static void file_draw_preview(uiBlock *block, /* path is no more static, cannot give it directly to but... */ else if (file->typeflag & FILE_TYPE_ASSET) { char blend_path[FILE_MAX_LIBEXTRA]; + if (BLO_library_path_explode(path, blend_path, NULL, NULL)) { - UI_but_drag_set_asset( - but, file->name, BLI_strdup(blend_path), file->blentype, icon, imb, scale); + const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(sfile); + BLI_assert(asset_params != NULL); + + UI_but_drag_set_asset(but, + file->name, + BLI_strdup(blend_path), + file->blentype, + asset_params->import_type, + icon, + imb, + scale); } } else { @@ -925,7 +941,8 @@ void file_draw_list(const bContext *C, ARegion *region) is_icon = 1; } - file_draw_preview(block, + file_draw_preview(sfile, + block, file, path, sx, @@ -940,7 +957,8 @@ void file_draw_list(const bContext *C, ARegion *region) is_link); } else { - file_draw_icon(block, + file_draw_icon(sfile, + block, file, path, sx, diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 038b9c11bca..8e3fc36aa71 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -120,6 +120,7 @@ static void fileselect_ensure_updated_asset_params(SpaceFile *sfile) asset_params->base_params.details_flags = U_default.file_space_data.details_flags; asset_params->asset_library.type = FILE_ASSET_LIBRARY_LOCAL; asset_params->asset_library.custom_library_index = -1; + asset_params->import_type = FILE_ASSET_IMPORT_APPEND; } FileSelectParams *base_params = &asset_params->base_params; |