Outliner: Make deleting collections from "All Collections" mode work
This commit is contained in:
parent
fcbae6c3b3
commit
512fb74980
|
@ -294,12 +294,20 @@ static TreeTraversalReturn collection_delete_cb(TreeElement *te, void *customdat
|
|||
{
|
||||
struct CollectionDeleteData *data = customdata;
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
LayerCollection *lc = te->directdata;
|
||||
SceneCollection *scene_collection;
|
||||
|
||||
if (tselem->type != TSE_LAYER_COLLECTION) {
|
||||
/* skip */
|
||||
if (tselem->type == TSE_LAYER_COLLECTION) {
|
||||
LayerCollection *lc = te->directdata;
|
||||
scene_collection = lc->scene_collection;
|
||||
}
|
||||
else if (lc->scene_collection == BKE_collection_master(data->scene)) {
|
||||
else if (tselem->type == TSE_SCENE_COLLECTION) {
|
||||
scene_collection = te->directdata;
|
||||
}
|
||||
else {
|
||||
return TRAVERSE_SKIP_CHILDS;
|
||||
}
|
||||
|
||||
if (scene_collection == BKE_collection_master(data->scene)) {
|
||||
/* skip - showing warning/error message might be missleading
|
||||
* when deleting multiple collections, so just do nothing */
|
||||
}
|
||||
|
@ -311,7 +319,7 @@ static TreeTraversalReturn collection_delete_cb(TreeElement *te, void *customdat
|
|||
* This works as workaround, but having a proper way to find the TreeStoreElem for a recreated
|
||||
* TreeElement would be better. It could use an idname or the directdata pointer for that. */
|
||||
outliner_remove_treestore_element(data->soops, tselem);
|
||||
BKE_collection_remove(data->scene, lc->scene_collection);
|
||||
BKE_collection_remove(data->scene, scene_collection);
|
||||
}
|
||||
|
||||
return TRAVERSE_CONTINUE;
|
||||
|
@ -323,7 +331,7 @@ static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
SpaceOops *soops = CTX_wm_space_outliner(C);
|
||||
struct CollectionDeleteData data = {.scene = scene, .soops = soops};
|
||||
|
||||
TODO_LAYER_OVERRIDE; /* handle operators */
|
||||
TODO_LAYER_OVERRIDE; /* handle overrides */
|
||||
outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, collection_delete_cb, &data);
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
|
||||
|
|
|
@ -1330,10 +1330,12 @@ static void outliner_add_scene_collection_init(TreeElement *te, SceneCollection
|
|||
}
|
||||
|
||||
static void outliner_add_scene_collections_recursive(SpaceOops *soops, ListBase *tree, Scene *scene,
|
||||
ListBase *scene_collections, TreeElement *parent_ten)
|
||||
ListBase *scene_collections, TreeElement *parent_ten,
|
||||
int *io_collection_counter)
|
||||
{
|
||||
for (SceneCollection *collection = scene_collections->first; collection; collection = collection->next) {
|
||||
TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_SCENE_COLLECTION, 0);
|
||||
TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_SCENE_COLLECTION,
|
||||
(*io_collection_counter)++);
|
||||
|
||||
outliner_add_scene_collection_init(ten, collection);
|
||||
for (LinkData *link = collection->objects.first; link; link = link->next) {
|
||||
|
@ -1341,16 +1343,20 @@ static void outliner_add_scene_collections_recursive(SpaceOops *soops, ListBase
|
|||
}
|
||||
outliner_make_hierarchy(&ten->subtree);
|
||||
|
||||
outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &collection->scene_collections, ten);
|
||||
outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &collection->scene_collections, ten,
|
||||
io_collection_counter);
|
||||
}
|
||||
}
|
||||
static void outliner_add_collections_master(SpaceOops *soops, Scene *scene)
|
||||
{
|
||||
SceneCollection *master = BKE_collection_master(scene);
|
||||
TreeElement *ten = outliner_add_element(soops, &soops->tree, scene, NULL, TSE_SCENE_COLLECTION, 0);
|
||||
int collection_counter = 0;
|
||||
TreeElement *ten = outliner_add_element(soops, &soops->tree, scene, NULL, TSE_SCENE_COLLECTION,
|
||||
collection_counter++);
|
||||
|
||||
outliner_add_scene_collection_init(ten, master);
|
||||
outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &master->scene_collections, ten);
|
||||
outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &master->scene_collections, ten,
|
||||
&collection_counter);
|
||||
}
|
||||
|
||||
/* ======================================================= */
|
||||
|
|
Loading…
Reference in New Issue