Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/util/undo.c
| Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (obedit) { | ||||
| else if (obedit->type == OB_LATTICE) | else if (obedit->type == OB_LATTICE) | ||||
| undo_push_lattice(C, str); | undo_push_lattice(C, str); | ||||
| else if (obedit->type == OB_ARMATURE) | else if (obedit->type == OB_ARMATURE) | ||||
| undo_push_armature(C, str); | undo_push_armature(C, str); | ||||
| } | } | ||||
| else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { | else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { | ||||
| if (U.undosteps == 0) return; | if (U.undosteps == 0) return; | ||||
| PE_undo_push(CTX_data_scene(C), CTX_data_scene_layer(C), str); | PE_undo_push(CTX_data_scene(C), CTX_data_view_layer(C), str); | ||||
| } | } | ||||
| else if (obact && obact->mode & OB_MODE_SCULPT) { | else if (obact && obact->mode & OB_MODE_SCULPT) { | ||||
| /* do nothing for now */ | /* do nothing for now */ | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_undo_write(C, str); | BKE_undo_write(C, str); | ||||
| } | } | ||||
| WM_file_tag_modified(C); | WM_file_tag_modified(C); | ||||
| } | } | ||||
| /* note: also check undo_history_exec() in bottom if you change notifiers */ | /* note: also check undo_history_exec() in bottom if you change notifiers */ | ||||
| static int ed_undo_step(bContext *C, int step, const char *undoname) | static int ed_undo_step(bContext *C, int step, const char *undoname) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| 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 *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| Object *obact = CTX_data_active_object(C); | Object *obact = CTX_data_active_object(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| /* undo during jobs are running can easily lead to freeing data using by jobs, | /* undo during jobs are running can easily lead to freeing data using by jobs, | ||||
| * or they can just lead to freezing job in some other cases */ | * or they can just lead to freezing job in some other cases */ | ||||
| if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| ▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { | ||||
| if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname)) | if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname)) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else if (obact && obact->mode & OB_MODE_SCULPT) { | else if (obact && obact->mode & OB_MODE_SCULPT) { | ||||
| if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname)) | if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname)) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { | else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { | ||||
| return PE_undo_is_valid(CTX_data_scene(C), CTX_data_scene_layer(C)); | return PE_undo_is_valid(CTX_data_scene(C), CTX_data_view_layer(C)); | ||||
| } | } | ||||
| if (U.uiflag & USER_GLOBALUNDO) { | if (U.uiflag & USER_GLOBALUNDO) { | ||||
| return BKE_undo_is_valid(undoname); | return BKE_undo_is_valid(undoname); | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | static const EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) | ||||
| EnumPropertyItem item_tmp = {0}, *item = NULL; | EnumPropertyItem item_tmp = {0}, *item = NULL; | ||||
| int i = 0; | int i = 0; | ||||
| bool active; | bool active; | ||||
| while (true) { | while (true) { | ||||
| const char *name = NULL; | const char *name = NULL; | ||||
| if (undosys == UNDOSYSTEM_PARTICLE) { | if (undosys == UNDOSYSTEM_PARTICLE) { | ||||
| name = PE_undo_get_name(CTX_data_scene(C), CTX_data_scene_layer(C), i, &active); | name = PE_undo_get_name(CTX_data_scene(C), CTX_data_view_layer(C), i, &active); | ||||
| } | } | ||||
| else if (undosys == UNDOSYSTEM_EDITMODE) { | else if (undosys == UNDOSYSTEM_EDITMODE) { | ||||
| name = undo_editmode_get_name(C, i, &active); | name = undo_editmode_get_name(C, i, &active); | ||||
| } | } | ||||
| else if (undosys == UNDOSYSTEM_IMAPAINT) { | else if (undosys == UNDOSYSTEM_IMAPAINT) { | ||||
| name = ED_undo_paint_get_name(C, UNDO_PAINT_IMAGE, i, &active); | name = ED_undo_paint_get_name(C, UNDO_PAINT_IMAGE, i, &active); | ||||
| } | } | ||||
| else if (undosys == UNDOSYSTEM_SCULPT) { | else if (undosys == UNDOSYSTEM_SCULPT) { | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| /* note: also check ed_undo_step() in top if you change notifiers */ | /* note: also check ed_undo_step() in top if you change notifiers */ | ||||
| static int undo_history_exec(bContext *C, wmOperator *op) | static int undo_history_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| if (RNA_struct_property_is_set(op->ptr, "item")) { | if (RNA_struct_property_is_set(op->ptr, "item")) { | ||||
| int undosys = get_undo_system(C); | int undosys = get_undo_system(C); | ||||
| int item = RNA_int_get(op->ptr, "item"); | int item = RNA_int_get(op->ptr, "item"); | ||||
| if (undosys == UNDOSYSTEM_PARTICLE) { | if (undosys == UNDOSYSTEM_PARTICLE) { | ||||
| PE_undo_number(CTX_data_scene(C), CTX_data_scene_layer(C), item); | PE_undo_number(CTX_data_scene(C), CTX_data_view_layer(C), item); | ||||
| } | } | ||||
| else if (undosys == UNDOSYSTEM_EDITMODE) { | else if (undosys == UNDOSYSTEM_EDITMODE) { | ||||
| undo_editmode_number(C, item + 1); | undo_editmode_number(C, item + 1); | ||||
| WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); | WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); | ||||
| } | } | ||||
| else if (undosys == UNDOSYSTEM_IMAPAINT) { | else if (undosys == UNDOSYSTEM_IMAPAINT) { | ||||
| ED_undo_paint_step_num(C, UNDO_PAINT_IMAGE, item); | ED_undo_paint_step_num(C, UNDO_PAINT_IMAGE, item); | ||||
| } | } | ||||
| Show All 32 Lines | |||||