Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_collections.c
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | for (SceneCollection *sc = lb->first; sc; sc = sc->next) { | ||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| static int collection_link_exec(bContext *C, wmOperator *op) | static int collection_link_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| SceneCollection *sc_master = BKE_collection_master(scene); | SceneCollection *sc_master = BKE_collection_master(scene); | ||||
| SceneCollection *sc; | SceneCollection *sc; | ||||
| int scene_collection_index = RNA_enum_get(op->ptr, "scene_collection"); | int scene_collection_index = RNA_enum_get(op->ptr, "scene_collection"); | ||||
| if (scene_collection_index == 0) { | if (scene_collection_index == 0) { | ||||
| sc = sc_master; | sc = sc_master; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | void OUTLINER_OT_collection_link(wmOperatorType *ot) | ||||
| prop = RNA_def_enum(ot->srna, "scene_collection", DummyRNA_NULL_items, 0, "Scene Collection", ""); | prop = RNA_def_enum(ot->srna, "scene_collection", DummyRNA_NULL_items, 0, "Scene Collection", ""); | ||||
| RNA_def_enum_funcs(prop, collection_scene_collection_itemf); | RNA_def_enum_funcs(prop, collection_scene_collection_itemf); | ||||
| RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | ||||
| ot->prop = prop; | ot->prop = prop; | ||||
| } | } | ||||
| /** | /** | ||||
| * Returns true if selected element is a collection directly | * Returns true if selected element is a collection directly | ||||
| * linked to the active SceneLayer (not a nested collection) | * linked to the active ViewLayer (not a nested collection) | ||||
| */ | */ | ||||
| static int collection_unlink_poll(bContext *C) | static int collection_unlink_poll(bContext *C) | ||||
| { | { | ||||
| LayerCollection *lc = outliner_collection_active(C); | LayerCollection *lc = outliner_collection_active(C); | ||||
| if (lc == NULL) { | if (lc == NULL) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| return BLI_findindex(&sl->layer_collections, lc) != -1 ? 1 : 0; | return BLI_findindex(&sl->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); | ||||
| 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; | ||||
| } | } | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| BKE_collection_unlink(sl, lc); | BKE_collection_unlink(sl, lc); | ||||
| if (soops) { | if (soops) { | ||||
| outliner_cleanup_tree(soops); | outliner_cleanup_tree(soops); | ||||
| } | } | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| Show All 17 Lines | void OUTLINER_OT_collection_unlink(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int collection_new_exec(bContext *C, wmOperator *UNUSED(op)) | static int collection_new_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| SceneCollection *sc = BKE_collection_add(scene, NULL, NULL); | SceneCollection *sc = BKE_collection_add(scene, NULL, NULL); | ||||
| BKE_collection_link(sl, sc); | BKE_collection_link(sl, sc); | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| 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 105 Lines • ▼ Show 20 Lines | void OUTLINER_OT_collections_delete(wmOperatorType *ot) | ||||
| ot->exec = collection_delete_exec; | ot->exec = collection_delete_exec; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int collection_select_exec(bContext *C, wmOperator *op) | static int collection_select_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| const int collection_index = RNA_int_get(op->ptr, "collection_index"); | const int collection_index = RNA_int_get(op->ptr, "collection_index"); | ||||
| sl->active_collection = collection_index; | sl->active_collection = collection_index; | ||||
| WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void OUTLINER_OT_collection_select(wmOperatorType *ot) | void OUTLINER_OT_collection_select(wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 15 Lines | |||||
| #define ACTION_DISABLE 0 | #define ACTION_DISABLE 0 | ||||
| #define ACTION_ENABLE 1 | #define ACTION_ENABLE 1 | ||||
| #define ACTION_TOGGLE 2 | #define ACTION_TOGGLE 2 | ||||
| static int collection_toggle_exec(bContext *C, wmOperator *op) | static int collection_toggle_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| int action = RNA_enum_get(op->ptr, "action"); | int action = RNA_enum_get(op->ptr, "action"); | ||||
| LayerCollection *layer_collection = CTX_data_layer_collection(C); | LayerCollection *layer_collection = CTX_data_layer_collection(C); | ||||
| if (layer_collection->flag & COLLECTION_DISABLED) { | if (layer_collection->flag & COLLECTION_DISABLED) { | ||||
| if (ELEM(action, ACTION_TOGGLE, ACTION_ENABLE)) { | if (ELEM(action, ACTION_TOGGLE, ACTION_ENABLE)) { | ||||
| BKE_collection_enable(scene_layer, layer_collection); | BKE_collection_enable(view_layer, layer_collection); | ||||
| } | } | ||||
| else { /* ACTION_DISABLE */ | else { /* ACTION_DISABLE */ | ||||
| BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already disabled", | BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already disabled", | ||||
| layer_collection->scene_collection->name); | layer_collection->scene_collection->name); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (ELEM(action, ACTION_TOGGLE, ACTION_DISABLE)) { | if (ELEM(action, ACTION_TOGGLE, ACTION_DISABLE)) { | ||||
| BKE_collection_disable(scene_layer, layer_collection); | BKE_collection_disable(view_layer, layer_collection); | ||||
| } | } | ||||
| else { /* ACTION_ENABLE */ | else { /* ACTION_ENABLE */ | ||||
| BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already enabled", | BKE_reportf(op->reports, RPT_ERROR, "Layer collection %s already enabled", | ||||
| layer_collection->scene_collection->name); | layer_collection->scene_collection->name); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines | |||||