diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-03-19 16:17:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-03-31 21:40:37 +0300 |
commit | 651b8fb14eb6ee5cbfa98bffe80a966a0753b14e (patch) | |
tree | 2281978509d82a25fb5fbf586f34335e3606442d /source/blender/editors/sculpt_paint/paint_curve.c | |
parent | 91d0825b5556150c017dad767f7971bb6a731aec (diff) |
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
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_curve.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_curve.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 8d9812f41d9..120514762f4 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -40,6 +40,7 @@ #include "BKE_paint.h" #include "ED_view3d.h" +#include "ED_paint.h" #include "WM_api.h" #include "WM_types.h" @@ -203,7 +204,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) br->paint_curve = pc = BKE_paint_curve_add(bmain, "PaintCurve"); } - ED_paintcurve_undo_push(C, op, pc); + ED_paintcurve_undo_push_begin(op->type->name); pcp = MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint), "PaintCurvePoint"); add_index = pc->add_index; @@ -241,6 +242,8 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) pcp[add_index].bez.h1 = HD_ALIGN; } + ED_paintcurve_undo_push_end(); + WM_paint_cursor_tag_redraw(window, ar); } @@ -302,7 +305,7 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ED_paintcurve_undo_push(C, op, pc); + ED_paintcurve_undo_push_begin(op->type->name); #define DELETE_TAG 2 @@ -342,6 +345,8 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op) #undef DELETE_TAG + ED_paintcurve_undo_push_end(); + WM_paint_cursor_tag_redraw(window, ar); return OPERATOR_FINISHED; @@ -379,7 +384,7 @@ static bool paintcurve_point_select(bContext *C, wmOperator *op, const int loc[2 if (!pc) return false; - ED_paintcurve_undo_push(C, op, pc); + ED_paintcurve_undo_push_begin(op->type->name); if (toggle) { PaintCurvePoint *pcp; @@ -444,10 +449,14 @@ static bool paintcurve_point_select(bContext *C, wmOperator *op, const int loc[2 } } - if (!pcp) + if (!pcp) { + ED_paintcurve_undo_push_end(); return false; + } } + ED_paintcurve_undo_push_end(); + WM_paint_cursor_tag_redraw(window, ar); return true; @@ -562,9 +571,6 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e psd->align = align; op->customdata = psd; - if (do_select) - ED_paintcurve_undo_push(C, op, pc); - /* first, clear all selection from points */ for (i = 0; i < pc->tot_points; i++) pc->points[i].bez.f1 = pc->points[i].bez.f3 = pc->points[i].bez.f2 = 0; @@ -587,6 +593,8 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev if (event->type == psd->event && event->val == KM_RELEASE) { MEM_freeN(psd); + ED_paintcurve_undo_push_begin(op->type->name); + ED_paintcurve_undo_push_end(); return OPERATOR_FINISHED; } |