diff options
author | Bastien Montagne <bastien@blender.org> | 2021-01-27 18:42:50 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-02-03 13:11:12 +0300 |
commit | c9d6737e3e9a00bc297511af4a4d1cf2ed6f8cce (patch) | |
tree | 79bbfe482455f9edf593f444642138673206b7a1 /source/blender/blenkernel/BKE_undo_system.h | |
parent | 4884153823865bbe4bdd365162c71bb45df4081f (diff) |
BKE UndoSys refactor: deduplicate and simplify code, sanitize naming.
Now we only use 'undo' or 'redo' in function names when the direction is
clear (and we assert about it). Otherwise, use 'load' instead.
When passing an undo step to BKE functions, consider calling code has
done its work and is actually passing the target step (i.e. the final
step intended to be loaded), instead of assuming we have to load the
step before/after it.
Also deduplicate and simplify a lot of core undo code in BKE, now
`BKE_undosys_step_load_data_ex` is the only place where all the complex
logic of undo/redo loop (to handle several steps in a row) is placed. We also
only use a single loop there, instead of the two existing ones in
previous code.
Note that here we consider that when we are loading the current active
step, we are undoing. This makes sense in that doing so //may// undo
some changes (ideally it should never do so), but should never, ever
redo anything.
`BKE_undosys_step_load_from_index` also gets heavily simplified, it's
not basically a shallow wrapper around
`BKE_undosys_step_load_from_index`.
And some general update of variable names, commenting, etc.
Part of T83806.
Differential Revision: https://developer.blender.org/D10227
Diffstat (limited to 'source/blender/blenkernel/BKE_undo_system.h')
-rw-r--r-- | source/blender/blenkernel/BKE_undo_system.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 0603ef85cc1..4c3b21482ea 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -203,23 +203,32 @@ UndoStep *BKE_undosys_step_find_by_name_with_type(UndoStack *ustack, UndoStep *BKE_undosys_step_find_by_type(UndoStack *ustack, const UndoType *ut); UndoStep *BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name); +int BKE_undosys_step_calc_direction(const UndoStack *ustack, + const UndoStep *us_target, + const UndoStep *us_reference); + +bool BKE_undosys_step_load_data_ex(UndoStack *ustack, + struct bContext *C, + UndoStep *us_target, + UndoStep *us_reference, + const bool use_skip); +bool BKE_undosys_step_load_data(UndoStack *ustack, struct bContext *C, UndoStep *us_target); +void BKE_undosys_step_load_from_index(UndoStack *ustack, struct bContext *C, const int index); + bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack, struct bContext *C, UndoStep *us, bool use_skip); -bool BKE_undosys_step_undo_with_data(UndoStack *ustack, struct bContext *C, UndoStep *us); +bool BKE_undosys_step_undo_with_data(UndoStack *ustack, struct bContext *C, UndoStep *us_target); bool BKE_undosys_step_undo(UndoStack *ustack, struct bContext *C); bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack, struct bContext *C, UndoStep *us, bool use_skip); -bool BKE_undosys_step_redo_with_data(UndoStack *ustack, struct bContext *C, UndoStep *us); +bool BKE_undosys_step_redo_with_data(UndoStack *ustack, struct bContext *C, UndoStep *us_target); bool BKE_undosys_step_redo(UndoStack *ustack, struct bContext *C); -bool BKE_undosys_step_load_data(UndoStack *ustack, struct bContext *C, UndoStep *us); - -void BKE_undosys_step_undo_from_index(UndoStack *ustack, struct bContext *C, int index); UndoStep *BKE_undosys_step_same_type_next(UndoStep *us); UndoStep *BKE_undosys_step_same_type_prev(UndoStep *us); |