Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/util/undo.c
| Show All 31 Lines | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_gpencil_types.h" | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_blender_undo.h" | #include "BKE_blender_undo.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "BKE_paint.h" | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_particle.h" | #include "ED_particle.h" | ||||
| #include "ED_curve.h" | #include "ED_curve.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_mball.h" | #include "ED_mball.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static int ed_undo_step(bContext *C, int step, const char *undoname) | ||||
| if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* grease pencil can be can be used in plenty of spaces, so check it first */ | /* grease pencil can be can be used in plenty of spaces, so check it first */ | ||||
| if (ED_gpencil_session_active()) { | if (ED_gpencil_session_active()) { | ||||
| return ED_undo_gpencil_step(C, step, undoname); | return ED_undo_gpencil_step(C, step, undoname); | ||||
| } | } | ||||
| if (sa && (sa->spacetype == SPACE_VIEW3D)) { | |||||
| if (obact && (obact->type == OB_GPENCIL)) { | |||||
| ED_gpencil_toggle_brush_cursor(C, false); | |||||
| } | |||||
| } | |||||
| if (sa && (sa->spacetype == SPACE_IMAGE)) { | if (sa && (sa->spacetype == SPACE_IMAGE)) { | ||||
| SpaceImage *sima = (SpaceImage *)sa->spacedata.first; | SpaceImage *sima = (SpaceImage *)sa->spacedata.first; | ||||
| if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { | if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) { | ||||
| if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) { | if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) { | ||||
| if (U.uiflag & USER_GLOBALUNDO) { | if (U.uiflag & USER_GLOBALUNDO) { | ||||
| ED_viewport_render_kill_jobs(wm, bmain, true); | ED_viewport_render_kill_jobs(wm, bmain, true); | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | else if (U.uiflag & USER_GLOBALUNDO) { | ||||
| else | else | ||||
| BKE_undo_step(C, step); | BKE_undo_step(C, step); | ||||
| scene = CTX_data_scene(C); | scene = CTX_data_scene(C); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); | ||||
| } | } | ||||
| } | } | ||||
| /* Set special modes for grease pencil */ | |||||
| if (sa && (sa->spacetype == SPACE_VIEW3D)) { | |||||
| obact = CTX_data_active_object(C); | |||||
| if (obact && (obact->type == OB_GPENCIL)) { | |||||
| /* set cursor */ | |||||
| if (obact->mode == OB_MODE_GPENCIL_PAINT) { | |||||
| ED_gpencil_toggle_brush_cursor(C, true); | |||||
| } | |||||
| else if (obact->mode == OB_MODE_GPENCIL_SCULPT) { | |||||
| ED_gpencil_toggle_brush_cursor(C, true); | |||||
| } | |||||
| else if (obact->mode == OB_MODE_GPENCIL_WEIGHT) { | |||||
| ED_gpencil_toggle_brush_cursor(C, true); | |||||
| } | |||||
| else { | |||||
| ED_gpencil_toggle_brush_cursor(C, false); | |||||
| } | |||||
| /* set workspace mode */ | |||||
| BKE_workspace_object_mode_set(CTX_wm_workspace(C), obact->mode); | |||||
| } | |||||
| } | |||||
| WM_event_add_notifier(C, NC_WINDOW, NULL); | WM_event_add_notifier(C, NC_WINDOW, NULL); | ||||
| WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL); | WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL); | ||||
| if (win) { | if (win) { | ||||
| win->addmousemove = true; | win->addmousemove = true; | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void ED_undo_grouped_push(bContext *C, const char *str) | void ED_undo_grouped_push(bContext *C, const char *str) | ||||
| ▲ Show 20 Lines • Show All 448 Lines • Show Last 20 Lines | |||||