diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-12-22 16:11:04 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-12-22 16:41:09 +0300 |
commit | c08dac000ff3ca3597c82740c724f63f024ab542 (patch) | |
tree | 0314c66c0832484538f28fa0c315c8012906f05c /source/blender/blenkernel/intern/collection.c | |
parent | fec3be6b5455c8847df0910f1086be4bdcab8dc1 (diff) |
Collection: Name collection based on parent's name
So they are:
House
-> House 1
-> House 2
-> ...
The exception is when the parent collection is the master collection. In this case we get:
Master Collection
-> Collection 1
-> Collection 2
-> ...
This is part of "T53495: View layer and collection editing - Design Task"
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 8d69563f5ff..f8934184928 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -69,24 +69,35 @@ static SceneCollection *collection_master_from_id(const ID *owner_id) * Add a collection to a collection ListBase and syncronize all render layers * The ListBase is NULL when the collection is to be added to the master collection */ -SceneCollection *BKE_collection_add(ID *owner_id, SceneCollection *sc_parent, const int type, const char *name) +SceneCollection *BKE_collection_add(ID *owner_id, SceneCollection *sc_parent, const int type, const char *name_custom) { SceneCollection *sc_master = collection_master_from_id(owner_id); SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); sc->type = type; - - if (!name) { - name = DATA_("New Collection"); - } + const char *name = name_custom; if (!sc_parent) { sc_parent = sc_master; } + if (!name) { + if (sc_parent == sc_master) { + name = BLI_sprintfN("Collection %d", BLI_listbase_count(&sc_master->scene_collections) + 1); + } + else { + name = BLI_sprintfN("%s %d", sc_parent->name, BLI_listbase_count(&sc_parent->scene_collections) + 1); + } + } + BKE_collection_rename((Scene *)owner_id, sc, name); BLI_addtail(&sc_parent->scene_collections, sc); BKE_layer_sync_new_scene_collection(owner_id, sc_parent, sc); + + if (name != name_custom) { + MEM_freeN((char *)name); + } + return sc; } |