[Bf-blender-cvs] [bf7d7bc] master: Add new operator, ED_OT_undo_redo, to allow py tools to trigger that action.
Bastien Montagne
noreply at git.blender.org
Thu Dec 29 12:43:06 CET 2016
Commit: bf7d7bc323d5505b78688af2df1f66e1053f62e1
Author: Bastien Montagne
Date: Thu Dec 29 12:38:20 2016 +0100
Branches: master
https://developer.blender.org/rBbf7d7bc323d5505b78688af2df1f66e1053f62e1
Add new operator, ED_OT_undo_redo, to allow py tools to trigger that action.
Patch D2430 by @raa, thanks.
===================================================================
M source/blender/editors/include/ED_util.h
M source/blender/editors/screen/screen_ops.c
M source/blender/editors/util/undo.c
===================================================================
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index a4afa95..60c4b35 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -60,6 +60,7 @@ void ED_undo_redo(struct bContext *C);
void ED_OT_undo(struct wmOperatorType *ot);
void ED_OT_undo_push(struct wmOperatorType *ot);
void ED_OT_redo(struct wmOperatorType *ot);
+void ED_OT_undo_redo(struct wmOperatorType *ot);
void ED_OT_undo_history(struct wmOperatorType *ot);
int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index c69e014..a7a0a24 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4329,6 +4329,7 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(ED_OT_undo);
WM_operatortype_append(ED_OT_undo_push);
WM_operatortype_append(ED_OT_redo);
+ WM_operatortype_append(ED_OT_undo_redo);
WM_operatortype_append(ED_OT_undo_history);
WM_operatortype_append(ED_OT_flush_edits);
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 4a93114..fab5b7e 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -327,6 +327,13 @@ static int ed_redo_exec(bContext *C, wmOperator *UNUSED(op))
return ed_undo_step(C, -1, NULL);
}
+static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ wmOperator *last_op = WM_operator_last_redo(C);
+ const int ret = ED_undo_operator_repeat(C, last_op);
+ return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
+
/* ********************** */
@@ -369,6 +376,17 @@ void ED_OT_redo(wmOperatorType *ot)
ot->poll = ED_operator_screenactive;
}
+void ED_OT_undo_redo(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Undo and Redo";
+ ot->description = "Undo and redo previous action";
+ ot->idname = "ED_OT_undo_redo";
+
+ /* api callbacks */
+ ot->exec = ed_undo_redo_exec;
+ ot->poll = ED_operator_screenactive;
+}
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
More information about the Bf-blender-cvs
mailing list