Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_collections.c
| Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | static int collection_unlink_poll(bContext *C) | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| return BLI_findindex(&view_layer->layer_collections, lc) != -1 ? 1 : 0; | return BLI_findindex(&view_layer->layer_collections, lc) != -1 ? 1 : 0; | ||||
| } | } | ||||
| static int collection_unlink_exec(bContext *C, wmOperator *op) | static int collection_unlink_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| LayerCollection *lc = outliner_collection_active(C); | LayerCollection *lc = outliner_collection_active(C); | ||||
| SpaceOops *soops = CTX_wm_space_outliner(C); | SpaceOops *soops = CTX_wm_space_outliner(C); | ||||
| Main *bmain = CTX_data_main(C); | |||||
| if (lc == NULL) { | if (lc == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Active element is not a collection"); | BKE_report(op->reports, RPT_ERROR, "Active element is not a collection"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| BKE_collection_unlink(view_layer, lc); | BKE_collection_unlink(view_layer, lc, bmain); | ||||
| if (soops) { | if (soops) { | ||||
| outliner_cleanup_tree(soops); | outliner_cleanup_tree(soops); | ||||
| } | } | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(bmain); | ||||
| /* TODO(sergey): Use proper flag for tagging here. */ | /* TODO(sergey): Use proper flag for tagging here. */ | ||||
| DEG_id_tag_update(&CTX_data_scene(C)->id, 0); | DEG_id_tag_update(&CTX_data_scene(C)->id, 0); | ||||
| WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| /* Now, delete all tree elements representing a collection that will be deleted. We'll look for a | /* Now, delete all tree elements representing a collection that will be deleted. We'll look for a | ||||
| * new element to select in a few lines, so we can't wait until the tree is recreated on redraw. */ | * new element to select in a few lines, so we can't wait until the tree is recreated on redraw. */ | ||||
| outliner_tree_traverse(soops, &soops->tree, 0, 0, collection_delete_elements_from_collection, &data); | outliner_tree_traverse(soops, &soops->tree, 0, 0, collection_delete_elements_from_collection, &data); | ||||
| /* Effectively delete the collections. */ | /* Effectively delete the collections. */ | ||||
| GSetIterator collections_to_delete_iter; | GSetIterator collections_to_delete_iter; | ||||
| GSET_ITER(collections_to_delete_iter, data.collections_to_delete) { | GSET_ITER(collections_to_delete_iter, data.collections_to_delete) { | ||||
| SceneCollection *sc = BLI_gsetIterator_getKey(&collections_to_delete_iter); | SceneCollection *sc = BLI_gsetIterator_getKey(&collections_to_delete_iter); | ||||
| BKE_collection_remove(&data.scene->id, sc); | BKE_collection_remove(&data.scene->id, sc, CTX_data_main(C)); | ||||
| } | } | ||||
| BLI_gset_free(data.collections_to_delete, NULL); | BLI_gset_free(data.collections_to_delete, NULL); | ||||
| TreeElement *select_te = outliner_tree_element_from_layer_collection_index(soops, CTX_data_view_layer(C), 0); | TreeElement *select_te = outliner_tree_element_from_layer_collection_index(soops, CTX_data_view_layer(C), 0); | ||||
| if (select_te) { | if (select_te) { | ||||
| outliner_item_select(soops, select_te, false, false); | outliner_item_select(soops, select_te, false, false); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines | |||||