Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/undo/ed_undo.c
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| #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_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_undo_system.h" | #include "BKE_undo_system.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "BKE_paint.h" | |||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_render.h" | #include "ED_render.h" | ||||
| #include "ED_object.h" | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| Show All 40 Lines | |||||
| /* note: also check undo_history_exec() in bottom if you change notifiers */ | /* note: also check undo_history_exec() in bottom if you change notifiers */ | ||||
| static int ed_undo_step(bContext *C, int step, const char *undoname) | static int ed_undo_step(bContext *C, int step, const char *undoname) | ||||
| { | { | ||||
| CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step); | CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| // Main *bmain = CTX_data_main(C); | // Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| /* undo during jobs are running can easily lead to freeing data using by jobs, | /* undo during jobs are running can easily lead to freeing data using by jobs, | ||||
| * or they can just lead to freezing job in some other cases */ | * or they can just lead to freezing job in some other cases */ | ||||
| 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; | ||||
| } | } | ||||
| /* TODO(campbell): undo_system: use undo system */ | /* TODO(campbell): undo_system: use undo system */ | ||||
| /* 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)) { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| if (obact && (obact->type == OB_GPENCIL)) { | |||||
| ED_gpencil_toggle_brush_cursor(C, false, NULL); | |||||
| } | |||||
| } | |||||
| /* Undo System */ | /* Undo System */ | ||||
| { | { | ||||
| if (undoname) { | if (undoname) { | ||||
| UndoStep *step_data = BKE_undosys_step_find_by_name(wm->undo_stack, undoname); | UndoStep *step_data = BKE_undosys_step_find_by_name(wm->undo_stack, undoname); | ||||
| BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data); | BKE_undosys_step_undo_with_data(wm->undo_stack, C, step_data); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_undosys_step_undo_compat_only(wm->undo_stack, C, step); | BKE_undosys_step_undo_compat_only(wm->undo_stack, C, step); | ||||
| } | } | ||||
| /* Set special modes for grease pencil */ | |||||
| if (sa && (sa->spacetype == SPACE_VIEW3D)) { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| if (obact && (obact->type == OB_GPENCIL)) { | |||||
| /* set cursor */ | |||||
| if (ELEM(obact->mode, OB_MODE_GPENCIL_PAINT, OB_MODE_GPENCIL_SCULPT, OB_MODE_GPENCIL_WEIGHT)) { | |||||
| ED_gpencil_toggle_brush_cursor(C, true, NULL); | |||||
| } | |||||
| else { | |||||
| ED_gpencil_toggle_brush_cursor(C, false, NULL); | |||||
| } | |||||
| /* set workspace mode */ | |||||
| Base *basact = CTX_data_active_base(C); | |||||
| ED_object_base_activate(C, basact); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| 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; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 403 Lines • Show Last 20 Lines | |||||