From 604d029ddf164e87eb453d83c59e65c2f16f8879 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 12 Jan 2011 18:00:23 +0000 Subject: Bugfix #25570 The tool-redo depends on a working undo system, so it can rewind a step and then redo operator with new settings. When a user disables undo, this won't work. Now the properties for redo operator (toolbar, F6) will grey out when a redo isn't possible. --- source/blender/editors/util/editmode_undo.c | 14 +++++++++ source/blender/editors/util/undo.c | 46 +++++++++++++++++++++++++++++ source/blender/editors/util/util_intern.h | 1 + 3 files changed, 61 insertions(+) (limited to 'source/blender/editors/util') diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index cff30f12369..85f343e3311 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -314,6 +314,20 @@ void undo_editmode_name(bContext *C, const char *undoname) } } +/* undoname optionally, if NULL it just checks for existing undo steps */ +int undo_editmode_valid(const char *undoname) +{ + if(undoname) { + UndoElem *uel; + + for(uel= undobase.last; uel; uel= uel->prev) { + if(strcmp(undoname, uel->name)==0) + break; + } + return uel != NULL; + } + return undobase.last != undobase.first; +} /* ************** for interaction with menu/pullown */ diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 60f526b940a..0158719b2fb 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -199,6 +199,52 @@ void ED_undo_pop_op(bContext *C, wmOperator *op) ed_undo_step(C, 0, op->type->name); } +/* name optionally, function used to check for operator redo panel */ +int ED_undo_valid(const bContext *C, const char *undoname) +{ + Object *obedit= CTX_data_edit_object(C); + Object *obact= CTX_data_active_object(C); + ScrArea *sa= CTX_wm_area(C); + + if(sa && sa->spacetype==SPACE_IMAGE) { + SpaceImage *sima= (SpaceImage *)sa->spacedata.first; + + if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { + return 1; + } + } + + if(sa && sa->spacetype==SPACE_TEXT) { + return 1; + } + else if(obedit) { + if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) { + return undo_editmode_valid(undoname); + } + } + else { + + /* if below tests fail, global undo gets executed */ + + if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) { + if( ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) ) + return 1; + } + else if(obact && obact->mode & OB_MODE_SCULPT) { + if( ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) ) + return 1; + } + else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { + return PE_undo_valid(CTX_data_scene(C)); + } + + if(U.uiflag & USER_GLOBALUNDO) { + return BKE_undo_valid(undoname); + } + } + return 0; +} + static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op)) { /* "last operator" should disappear, later we can tie ths with undo stack nicer */ diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index 73675ab4ef9..b5750c55c87 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -34,6 +34,7 @@ /* editmode_undo.c */ void undo_editmode_clear(void); void undo_editmode_name(bContext *C, const char *undoname); +int undo_editmode_valid(const char *undoname); #endif /* ED_UTIL_INTERN_H */ -- cgit v1.2.3