From 8d2576fd295fc67e2b70c282117928173ec1af8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Oct 2020 20:24:13 +1100 Subject: Undo System: support for grouping steps with begin/end calls This adds support for treating multiple undo steps as a single step from the user perspective. This is needed for outliner mode switching and `object.switch_object` operator which change active object and mode in a single action. --- source/blender/blenkernel/BKE_undo_system.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/BKE_undo_system.h') diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 4f933ca7a87..58872d6be58 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -70,6 +70,12 @@ typedef struct UndoStack { * That is done once end is called. */ struct UndoStep *step_init; + + /** + * Keep track of nested group begin/end calls, + * within which all but the last undo-step is marked for skipping. + */ + int group_level; } UndoStack; typedef struct UndoStep { @@ -156,6 +162,9 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size #define BKE_undosys_stack_limit_steps_and_memory_defaults(ustack) \ BKE_undosys_stack_limit_steps_and_memory(ustack, U.undosteps, (size_t)U.undomemory * 1024 * 1024) +void BKE_undosys_stack_group_begin(UndoStack *ustack); +void BKE_undosys_stack_group_end(UndoStack *ustack); + /* Only some UndoType's require init. */ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack, struct bContext *C, -- cgit v1.2.3