Blender V4.5
ed_undo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
11#include "CLG_log.h"
12
13#include "DNA_object_types.h"
14#include "DNA_scene_types.h"
15
16#include "BLI_listbase.h"
17#include "BLI_utildefines.h"
18
19#include "BKE_blender_undo.hh"
20#include "BKE_callbacks.hh"
21#include "BKE_context.hh"
22#include "BKE_global.hh"
23#include "BKE_layer.hh"
24#include "BKE_main.hh"
25#include "BKE_paint.hh"
26#include "BKE_report.hh"
27#include "BKE_scene.hh"
28#include "BKE_screen.hh"
29#include "BKE_undo_system.hh"
30#include "BKE_workspace.hh"
31
32#include "BLO_blend_validate.hh"
33
34#include "ED_asset.hh"
35#include "ED_gpencil_legacy.hh"
36#include "ED_object.hh"
37#include "ED_outliner.hh"
38#include "ED_render.hh"
39#include "ED_screen.hh"
40#include "ED_undo.hh"
41
42#include "WM_api.hh"
43#include "WM_toolsystem.hh"
44#include "WM_types.hh"
45
46#include "RNA_access.hh"
47#include "RNA_define.hh"
48#include "RNA_enum_types.hh"
49
50#include "UI_interface.hh"
51
52using blender::Set;
53using blender::Vector;
54
56static CLG_LogRef LOG = {"ed.undo"};
57
58/* -------------------------------------------------------------------- */
63
65{
67
68 /* Currently only checks matching begin/end calls. */
69 if (wm->undo_stack == nullptr) {
70 /* No undo stack is valid, nothing to do. */
71 return true;
72 }
73 if (wm->undo_stack->group_level != 0) {
74 /* If this fails #ED_undo_grouped_begin, #ED_undo_grouped_end calls don't match. */
75 return false;
76 }
77 if (wm->undo_stack->step_active != nullptr) {
78 if (wm->undo_stack->step_active->skip == true) {
79 /* Skip is only allowed between begin/end calls,
80 * a state that should never happen in main event loop. */
81 return false;
82 }
83 }
84 return true;
85}
86
92
98
99void ED_undo_push(bContext *C, const char *str)
100{
101 CLOG_INFO(&LOG, 1, "name='%s'", str);
103
105 int steps = U.undosteps;
106
107 /* Ensure steps that have been initialized are always pushed,
108 * even when undo steps are zero.
109 *
110 * Note that some modes (paint, sculpt) initialize an undo step before an action runs,
111 * then accumulate changes there, or restore data from it in the case of 2D painting.
112 *
113 * For this reason we need to handle the undo step even when undo steps is set to zero.
114 */
115 if ((steps <= 0) && wm->undo_stack->step_init != nullptr) {
116 steps = 1;
117 }
118 if (steps <= 0) {
119 return;
120 }
121 if (G.background) {
122 /* Python developers may have explicitly created the undo stack in background mode,
123 * otherwise allow it to be nullptr, see: #60934.
124 * Otherwise it must never be nullptr, even when undo is disabled. */
125 if (wm->undo_stack == nullptr) {
126 return;
127 }
128 }
129
130 eUndoPushReturn push_retval;
131
132 /* Only apply limit if this is the last undo step. */
133 if (wm->undo_stack->step_active && (wm->undo_stack->step_active->next == nullptr)) {
135 }
136
137 push_retval = BKE_undosys_step_push(wm->undo_stack, C, str);
138
139 if (U.undomemory != 0) {
140 const size_t memory_limit = size_t(U.undomemory) * 1024 * 1024;
142 }
143
144 if (CLOG_CHECK(&LOG, 1)) {
146 }
147
148 if (push_retval & UNDO_PUSH_RET_OVERRIDE_CHANGED) {
150 }
151}
152
157 wmWindowManager *wm,
158 const enum eUndoStepDir undo_dir,
160{
161 BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
162
163 Main *bmain = CTX_data_main(C);
164 Scene *scene = CTX_data_scene(C);
165
166 /* undo during jobs are running can easily lead to freeing data using by jobs,
167 * or they can just lead to freezing job in some other cases */
169
170 if (G.debug & G_DEBUG_IO) {
171 if (bmain->lock != nullptr) {
173 reports, RPT_DEBUG, "Checking validity of current .blend file *BEFORE* undo step");
175 }
176 }
177
178 /* App-Handlers (pre). */
179 {
180 /* NOTE: ignore grease pencil for now. */
181 wm->op_undo_depth++;
183 bmain, &scene->id, (undo_dir == STEP_UNDO) ? BKE_CB_EVT_UNDO_PRE : BKE_CB_EVT_REDO_PRE);
184 wm->op_undo_depth--;
185 }
186}
187
194 wmWindowManager *wm,
195 const enum eUndoStepDir undo_dir,
197{
198 using namespace blender::ed;
199 BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
200
201 Main *bmain = CTX_data_main(C);
202 Scene *scene = CTX_data_scene(C);
203
204 /* App-Handlers (post). */
205 {
206 wm->op_undo_depth++;
208 bmain, &scene->id, (undo_dir == STEP_UNDO) ? BKE_CB_EVT_UNDO_POST : BKE_CB_EVT_REDO_POST);
209 wm->op_undo_depth--;
210 }
211
212 if (G.debug & G_DEBUG_IO) {
213 if (bmain->lock != nullptr) {
214 BKE_report(reports, RPT_INFO, "Checking validity of current .blend file *AFTER* undo step");
216 }
217 }
218
221
224
226
227 if (CLOG_CHECK(&LOG, 1)) {
228 BKE_undosys_print(wm->undo_stack);
229 }
230}
231
238 enum eUndoStepDir step,
240{
242
243 CLOG_INFO(&LOG, 1, "direction=%s", (step == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
244
246
248
249 if (step == STEP_UNDO) {
250 BKE_undosys_step_undo(wm->undo_stack, C);
251 }
252 else {
253 BKE_undosys_step_redo(wm->undo_stack, C);
254 }
255
257
258 return OPERATOR_FINISHED;
259}
260
266static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
267{
268 BLI_assert(undo_name != nullptr);
269
271 UndoStep *undo_step_from_name = BKE_undosys_step_find_by_name(wm->undo_stack, undo_name);
272 if (undo_step_from_name == nullptr) {
273 CLOG_ERROR(&LOG, "Step name='%s' not found in current undo stack", undo_name);
274
275 return OPERATOR_CANCELLED;
276 }
277
278 UndoStep *undo_step_target = undo_step_from_name->prev;
279 if (undo_step_target == nullptr) {
280 CLOG_ERROR(&LOG, "Step name='%s' cannot be undone", undo_name);
281
282 return OPERATOR_CANCELLED;
283 }
284
285 const int undo_dir_i = BKE_undosys_step_calc_direction(
286 wm->undo_stack, undo_step_target, nullptr);
287 BLI_assert(ELEM(undo_dir_i, -1, 1));
288 const enum eUndoStepDir undo_dir = (undo_dir_i == -1) ? STEP_UNDO : STEP_REDO;
289
290 CLOG_INFO(&LOG,
291 1,
292 "name='%s', found direction=%s",
293 undo_name,
294 (undo_dir == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
295
296 ed_undo_step_pre(C, wm, undo_dir, reports);
297
298 BKE_undosys_step_load_data_ex(wm->undo_stack, C, undo_step_target, nullptr, true);
299
300 ed_undo_step_post(C, wm, undo_dir, reports);
301
302 return OPERATOR_FINISHED;
303}
304
310static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *reports)
311{
312 BLI_assert(undo_index >= 0);
313
315 const int active_step_index = BLI_findindex(&wm->undo_stack->steps, wm->undo_stack->step_active);
316 if (undo_index == active_step_index) {
317 return OPERATOR_CANCELLED;
318 }
319 const enum eUndoStepDir undo_dir = (undo_index < active_step_index) ? STEP_UNDO : STEP_REDO;
320
321 CLOG_INFO(&LOG,
322 1,
323 "index='%d', found direction=%s",
324 undo_index,
325 (undo_dir == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
326
327 ed_undo_step_pre(C, wm, undo_dir, reports);
328
329 BKE_undosys_step_load_from_index(wm->undo_stack, C, undo_index);
330
331 ed_undo_step_post(C, wm, undo_dir, reports);
332
333 return OPERATOR_FINISHED;
334}
335
337{
338 /* do nothing if previous undo task is the same as this one (or from the same undo group) */
340 const UndoStep *us = wm->undo_stack->step_active;
341 if (us && STREQ(str, us->name)) {
343 }
344
345 /* push as usual */
347}
348
350{
352}
354{
356}
357
359{
360 /* in future, get undo string info? */
361 ED_undo_push(C, op->type->name);
362}
363
365{
366 if (op->type->undo_group[0] != '\0') {
368 }
369 else {
371 }
372}
373
375{
376 /* search back a couple of undo's, in case something else added pushes */
378}
379
380bool ED_undo_is_valid(const bContext *C, const char *undoname)
381{
383 return BKE_undosys_stack_has_undo(wm->undo_stack, undoname);
384}
385
387{
388 /* Some modes don't co-exist with memfile undo, disable their use: #60593
389 * (this matches 2.7x behavior). */
390 const Scene *scene = CTX_data_scene(C);
391 ViewLayer *view_layer = CTX_data_view_layer(C);
392 if (view_layer != nullptr) {
393 BKE_view_layer_synced_ensure(scene, view_layer);
394 Object *obact = BKE_view_layer_active_object_get(view_layer);
395 if (obact != nullptr) {
396 if (obact->mode & OB_MODE_EDIT) {
397 return false;
398 }
399 }
400 }
401 return true;
402}
403
405{
406 if (!RNA_struct_undo_check(ptr.type)) {
407 return false;
408 }
409 /* If the whole ID type doesn't support undo there is no need to check the current context. */
410 if (id && !ID_CHECK_UNDO(id)) {
411 return false;
412 }
413
414 const Scene *scene = CTX_data_scene(C);
415 ViewLayer *view_layer = CTX_data_view_layer(C);
416 if (view_layer != nullptr) {
417 BKE_view_layer_synced_ensure(scene, view_layer);
418 Object *obact = BKE_view_layer_active_object_get(view_layer);
419 if (obact != nullptr) {
421 /* For all non-weight-paint paint modes: Don't store property changes when painting.
422 * Weight Paint and Vertex Paint use global undo, and thus don't need to be special-cased
423 * here. */
424 CLOG_INFO(&LOG, 1, "skipping undo for paint-mode");
425 return false;
426 }
427 if (obact->mode & OB_MODE_EDIT) {
428 if ((id == nullptr) || (obact->data == nullptr) ||
429 (GS(id->name) != GS(((ID *)obact->data)->name)))
430 {
431 /* No undo push on id type mismatch in edit-mode. */
432 CLOG_INFO(&LOG, 1, "skipping undo for edit-mode");
433 return false;
434 }
435 }
436 }
437 }
438 return true;
439}
440
442{
443 wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
444 return wm->undo_stack;
445}
446
448
449/* -------------------------------------------------------------------- */
452
457{
458 /* The "last operator" should disappear, later we can tie this with undo stack nicer. */
460
461 /* Keep button under the cursor active. */
463
465}
466
468{
469 /* "last operator" should disappear, later we can tie this with undo stack nicer */
472 if (ret & OPERATOR_FINISHED) {
474 }
475 return ret;
476}
477
479{
480 if (G.background) {
481 /* Exception for background mode, see: #60934.
482 * NOTE: since the undo stack isn't initialized on startup, background mode behavior
483 * won't match regular usage, this is just for scripts to do explicit undo pushes. */
485 if (wm->undo_stack == nullptr) {
486 wm->undo_stack = BKE_undosys_stack_create();
487 }
488 }
489 char str[BKE_UNDO_STR_MAX];
490 RNA_string_get(op->ptr, "message", str);
492 return OPERATOR_FINISHED;
493}
494
503
505{
509 if (ret & OPERATOR_FINISHED) {
510 /* Keep button under the cursor active. */
512 }
513 return ret;
514}
515
516/* Disable in background mode, we could support if it's useful, #60934. */
517
519{
521 if (wm->undo_stack == nullptr) {
522 /* This message is intended for Python developers,
523 * it will be part of the exception when attempting to call undo in background mode. */
525 C,
526 "Undo disabled at startup in background-mode "
527 "(call `ed.undo_push()` to explicitly initialize the undo-system)");
528 return false;
529 }
530 return true;
531}
532
534{
535 if (ed_undo_is_init_poll(C) == false) {
536 return false;
537 }
539}
540
542{
544 return (last_op && ed_undo_is_init_and_screenactive_poll(C) &&
546}
547
549{
551 return false;
552 }
554 return (undo_stack->step_active != nullptr) && (undo_stack->step_active->prev != nullptr);
555}
556
558{
559 /* identifiers */
560 ot->name = "Undo";
561 ot->description = "Undo previous action";
562 ot->idname = "ED_OT_undo";
563
564 /* API callbacks. */
565 ot->exec = ed_undo_exec;
566 ot->poll = ed_undo_poll;
567}
568
570{
571 /* identifiers */
572 ot->name = "Undo Push";
573 ot->description = "Add an undo state (internal use only)";
574 ot->idname = "ED_OT_undo_push";
575
576 /* API callbacks. */
577 ot->exec = ed_undo_push_exec;
578 /* Unlike others undo operators this initializes undo stack. */
580
581 ot->flag = OPTYPE_INTERNAL;
582
583 RNA_def_string(ot->srna,
584 "message",
585 "Add an undo step *function may be moved*",
587 "Undo Message",
588 "");
589}
590
592{
594 return false;
595 }
597 return (undo_stack->step_active != nullptr) && (undo_stack->step_active->next != nullptr);
598}
599
601{
602 /* identifiers */
603 ot->name = "Redo";
604 ot->description = "Redo previous action";
605 ot->idname = "ED_OT_redo";
606
607 /* API callbacks. */
608 ot->exec = ed_redo_exec;
609 ot->poll = ed_redo_poll;
610}
611
613{
614 /* identifiers */
615 ot->name = "Undo and Redo";
616 ot->description = "Undo and redo previous action";
617 ot->idname = "ED_OT_undo_redo";
618
619 /* API callbacks. */
620 ot->exec = ed_undo_redo_exec;
621 ot->poll = ed_undo_redo_poll;
622}
623
625
626/* -------------------------------------------------------------------- */
629
631{
632 bool success = false;
633
634 if (op) {
635 CLOG_INFO(&LOG, 1, "idname='%s'", op->type->idname);
637 const ScrArea *area = CTX_wm_area(C);
638 Scene *scene = CTX_data_scene(C);
639
640 /* keep in sync with logic in view3d_panel_operator_redo() */
641 ARegion *region_orig = CTX_wm_region(C);
642 /* If the redo is called from a HUD, this knows about the region type the operator was
643 * initially called in, so attempt to restore that. */
644 ARegion *redo_region_from_hud = (region_orig->regiontype == RGN_TYPE_HUD) ?
645 ED_area_type_hud_redo_region_find(area, region_orig) :
646 nullptr;
647 ARegion *region_repeat = redo_region_from_hud ? redo_region_from_hud :
649
650 if (region_repeat) {
651 CTX_wm_region_set(C, region_repeat);
652 }
653
655 /* NOTE: undo/redo can't run if there are jobs active,
656 * check for screen jobs only so jobs like material/texture/world preview
657 * (which copy their data), won't stop redo, see #29579.
658 *
659 * NOTE: WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this. */
660 (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0))
661 {
662 if (G.debug & G_DEBUG) {
663 printf("redo_cb: operator redo %s\n", op->type->name);
664 }
665
667
668 ED_undo_pop_op(C, op);
669
670 if (op->type->check) {
671 if (op->type->check(C, op)) {
672 /* check for popup and re-layout buttons */
673 ARegion *region_popup = CTX_wm_region_popup(C);
674 if (region_popup) {
675 ED_region_tag_refresh_ui(region_popup);
676 }
677 }
678 }
679
680 const wmOperatorStatus retval = WM_operator_repeat(C, op);
681 if ((retval & OPERATOR_FINISHED) == 0) {
682 if (G.debug & G_DEBUG) {
683 printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
684 }
686 }
687 else {
688 success = true;
689 }
690 }
691 else {
692 if (G.debug & G_DEBUG) {
693 printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name);
694 }
695 }
696
697 /* set region back */
698 CTX_wm_region_set(C, region_orig);
699 }
700 else {
701 CLOG_WARN(&LOG, "called with nullptr 'op'");
702 }
703
704 return success;
705}
706
707void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void * /*arg_unused*/)
708{
710}
711
712void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int /*arg_unused*/)
713{
715}
716
718
719/* -------------------------------------------------------------------- */
724
725/* NOTE: also check #ed_undo_step() in top if you change notifiers. */
727{
728 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
729 if (RNA_property_is_set(op->ptr, prop)) {
730 const int item = RNA_property_int_get(op->ptr, prop);
731 const int ret = ed_undo_step_by_index(C, item, op->reports);
732 if (ret & OPERATOR_FINISHED) {
734
736 return OPERATOR_FINISHED;
737 }
738 }
739 return OPERATOR_CANCELLED;
740}
741
743{
744 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
745 if (RNA_property_is_set(op->ptr, prop)) {
746 return undo_history_exec(C, op);
747 }
748
749 WM_menu_name_call(C, "TOPBAR_MT_undo_history", WM_OP_INVOKE_DEFAULT);
750 return OPERATOR_FINISHED;
751}
752
754{
755 /* identifiers */
756 ot->name = "Undo History";
757 ot->description = "Redo specific action in history";
758 ot->idname = "ED_OT_undo_history";
759
760 /* API callbacks. */
761 ot->invoke = undo_history_invoke;
762 ot->exec = undo_history_exec;
764
765 RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);
766}
767
769
770/* -------------------------------------------------------------------- */
773
775 Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
776{
777 using namespace blender::ed;
778 BKE_view_layer_synced_ensure(scene, view_layer);
779 Object *ob_prev = BKE_view_layer_active_object_get(view_layer);
780 if (ob_prev != ob) {
781 Base *base = BKE_view_layer_base_find(view_layer, ob);
782 if (base != nullptr) {
783 view_layer->basact = base;
784 object::base_active_refresh(G_MAIN, scene, view_layer);
785 }
786 else {
787 /* Should never fail, may not crash but can give odd behavior. */
788 CLOG_WARN(log, "'%s' failed to restore active object: '%s'", info, ob->id.name + 2);
789 }
790 }
791}
792
794 const Scene *scene_ref,
795 Scene **scene_p,
796 ViewLayer **view_layer_p)
797{
798 if (*scene_p == scene_ref) {
799 return;
800 }
801 LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
802 if (win->scene == scene_ref) {
803 *scene_p = win->scene;
804 *view_layer_p = WM_window_get_active_view_layer(win);
805 return;
806 }
807 }
808}
809
811 ViewLayer *view_layer,
812 Object **object_array,
813 uint object_array_len,
814 uint object_array_stride)
815{
816 using namespace blender::ed;
817 Main *bmain = G_MAIN;
818 /* Don't request unique data because we want to de-select objects when exiting edit-mode
819 * for that to be done on all objects we can't skip ones that share data. */
821 for (Base *base : bases) {
822 ((ID *)base->object->data)->tag |= ID_TAG_DOIT;
823 }
824 Object **ob_p = object_array;
825 for (uint i = 0; i < object_array_len;
826 i++, ob_p = static_cast<Object **>(POINTER_OFFSET(ob_p, object_array_stride)))
827 {
828 Object *obedit = *ob_p;
830 ((ID *)obedit->data)->tag &= ~ID_TAG_DOIT;
831 }
832 for (Base *base : bases) {
833 const ID *id = static_cast<ID *>(base->object->data);
834 if (id->tag & ID_TAG_DOIT) {
835 object::editmode_exit_ex(bmain, scene, base->object, object::EM_FREEDATA);
836 /* Ideally we would know the selection state it was before entering edit-mode,
837 * for now follow the convention of having them unselected when exiting the mode. */
839 }
840 }
841}
842
844
845/* -------------------------------------------------------------------- */
854
856 ViewLayer *view_layer)
857{
858 BKE_view_layer_synced_ensure(scene, view_layer);
859 Base *baseact = BKE_view_layer_active_base_get(view_layer);
860 if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
861 return {};
862 }
863 Set<const ID *> object_data;
864 const short object_type = baseact->object->type;
865 Vector<Object *> objects(object_data.size());
866 /* Base iteration, starting with the active-base to ensure it's the first item in the array.
867 * Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
868 for (Base *base = baseact,
869 *base_next = static_cast<Base *>(BKE_view_layer_object_bases_get(view_layer)->first);
870 base;
871 base = base_next, base_next = base_next ? base_next->next : nullptr)
872 {
873 Object *ob = base->object;
874 if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
875 if (object_data.add(static_cast<const ID *>(ob->data))) {
876 objects.append(ob);
877 }
878 }
879 }
880 BLI_assert(!object_data.is_empty());
881 BLI_assert(objects[0] == baseact->object);
882 return objects;
883}
884
886{
887 BKE_view_layer_synced_ensure(scene, view_layer);
888 Base *baseact = BKE_view_layer_active_base_get(view_layer);
889 if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
890 return {};
891 }
892 Set<const ID *> object_data;
893 const short object_type = baseact->object->type;
894 Vector<Base *> bases;
895 /* Base iteration, starting with the active-base to ensure it's the first item in the array.
896 * Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
897 for (Base *base = BKE_view_layer_active_base_get(view_layer),
898 *base_next = static_cast<Base *>(BKE_view_layer_object_bases_get(view_layer)->first);
899 base;
900 base = base_next, base_next = base_next ? base_next->next : nullptr)
901 {
902 Object *ob = base->object;
903 if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
904 if (object_data.add(static_cast<const ID *>(ob->data))) {
905 bases.append(base);
906 }
907 }
908 }
909
910 BLI_assert(!object_data.is_empty());
911 BLI_assert(bases[0] == baseact);
912 return bases;
913}
914
#define BKE_UNDO_STR_MAX
void BKE_callback_exec_id(Main *bmain, ID *id, eCbEvent evt)
Definition callbacks.cc:43
@ BKE_CB_EVT_REDO_POST
@ BKE_CB_EVT_REDO_PRE
@ BKE_CB_EVT_UNDO_PRE
@ BKE_CB_EVT_UNDO_POST
ARegion * CTX_wm_region_popup(const bContext *C)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define G_MAIN
@ G_DEBUG
@ G_DEBUG_IO
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
ARegion * BKE_area_find_region_active_win(const ScrArea *area)
Definition screen.cc:853
void BKE_undosys_step_load_from_index(UndoStack *ustack, bContext *C, int index)
bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name)
bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C)
bool BKE_undosys_step_undo(UndoStack *ustack, bContext *C)
void BKE_undosys_stack_clear_active(UndoStack *ustack)
eUndoPushReturn BKE_undosys_step_push(UndoStack *ustack, bContext *C, const char *name)
eUndoStepDir BKE_undosys_step_calc_direction(const UndoStack *ustack, const UndoStep *us_target, const UndoStep *us_reference)
eUndoStepDir
@ STEP_UNDO
@ STEP_REDO
void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit)
UndoStep * BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name)
bool BKE_undosys_step_load_data_ex(UndoStack *ustack, bContext *C, UndoStep *us_target, UndoStep *us_reference, bool use_skip)
eUndoPushReturn
@ UNDO_PUSH_RET_OVERRIDE_CHANGED
void BKE_undosys_stack_group_end(UndoStack *ustack)
UndoStack * BKE_undosys_stack_create()
void BKE_undosys_print(UndoStack *ustack)
void BKE_undosys_stack_group_begin(UndoStack *ustack)
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
#define LISTBASE_FOREACH(type, var, list)
unsigned int uint
#define ELEM(...)
#define POINTER_OFFSET(v, ofs)
#define STREQ(a, b)
Utilities ensuring .blend file (i.e. Main) is in valid state during write and/or read process.
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:182
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:181
#define CLOG_CHECK(clg_ref, verbose_level,...)
Definition CLG_log.h:153
#define CLOG_INFO(clg_ref, level,...)
Definition CLG_log.h:179
@ ID_TAG_DOIT
Definition DNA_ID.h:944
#define OB_MODE_ALL_PAINT
@ OB_MODE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_VERTEX_PAINT
Object is a sort of wrapper for general info.
@ RGN_TYPE_HUD
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
void ED_outliner_select_sync_from_all_tag(bContext *C)
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:668
ARegion * ED_area_type_hud_redo_region_find(const ScrArea *area, const ARegion *hud_region)
bool ED_operator_screenactive(bContext *C)
#define C
Definition RandGen.cpp:29
@ WM_JOB_TYPE_ANY
Definition WM_api.hh:1725
#define NC_WINDOW
Definition WM_types.hh:372
#define NC_WM
Definition WM_types.hh:371
@ OPTYPE_INTERNAL
Definition WM_types.hh:202
#define ND_LIB_OVERRIDE_CHANGED
Definition WM_types.hh:416
ReportList * reports
Definition WM_types.hh:1025
#define ND_UNDO
Definition WM_types.hh:414
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:238
#define U
int64_t size() const
Definition BLI_set.hh:587
bool add(const Key &key)
Definition BLI_set.hh:248
bool is_empty() const
Definition BLI_set.hh:595
void append(const T &value)
void ED_undo_object_set_active_or_warn(Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
Definition ed_undo.cc:774
void ED_undo_push(bContext *C, const char *str)
Definition ed_undo.cc:99
bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, PointerRNA &ptr)
Definition ed_undo.cc:404
void ED_OT_redo(wmOperatorType *ot)
Definition ed_undo.cc:600
UndoStack * ED_undo_stack_get()
Definition ed_undo.cc:441
static wmOperatorStatus undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition ed_undo.cc:742
static void ed_undo_step_pre(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
Definition ed_undo.cc:156
void ED_undo_push_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:358
void ED_undo_pop_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:374
void ED_undo_group_begin(bContext *C)
Definition ed_undo.cc:87
bool ED_undo_is_valid(const bContext *C, const char *undoname)
Definition ed_undo.cc:380
void ED_OT_undo_redo(wmOperatorType *ot)
Definition ed_undo.cc:612
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int)
Definition ed_undo.cc:712
static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *reports)
Definition ed_undo.cc:310
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *)
Definition ed_undo.cc:707
void ED_OT_undo_push(wmOperatorType *ot)
Definition ed_undo.cc:569
static wmOperatorStatus ed_undo_step_direction(bContext *C, enum eUndoStepDir step, ReportList *reports)
Definition ed_undo.cc:237
static void ed_undo_step_post(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
Definition ed_undo.cc:193
static void ed_undo_refresh_for_op(bContext *C)
Definition ed_undo.cc:456
static wmOperatorStatus ed_undo_push_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:478
static wmOperatorStatus ed_undo_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:467
Vector< Object * > ED_undo_editmode_objects_from_view_layer(const Scene *scene, ViewLayer *view_layer)
Definition ed_undo.cc:855
static bool ed_redo_poll(bContext *C)
Definition ed_undo.cc:591
static bool ed_undo_is_init_poll(bContext *C)
Definition ed_undo.cc:518
static bool ed_undo_is_init_and_screenactive_poll(bContext *C)
Definition ed_undo.cc:533
static wmOperatorStatus ed_redo_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:495
static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
Definition ed_undo.cc:266
void ED_undo_redo(bContext *C)
Definition ed_undo.cc:353
static wmOperatorStatus ed_undo_redo_exec(bContext *C, wmOperator *)
Definition ed_undo.cc:504
bool ED_undo_is_state_valid(bContext *C)
Definition ed_undo.cc:64
static wmOperatorStatus undo_history_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:726
void ED_OT_undo(wmOperatorType *ot)
Definition ed_undo.cc:557
bool ED_undo_operator_repeat(bContext *C, wmOperator *op)
Definition ed_undo.cc:630
void ED_OT_undo_history(wmOperatorType *ot)
Definition ed_undo.cc:753
static bool ed_undo_poll(bContext *C)
Definition ed_undo.cc:548
void ED_undo_object_editmode_restore_helper(Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
Definition ed_undo.cc:810
void ED_undo_grouped_push_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:364
static bool ed_undo_redo_poll(bContext *C)
Definition ed_undo.cc:541
bool ED_undo_is_memfile_compatible(const bContext *C)
Definition ed_undo.cc:386
void ED_undo_pop(bContext *C)
Definition ed_undo.cc:349
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm, const Scene *scene_ref, Scene **scene_p, ViewLayer **view_layer_p)
Definition ed_undo.cc:793
void ED_undo_group_end(bContext *C)
Definition ed_undo.cc:93
void ED_undo_grouped_push(bContext *C, const char *str)
Definition ed_undo.cc:336
Vector< Base * > ED_undo_editmode_bases_from_view_layer(const Scene *scene, ViewLayer *view_layer)
Definition ed_undo.cc:885
#define str(s)
#define log
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define printf(...)
#define ID_CHECK_UNDO(id)
#define GS(a)
#define LOG(severity)
Definition log.h:32
#define G(x, y, z)
void base_select(Base *base, eObjectSelect_Mode mode)
bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
void base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer)
bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
return ret
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
bool RNA_struct_undo_check(const StructRNA *type)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
static const int steps
struct Base * next
struct Object * object
Definition DNA_ID.h:404
int tag
Definition DNA_ID.h:424
char name[66]
Definition DNA_ID.h:415
MainLock * lock
Definition BKE_main.hh:312
UndoStep * step_init
UndoStep * step_active
UndoStep * prev
UndoStep * next
char name[64]
struct Base * basact
const char * name
Definition WM_types.hh:1030
const char * idname
Definition WM_types.hh:1032
bool(* check)(bContext *C, wmOperator *op)
Definition WM_types.hh:1054
const char * undo_group
Definition WM_types.hh:1038
struct ReportList * reports
struct wmOperatorType * type
struct PointerRNA * ptr
struct UndoStack * undo_stack
i
Definition text_draw.cc:230
#define undo_stack
void WM_operator_stack_clear(wmWindowManager *wm)
Definition wm.cc:374
void WM_operator_free_all_after(wmWindowManager *wm, wmOperator *op)
Definition wm.cc:310
void WM_menu_name_call(bContext *C, const char *menu_name, short context)
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
bool WM_operator_repeat_check(const bContext *, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
wmOperatorStatus WM_operator_repeat(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_add_mousemove(wmWindow *win)
void WM_file_tag_modified()
Definition wm_files.cc:174
PointerRNA * ptr
Definition wm_files.cc:4226
wmOperatorType * ot
Definition wm_files.cc:4225
void WM_jobs_kill_all(wmWindowManager *wm)
Definition wm_jobs.cc:577
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
Definition wm_jobs.cc:224
bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
wmOperator * WM_operator_last_redo(const bContext *C)
size_t memory_limit
void WM_toolsystem_refresh_screen_all(Main *bmain)
void WM_toolsystem_refresh_active(bContext *C)
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)