[Bf-blender-cvs] [c17f2c2eb61] blender2.8: Outliner: Open empty collection when something is dragged into it

Jacques Lucke noreply at git.blender.org
Fri Oct 19 14:31:07 CEST 2018


Commit: c17f2c2eb61f387c278a8dbc8ec559fc1d4bcad6
Author: Jacques Lucke
Date:   Fri Oct 19 14:30:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc17f2c2eb61f387c278a8dbc8ec559fc1d4bcad6

Outliner: Open empty collection when something is dragged into it

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3814

===================================================================

M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/editors/space_outliner/outliner_dragdrop.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 175ee61c690..a9539b3a3c4 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -75,6 +75,7 @@ struct Collection *BKE_collection_master_add(void);
 bool               BKE_collection_has_object(struct Collection *collection, struct Object *ob);
 bool               BKE_collection_has_object_recursive(struct Collection *collection, struct Object *ob);
 struct Collection *BKE_collection_object_find(struct Main *bmain, struct Collection *collection, struct Object *ob);
+bool               BKE_collection_is_empty(struct Collection *collection);
 
 bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob);
 void BKE_collection_object_add_from(struct Main *bmain, struct Scene *scene, struct Object *ob_src, struct Object *ob_dst);
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index ef126da3463..54ce5223756 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -467,6 +467,11 @@ Collection *BKE_collection_object_find(Main *bmain, Collection *collection, Obje
 	return NULL;
 }
 
+bool BKE_collection_is_empty(Collection *collection)
+{
+	return BLI_listbase_is_empty(&collection->gobject) && BLI_listbase_is_empty(&collection->children);
+}
+
 /********************** Collection Objects *********************/
 
 static bool collection_object_add(Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us)
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 293c1d5f29c..4a1e720fe2a 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -794,6 +794,10 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
 		return OPERATOR_CANCELLED;
 	}
 
+	if (BKE_collection_is_empty(data.to)) {
+		TREESTORE(data.te)->flag &= ~TSE_CLOSED;
+	}
+
 	for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
 		/* Ctrl enables linking, so we don't need a from collection then. */
 		Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent);



More information about the Bf-blender-cvs mailing list