Outliner: Open empty collection when something is dragged into it
Reviewers: brecht Differential Revision: https://developer.blender.org/D3814
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user