Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_tools.c
| Show First 20 Lines • Show All 360 Lines • ▼ Show 20 Lines | void OUTLINER_OT_scene_operation(wmOperatorType *ot) | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", prop_scene_op_types, 0, "Scene Operation", ""); | ot->prop = RNA_def_enum(ot->srna, "type", prop_scene_op_types, 0, "Scene Operation", ""); | ||||
| } | } | ||||
| /* ******************************************** */ | /* ******************************************** */ | ||||
| static void object_select_cb( | static void object_select_cb( | ||||
| bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), | bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), | ||||
| TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | ||||
| { | { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| Base *base = BKE_scene_layer_base_find(sl, ob); | Base *base = BKE_view_layer_base_find(sl, ob); | ||||
| if (base && ((base->flag & BASE_VISIBLED) != 0)) { | if (base && ((base->flag & BASE_VISIBLED) != 0)) { | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| } | } | ||||
| static void object_select_hierarchy_cb( | static void object_select_hierarchy_cb( | ||||
| bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *te, | bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *te, | ||||
| TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | ||||
| { | { | ||||
| /* Don't extend because this toggles, which is nice for Ctrl-Click but not for a menu item. | /* Don't extend because this toggles, which is nice for Ctrl-Click but not for a menu item. | ||||
| * it's especially confusing when multiple items are selected since some toggle on/off. */ | * it's especially confusing when multiple items are selected since some toggle on/off. */ | ||||
| outliner_item_do_activate_from_tree_element(C, te, tselem, false, true); | outliner_item_do_activate_from_tree_element(C, te, tselem, false, true); | ||||
| } | } | ||||
| static void object_deselect_cb( | static void object_deselect_cb( | ||||
| bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), | bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te), | ||||
| TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | ||||
| { | { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *ob = (Object *)tselem->id; | Object *ob = (Object *)tselem->id; | ||||
| Base *base = BKE_scene_layer_base_find(sl, ob); | Base *base = BKE_view_layer_base_find(sl, ob); | ||||
| if (base) { | if (base) { | ||||
| base->flag &= ~BASE_SELECTED; | base->flag &= ~BASE_SELECTED; | ||||
| } | } | ||||
| } | } | ||||
| static void object_delete_cb( | static void object_delete_cb( | ||||
| bContext *C, ReportList *reports, Scene *scene, TreeElement *te, | bContext *C, ReportList *reports, Scene *scene, TreeElement *te, | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | if (id) { | ||||
| id_single_user(C, id, &ptr, prop); | id_single_user(C, id, &ptr, prop); | ||||
| } | } | ||||
| } | } | ||||
| static void group_linkobs2scene_cb( | static void group_linkobs2scene_cb( | ||||
| bContext *C, ReportList *UNUSED(reports), Scene *scene, TreeElement *UNUSED(te), | bContext *C, ReportList *UNUSED(reports), Scene *scene, TreeElement *UNUSED(te), | ||||
| TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | ||||
| { | { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| SceneCollection *sc = CTX_data_scene_collection(C); | SceneCollection *sc = CTX_data_scene_collection(C); | ||||
| Group *group = (Group *)tselem->id; | Group *group = (Group *)tselem->id; | ||||
| GroupObject *gob; | GroupObject *gob; | ||||
| Base *base; | Base *base; | ||||
| for (gob = group->gobject.first; gob; gob = gob->next) { | for (gob = group->gobject.first; gob; gob = gob->next) { | ||||
| base = BKE_scene_layer_base_find(sl, gob->ob); | base = BKE_view_layer_base_find(sl, gob->ob); | ||||
| if (!base) { | if (!base) { | ||||
| /* link to scene */ | /* link to scene */ | ||||
| BKE_collection_object_add(scene, sc, gob->ob); | BKE_collection_object_add(scene, sc, gob->ob); | ||||
| base = BKE_scene_layer_base_find(sl, gob->ob); | base = BKE_view_layer_base_find(sl, gob->ob); | ||||
| id_us_plus(&gob->ob->id); | id_us_plus(&gob->ob->id); | ||||
| } | } | ||||
| base->flag |= BASE_SELECTED; | base->flag |= BASE_SELECTED; | ||||
| } | } | ||||
| } | } | ||||
| static void group_instance_cb( | static void group_instance_cb( | ||||
| ▲ Show 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | else if (event == OL_COLLECTION_OP_OBJECTS_REMOVE) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | ||||
| te->store_elem->flag &= ~TSE_SELECTED; | te->store_elem->flag &= ~TSE_SELECTED; | ||||
| } | } | ||||
| else if (event == OL_COLLECTION_OP_COLLECTION_NEW) { | else if (event == OL_COLLECTION_OP_COLLECTION_NEW) { | ||||
| BKE_collection_add(scene, sc, NULL); | BKE_collection_add(scene, sc, NULL); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | ||||
| } | } | ||||
| else if (event == OL_COLLECTION_OP_COLLECTION_UNLINK) { | else if (event == OL_COLLECTION_OP_COLLECTION_UNLINK) { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| if (BLI_findindex(&sl->layer_collections, lc) == -1) { | if (BLI_findindex(&view_layer->layer_collections, lc) == -1) { | ||||
| /* we can't unlink if the layer collection wasn't directly linked */ | /* we can't unlink if the layer collection wasn't directly linked */ | ||||
| TODO_LAYER_OPERATORS; /* this shouldn't be in the menu in those cases */ | TODO_LAYER_OPERATORS; /* this shouldn't be in the menu in those cases */ | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_collection_unlink(sl, lc); | BKE_collection_unlink(view_layer, lc); | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | ||||
| } | } | ||||
| } | } | ||||
| else if (event == OL_COLLECTION_OP_COLLECTION_DEL) { | else if (event == OL_COLLECTION_OP_COLLECTION_DEL) { | ||||
| if (BKE_collection_remove(scene, sc)) { | if (BKE_collection_remove(scene, sc)) { | ||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); | ||||
| Show All 24 Lines | for (te = lb->first; te; te = te->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *scene, Base *base) | static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *scene, Base *base) | ||||
| { | { | ||||
| Base *child_base, *base_next; | Base *child_base, *base_next; | ||||
| Object *parent; | Object *parent; | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| if (!base) { | if (!base) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| for (child_base = scene_layer->object_bases.first; child_base; child_base = base_next) { | for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { | ||||
| base_next = child_base->next; | base_next = child_base->next; | ||||
| for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent); | for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent); | ||||
| if (parent) { | if (parent) { | ||||
| base_next = outline_delete_hierarchy(C, reports, scene, child_base); | base_next = outline_delete_hierarchy(C, reports, scene, child_base); | ||||
| } | } | ||||
| } | } | ||||
| base_next = base->next; | base_next = base->next; | ||||
| Show All 14 Lines | static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *scene, Base *base) | ||||
| ED_object_base_free_and_unlink(CTX_data_main(C), scene, base->object); | ED_object_base_free_and_unlink(CTX_data_main(C), scene, base->object); | ||||
| return base_next; | return base_next; | ||||
| } | } | ||||
| static void object_delete_hierarchy_cb( | static void object_delete_hierarchy_cb( | ||||
| bContext *C, ReportList *reports, Scene *scene, | bContext *C, ReportList *reports, Scene *scene, | ||||
| TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) | ||||
| { | { | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Base *base = (Base *)te->directdata; | Base *base = (Base *)te->directdata; | ||||
| Object *obedit = scene->obedit; | Object *obedit = scene->obedit; | ||||
| if (!base) { | if (!base) { | ||||
| base = BKE_scene_layer_base_find(sl, (Object *)tselem->id); | base = BKE_view_layer_base_find(sl, (Object *)tselem->id); | ||||
| } | } | ||||
| if (base) { | if (base) { | ||||
| /* Check also library later. */ | /* Check also library later. */ | ||||
| for (; obedit && (obedit != base->object); obedit = obedit->parent); | for (; obedit && (obedit != base->object); obedit = obedit->parent); | ||||
| if (obedit == base->object) { | if (obedit == base->object) { | ||||
| ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); | ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,123 Lines • Show Last 20 Lines | |||||