diff options
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/undo.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index af524fa18bc..60c761cc12d 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -105,13 +105,13 @@ void ED_undo_push(bContext *C, const char *str) } else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; - + PE_undo_push(CTX_data_scene(C), str); } else { BKE_write_undo(C, str); } - + if (wm->file_saved) { wm->file_saved = 0; /* notifier that data changed, for save-over warning or header */ @@ -433,13 +433,27 @@ void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_ev enum { UNDOSYSTEM_GLOBAL = 1, UNDOSYSTEM_EDITMODE = 2, - UNDOSYSTEM_PARTICLE = 3 + UNDOSYSTEM_PARTICLE = 3, + UNDOSYSTEM_IMAPAINT = 4 }; static int get_undo_system(bContext *C) { + Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); - + ScrArea *sa = CTX_wm_area(C); + + /* first check for editor undo */ + if (sa && (sa->spacetype == SPACE_IMAGE)) { + SpaceImage *sima = (SpaceImage *)sa->spacedata.first; + + if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { + if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE)) + return UNDOSYSTEM_IMAPAINT; + else + return UNDOSYSTEM_GLOBAL; + } + } /* find out which undo system */ if (obedit) { if (OB_TYPE_SUPPORT_EDITMODE(obedit->type)) { @@ -449,8 +463,16 @@ static int get_undo_system(bContext *C) else { Object *obact = CTX_data_active_object(C); - if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) - return UNDOSYSTEM_PARTICLE; + if (obact) { + if (obact->mode & OB_MODE_PARTICLE_EDIT) + return UNDOSYSTEM_PARTICLE; + else if (obact->mode & OB_MODE_TEXTURE_PAINT) { + if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE)) + return UNDOSYSTEM_IMAPAINT; + else + return UNDOSYSTEM_GLOBAL; + } + } else if (U.uiflag & USER_GLOBALUNDO) return UNDOSYSTEM_GLOBAL; } @@ -473,6 +495,9 @@ static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) else if (undosys == UNDOSYSTEM_EDITMODE) { name = undo_editmode_get_name(C, i, &active); } + else if (undosys == UNDOSYSTEM_IMAPAINT) { + name = ED_undo_paint_get_name(UNDO_PAINT_IMAGE, i, &active); + } else { name = BKE_undo_get_name(i, &active); } @@ -545,6 +570,9 @@ static int undo_history_exec(bContext *C, wmOperator *op) undo_editmode_number(C, item + 1); WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); } + else if (undosys == UNDOSYSTEM_IMAPAINT) { + ED_undo_paint_step_num(C, UNDO_PAINT_IMAGE, item ); + } else { ED_viewport_render_kill_jobs(C, true); BKE_undo_number(C, item); |