Undo: unified undo system w/ linear history

- Use a single undo history for all operations.
- UndoType's are registered and poll the context to check if they
  should be used when performing an undo push.
- Mode switching is used to ensure the state is correct before
  undo data is restored.
- Some undo types accumulate changes (image & text editing)
  others store the state multiple times (with de-duplication).
  This is supported by checking UndoStack.mode `ACCUMULATE` / `STORE`.
- Each undo step stores ID datablocks they use with utilities to help
  manage restoring correct ID's.
  Needed since global undo is now mixed with other modes undo.
- Currently performs each undo step when going up/down history
  Previously this wasn't done, making history fail in some cases.
  This can be optimized to skip some combinations of undo steps.

grease-pencil is an exception which has not been updated
since it integrates undo into the draw-session.

See D3113
This commit is contained in:
2018-03-19 14:17:59 +01:00
parent 91d0825b55
commit 651b8fb14e
66 changed files with 3066 additions and 1942 deletions

View File

@@ -30,12 +30,13 @@
#ifndef __ED_TEXT_H__
#define __ED_TEXT_H__
struct bContext;
struct SpaceText;
struct ARegion;
struct UndoType;
void ED_text_undo_step(struct bContext *C, int step);
bool ED_text_region_location_from_cursor(struct SpaceText *st, struct ARegion *ar, const int cursor_co[2], int r_pixel_co[2]);
#endif /* __ED_TEXT_H__ */
/* text_undo.c */
void ED_text_undosys_type(struct UndoType *ut);
#endif /* __ED_TEXT_H__ */