Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-03-14 00:35:26 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-03-14 00:36:16 +0400
commit93684d5b5e3dcc6b9f0d4130ff5bdab86d2f7981 (patch)
treed103245caabd1f00a28e100277a30fd42ac8d3e4 /source/blender/editors/sculpt_paint/paint_undo.c
parenta8039d99f8a38ec9acb8bc048d38259bab574c53 (diff)
Fix T39156 part 2: Add support for image paint operations in undo
history operator (Ctrl + Alt + Z). This will only show paint operations now while in an image paint mode. The caveat is that user can delete previous paint operations too (even on images not on the canvas currently) so it needs some care. This is consistent with regular undo behaviour though. Sculpting also suffers from lack of Undo history support, this will be added in a separate commit.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_undo.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index fd8cc4df41e..2b5c6d9421c 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -271,6 +271,77 @@ int ED_undo_paint_step(bContext *C, int type, int step, const char *name)
return 0;
}
+static void undo_step_num(bContext *C, UndoStack *stack, int step)
+{
+ UndoElem *uel;
+ int a = 0;
+ int curnum = BLI_findindex(&stack->elems, stack->current);
+
+ for (uel = stack->elems.first; uel; uel = uel->next, a++) {
+ if (a == step) break;
+ }
+
+ if (curnum > a) {
+ while (a++ != curnum)
+ undo_stack_step(C, stack, 1, NULL);
+ }
+ else if (curnum < a){
+ while (a-- != curnum)
+ undo_stack_step(C, stack, -1, NULL);
+ }
+}
+
+void ED_undo_paint_step_num(bContext *C, int type, int step)
+{
+ if (type == UNDO_PAINT_IMAGE)
+ return undo_step_num(C, &ImageUndoStack, step);
+ else if (type == UNDO_PAINT_MESH)
+ return undo_step_num(C, &MeshUndoStack, step);
+}
+
+static char *undo_stack_get_name(UndoStack *stack, int nr, int *active)
+{
+ UndoElem *uel;
+
+ if (active) *active = 0;
+
+ uel = BLI_findlink(&stack->elems, nr);
+ if (uel) {
+ if (active && uel == stack->current)
+ *active = 1;
+ return uel->name;
+ }
+
+ return NULL;
+}
+
+const char *ED_undo_paint_get_name(int type, int nr, int *active)
+{
+ if (type == UNDO_PAINT_IMAGE)
+ return undo_stack_get_name(&ImageUndoStack, nr, active);
+ else if (type == UNDO_PAINT_MESH)
+ return undo_stack_get_name(&MeshUndoStack, nr, active);
+ return NULL;
+}
+
+bool ED_undo_paint_empty(int type)
+{
+ UndoStack *stack;
+
+ if (type == UNDO_PAINT_IMAGE)
+ stack = &ImageUndoStack;
+ else if (type == UNDO_PAINT_MESH)
+ stack = &MeshUndoStack;
+ else
+ return true;
+
+ if (stack->current == NULL) {
+ return true;
+ }
+
+ return false;
+}
+
int ED_undo_paint_valid(int type, const char *name)
{
UndoStack *stack;