Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2019-02-26 22:15:30 +0300
committerDalai Felinto <dfelinto@gmail.com>2019-03-01 17:44:19 +0300
commite7ea99af1b0d933b9323be39d8b1c6f683bfba52 (patch)
tree461d23594737af40f62f533dbe357d2264134d1d /source/blender/editors/space_outliner
parent619c65a4b3372b45a8d6d7317672c48d248104ca (diff)
Outliner: Collection - Duplicate Hierarchy, and Duplicate Linked Hierarchy
As per the suggestion on T57064, this introduces two new options to duplicate collections. We then have: * Duplicate > Collection (New collection with linked content). * Duplicate > Hierachy (Duplicate entire hierarchy and make all contents single user). * Duplicate > Linked Hierarchy (Duplicate entire hierarchy keeping content linked with original). Development TODO: `single_object_users` can/should use the new functions. Reviewers: brecht, mont29 Subscribers: pablovazquez, billreynish, JulienKaspar Differential Revision: https://developer.blender.org/D4394
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c36
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h2
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c2
3 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 67126a3e155..61c02d18f8f 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -448,6 +448,8 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceOutliner *soops = CTX_wm_space_outliner(C);
TreeElement *te = outliner_active_collection(C);
+ bool hierarchy = strstr(op->idname, "hierarchy") != NULL;
+ bool linked = strstr(op->idname, "linked") != NULL;
/* Can happen when calling from a key binding. */
if (te == NULL) {
@@ -467,7 +469,7 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
case SO_SCENES:
case SO_VIEW_LAYER:
case SO_LIBRARIES:
- BKE_collection_copy(bmain, parent, collection);
+ BKE_collection_duplicate(bmain, parent, collection, hierarchy, !linked);
break;
}
@@ -482,7 +484,37 @@ void OUTLINER_OT_collection_duplicate(wmOperatorType *ot)
/* identifiers */
ot->name = "Duplicate Collection";
ot->idname = "OUTLINER_OT_collection_duplicate";
- ot->description = "Duplicate selected collections";
+ ot->description = "Make a new collection with linked content (collection and objects)";
+
+ /* api callbacks */
+ ot->exec = collection_duplicate_exec;
+ ot->poll = ED_outliner_collections_editor_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+void OUTLINER_OT_collection_duplicate_hierarchy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Duplicate Collection Hierarchy";
+ ot->idname = "OUTLINER_OT_collection_duplicate_hierarchy";
+ ot->description = "Duplicate entire hierarchy and make all content single user";
+
+ /* api callbacks */
+ ot->exec = collection_duplicate_exec;
+ ot->poll = ED_outliner_collections_editor_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+void OUTLINER_OT_collection_duplicate_linked_hierarchy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Duplicate Linked Collection Hierarchy";
+ ot->idname = "OUTLINER_OT_collection_duplicate_linked_hierarchy";
+ ot->description = "Duplicate entire hierarchy with linked object data";
/* api callbacks */
ot->exec = collection_duplicate_exec;
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 81b06cab3a1..a1751e90660 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -316,6 +316,8 @@ struct Collection *outliner_collection_from_tree_element(const TreeElement *te);
void OUTLINER_OT_collection_new(struct wmOperatorType *ot);
void OUTLINER_OT_collection_duplicate(struct wmOperatorType *ot);
+void OUTLINER_OT_collection_duplicate_hierarchy(struct wmOperatorType *ot);
+void OUTLINER_OT_collection_duplicate_linked_hierarchy(struct wmOperatorType *ot);
void OUTLINER_OT_collection_delete(struct wmOperatorType *ot);
void OUTLINER_OT_collection_objects_select(struct wmOperatorType *ot);
void OUTLINER_OT_collection_objects_deselect(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 81001c0160f..404ad17ba4e 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -94,6 +94,8 @@ void outliner_operatortypes(void)
/* collections */
WM_operatortype_append(OUTLINER_OT_collection_new);
WM_operatortype_append(OUTLINER_OT_collection_duplicate);
+ WM_operatortype_append(OUTLINER_OT_collection_duplicate_hierarchy);
+ WM_operatortype_append(OUTLINER_OT_collection_duplicate_linked_hierarchy);
WM_operatortype_append(OUTLINER_OT_collection_delete);
WM_operatortype_append(OUTLINER_OT_collection_objects_select);
WM_operatortype_append(OUTLINER_OT_collection_objects_deselect);