diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-25 11:55:36 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-03-25 12:09:03 +0300 |
commit | c1f8b9753acd6e61317dd7076eac5408fc48d7e6 (patch) | |
tree | c7b8b4885db9ab2fd3334f4b6bb2863ad13cf1d8 /source/blender/blenkernel/intern/blender_copybuffer.c | |
parent | 6d8a945f06e3dfd720de4839d9df67989ce32388 (diff) |
Copy/Paste: refactor to be able to paste any kind of IDs, by type.
This commit does not add anything new from user perspective, but make it
possible to paste any kind of IDs, not only objects/collections.
Will be used by new copy/paste in the outliner in next commit.
Diffstat (limited to 'source/blender/blenkernel/intern/blender_copybuffer.c')
-rw-r--r-- | source/blender/blenkernel/intern/blender_copybuffer.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c index bc935f0b760..2ac013df620 100644 --- a/source/blender/blenkernel/intern/blender_copybuffer.c +++ b/source/blender/blenkernel/intern/blender_copybuffer.c @@ -82,7 +82,7 @@ bool BKE_copybuffer_save(Main *bmain_src, const char *filename, ReportList *repo return retval; } -bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports) +bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports, const unsigned int id_types_mask) { BlendHandle *bh = BLO_blendhandle_from_file(libname, reports); if (bh == NULL) { @@ -91,7 +91,7 @@ bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *repor } /* Here appending/linking starts. */ Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname); - BLO_library_link_copypaste(mainl, bh); + BLO_library_link_copypaste(mainl, bh, id_types_mask); BLO_library_link_end(mainl, &bh, 0, NULL, NULL, NULL, NULL); /* Mark all library linked objects to be updated. */ BKE_main_lib_objects_recalc_all(bmain_dst); @@ -108,9 +108,10 @@ bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *repor } /** - * \return Success. + * \return Number of IDs directly pasted from the buffer (does not includes indirectly pulled out ones). */ -bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, ReportList *reports) +int BKE_copybuffer_paste( + bContext *C, const char *libname, const short flag, ReportList *reports, const unsigned int id_types_mask) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -124,7 +125,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re if (bh == NULL) { /* error reports will have been made by BLO_blendhandle_from_file() */ - return false; + return 0; } BKE_view_layer_base_deselect_all(view_layer); @@ -138,7 +139,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re /* here appending/linking starts */ mainl = BLO_library_link_begin(bmain, &bh, libname); - BLO_library_link_copypaste(mainl, bh); + const int num_pasted = BLO_library_link_copypaste(mainl, bh, id_types_mask); BLO_library_link_end(mainl, &bh, flag, bmain, scene, view_layer, v3d); @@ -164,7 +165,7 @@ bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, Re BLO_blendhandle_close(bh); /* remove library... */ - return true; + return num_pasted; } /** \} */ |