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:
Diffstat (limited to 'source/blender/editors/util/undo.c')
-rw-r--r--source/blender/editors/util/undo.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index e224dc6484c..3a2d67c8703 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -45,9 +45,12 @@
#include "BKE_blender_undo.h"
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_library_override.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "DEG_depsgraph.h"
+
#include "ED_armature.h"
#include "ED_particle.h"
#include "ED_curve.h"
@@ -76,12 +79,16 @@
void ED_undo_push(bContext *C, const char *str)
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
if (G.debug & G_DEBUG)
printf("%s: %s\n", __func__, str);
+ /* Always do it for now, this might need to be refined... */
+ BKE_main_override_static_operations_create(CTX_data_main(C));
+
if (obedit) {
if (U.undosteps == 0) return;
@@ -98,12 +105,12 @@ void ED_undo_push(bContext *C, const char *str)
else if (obedit->type == OB_ARMATURE)
undo_push_armature(C, str);
}
- else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
+ else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) {
if (U.undosteps == 0) return;
- PE_undo_push(CTX_data_scene(C), str);
+ PE_undo_push(CTX_data_scene(C), CTX_data_view_layer(C), str);
}
- else if (obact && obact->mode & OB_MODE_SCULPT) {
+ else if (obact && workspace->object_mode & OB_MODE_SCULPT) {
/* do nothing for now */
}
else {
@@ -116,10 +123,12 @@ void ED_undo_push(bContext *C, const char *str)
/* note: also check undo_history_exec() in bottom if you change notifiers */
static int ed_undo_step(bContext *C, int step, const char *undoname)
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
@@ -138,7 +147,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
if (sa && (sa->spacetype == SPACE_IMAGE)) {
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
- if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
+ if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) {
if (U.uiflag & USER_GLOBALUNDO) {
ED_viewport_render_kill_jobs(wm, bmain, true);
@@ -172,17 +181,17 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
* That was inconsistent with editmode, and also makes for
* unecessarily tricky interaction with the other undo
* systems. */
- if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
+ if (obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname);
}
- else if (obact && obact->mode & OB_MODE_SCULPT) {
+ else if (obact && workspace->object_mode & OB_MODE_SCULPT) {
ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname);
}
- else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
+ else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) {
if (step == 1)
- PE_undo(scene);
+ PE_undo(scene, view_layer);
else
- PE_redo(scene);
+ PE_redo(scene, view_layer);
}
else if (U.uiflag & USER_GLOBALUNDO) {
// note python defines not valid here anymore.
@@ -264,6 +273,7 @@ void ED_undo_pop_op(bContext *C, wmOperator *op)
/* name optionally, function used to check for operator redo panel */
bool ED_undo_is_valid(const bContext *C, const char *undoname)
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
ScrArea *sa = CTX_wm_area(C);
@@ -271,7 +281,7 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname)
if (sa && sa->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
- if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
+ if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
return 1;
}
}
@@ -288,16 +298,16 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname)
/* if below tests fail, global undo gets executed */
- if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) {
+ if (obact && workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
if (ED_undo_paint_is_valid(UNDO_PAINT_IMAGE, undoname))
return 1;
}
- else if (obact && obact->mode & OB_MODE_SCULPT) {
+ else if (obact && workspace->object_mode & OB_MODE_SCULPT) {
if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname))
return 1;
}
- else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
- return PE_undo_is_valid(CTX_data_scene(C));
+ else if (obact && workspace->object_mode & OB_MODE_PARTICLE_EDIT) {
+ return PE_undo_is_valid(CTX_data_scene(C), CTX_data_view_layer(C));
}
if (U.uiflag & USER_GLOBALUNDO) {
@@ -492,6 +502,7 @@ enum {
static int get_undo_system(bContext *C)
{
+ const WorkSpace *workspace = CTX_wm_workspace(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
ScrArea *sa = CTX_wm_area(C);
@@ -500,7 +511,7 @@ static int get_undo_system(bContext *C)
if (sa && (sa->spacetype == SPACE_IMAGE)) {
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
- if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
+ if ((obact && (workspace->object_mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE))
return UNDOSYSTEM_IMAPAINT;
}
@@ -513,13 +524,13 @@ static int get_undo_system(bContext *C)
}
else {
if (obact) {
- if (obact->mode & OB_MODE_PARTICLE_EDIT)
+ if (workspace->object_mode & OB_MODE_PARTICLE_EDIT)
return UNDOSYSTEM_PARTICLE;
- else if (obact->mode & OB_MODE_TEXTURE_PAINT) {
+ else if (workspace->object_mode & OB_MODE_TEXTURE_PAINT) {
if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE))
return UNDOSYSTEM_IMAPAINT;
}
- else if (obact->mode & OB_MODE_SCULPT) {
+ else if (workspace->object_mode & OB_MODE_SCULPT) {
if (!ED_undo_paint_empty(UNDO_PAINT_MESH))
return UNDOSYSTEM_SCULPT;
}
@@ -542,7 +553,7 @@ static const EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *tot
const char *name = NULL;
if (undosys == UNDOSYSTEM_PARTICLE) {
- name = PE_undo_get_name(CTX_data_scene(C), i, &active);
+ name = PE_undo_get_name(CTX_data_scene(C), CTX_data_view_layer(C), i, &active);
}
else if (undosys == UNDOSYSTEM_EDITMODE) {
name = undo_editmode_get_name(C, i, &active);
@@ -625,7 +636,7 @@ static int undo_history_exec(bContext *C, wmOperator *op)
int item = RNA_int_get(op->ptr, "item");
if (undosys == UNDOSYSTEM_PARTICLE) {
- PE_undo_number(CTX_data_scene(C), item);
+ PE_undo_number(CTX_data_scene(C), CTX_data_view_layer(C), item);
}
else if (undosys == UNDOSYSTEM_EDITMODE) {
undo_editmode_number(C, item + 1);