static int outliner_group_operation_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); SpaceOops *soops = CTX_wm_space_outliner(C); int event; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; event = RNA_enum_get(op->ptr, "type"); switch (event) { case OL_GROUPOP_UNLINK: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); break; case OL_GROUPOP_LOCAL: outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); break; case OL_GROUPOP_LINK: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); break; case OL_GROUPOP_INSTANCE: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb); break; case OL_GROUPOP_TOGVIS: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); break; case OL_GROUPOP_TOGSEL: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); break; case OL_GROUPOP_TOGREN: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); break; case OL_GROUPOP_RENAME: outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); break; default: BLI_assert(0); } if (event == 3) { /* instance */ /* works without this except if you try render right after, see: 22027 */ DAG_relations_tag_update(CTX_data_main(C)); } ED_undo_push(C, prop_group_op_types[event - 1].name); WM_event_add_notifier(C, NC_GROUP, NULL); return OPERATOR_FINISHED; }
static int outliner_group_operation_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; const char *str= NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; event= RNA_enum_get(op->ptr, "type"); if (event==1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); str= "Unlink group"; } else if (event==2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); str= "Localized Data"; } else if (event==3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); str= "Link Group Objects to Scene"; } else if (event==4) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); str= "Toggle Visibility"; } else if (event==5) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); str= "Toggle Selectability"; } else if (event==6) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); str= "Toggle Renderability"; } else if (event==7) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); str= "Rename"; } ED_undo_push(C, str); WM_event_add_notifier(C, NC_GROUP, NULL); return OPERATOR_FINISHED; }
static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; for (te=lb->first; te; te= te->next) { tselem= TREESTORE(te); if (tselem->flag & TSE_SELECTED) { if (tselem->type==0) { TreeStoreElem *tsep= TREESTORE(te->parent); operation_cb(C, scene, te, tsep, tselem); } } if (TSELEM_OPEN(tselem,soops)) { outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb); } } }
static int outliner_id_operation_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); event = RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_IDOP_UNLINK: { /* unlink datablock from its parent */ switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb); WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; default: BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } } break; case OUTLINER_IDOP_LOCAL: { /* make local */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); ED_undo_push(C, "Localized Data"); } break; case OUTLINER_IDOP_SINGLE: { /* make single user */ switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb); WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; default: BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } } break; case OUTLINER_IDOP_FAKE_ADD: { /* set fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb); WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); } break; case OUTLINER_IDOP_FAKE_CLEAR: { /* clear fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb); WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); } break; case OUTLINER_IDOP_RENAME: { /* rename */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); } break; case OUTLINER_IDOP_SELECT_LINKED: outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_select_linked_cb); ED_undo_push(C, "Select"); break; default: // invalid - unhandled break; } /* wrong notifier still... */ WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); // XXX: this is just so that outliner is always up to date WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; }