diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-14 00:35:26 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-03-14 00:36:16 +0400 |
commit | 93684d5b5e3dcc6b9f0d4130ff5bdab86d2f7981 (patch) | |
tree | d103245caabd1f00a28e100277a30fd42ac8d3e4 /source/blender/editors/util/undo.c | |
parent | a8039d99f8a38ec9acb8bc048d38259bab574c53 (diff) |
Fix T39156 part 2: Add support for image paint operations in undo
history operator (Ctrl + Alt + Z).
This will only show paint operations now while in an image paint mode.
The caveat is that user can delete previous paint operations too (even
on images not on the canvas currently) so it needs some care. This is
consistent with regular undo behaviour though.
Sculpting also suffers from lack of Undo history support, this will be
added in a separate commit.
Diffstat (limited to 'source/blender/editors/util/undo.c')
-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); |