diff options
author | Ton Roosendaal <ton@blender.org> | 2009-07-29 21:56:38 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-07-29 21:56:38 +0400 |
commit | 4a1266baadf2251bf19ac8ebe15e334273b1f5a3 (patch) | |
tree | bfe8d1125ed33ab1732a718c7539d3be6081fa5f /source/blender/editors | |
parent | fa7a2091f1afb50e276730c5fdc0ff4b7141f327 (diff) |
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_util.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 3 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 14 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 22 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_toolbar.c | 30 | ||||
-rw-r--r-- | source/blender/editors/util/editmode_undo.c | 15 | ||||
-rw-r--r-- | source/blender/editors/util/undo.c | 46 | ||||
-rw-r--r-- | source/blender/editors/util/util_intern.h | 1 |
13 files changed, 124 insertions, 55 deletions
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 7ccbf1ff18d..7b1c87f9cb2 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -44,6 +44,7 @@ void ED_editors_exit (struct bContext *C); /* undo.c */ void ED_undo_push (struct bContext *C, char *str); void ED_undo_push_op (struct bContext *C, struct wmOperator *op); +void ED_undo_pop_op (struct bContext *C, struct wmOperator *op); void ED_undo_pop (struct bContext *C); void ED_undo_redo (struct bContext *C); void ED_OT_undo (struct wmOperatorType *ot); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index da2899dd3b2..6f2b49c0513 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -358,8 +358,8 @@ static void ui_apply_but_funcs_after(bContext *C) if(after.rename_orig) MEM_freeN(after.rename_orig); - if(after.undostr[0]) - ED_undo_push(C, after.undostr); +// if(after.undostr[0]) +// ED_undo_push(C, after.undostr); } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 92aa46ea390..34eca8748bc 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -1683,9 +1683,6 @@ static int mesh_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event) mesh_duplicate_exec(C, op); WM_cursor_wait(0); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); - return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 76f355ab7f9..93e91732b2b 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -704,7 +704,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - int constraint_axis[3] = {0, 0, 1}; +// int constraint_axis[3] = {0, 0, 1}; extrude_mesh(scene, obedit, em, op); @@ -717,11 +717,11 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_boolean_set(op->ptr, "mirror", 0); /* the following two should only be set when extruding faces */ - RNA_enum_set(op->ptr, "constraint_orientation", V3D_MANIP_NORMAL); - RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); +// RNA_enum_set(op->ptr, "constraint_orientation", V3D_MANIP_NORMAL); +// RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); - WM_operator_name_call(C, "TFM_OT_translate", WM_OP_INVOKE_REGION_WIN, op->ptr); +// WM_operator_name_call(C, "TFM_OT_translate", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; } @@ -4991,9 +4991,9 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) BKE_mesh_end_editmesh(obedit->data, em); - RNA_enum_set(op->ptr, "proportional", 0); - RNA_boolean_set(op->ptr, "mirror", 0); - WM_operator_name_call(C, "TFM_OT_translate", WM_OP_INVOKE_REGION_WIN, op->ptr); +// RNA_enum_set(op->ptr, "proportional", 0); +// RNA_boolean_set(op->ptr, "mirror", 0); +// WM_operator_name_call(C, "TFM_OT_translate", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 8ed68d5cd20..edb131d7da2 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -230,6 +230,8 @@ static void MESH_OT_specials(wmOperatorType *ot) void ED_operatortypes_mesh(void) { + wmOperatorType *ot; + WM_operatortype_append(MESH_OT_select_all_toggle); WM_operatortype_append(MESH_OT_select_more); WM_operatortype_append(MESH_OT_select_less); @@ -313,6 +315,20 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_edge_specials); WM_operatortype_append(MESH_OT_face_specials); WM_operatortype_append(MESH_OT_specials); + + /* macros */ + ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); + WM_operatortype_macro_define(ot, "TFM_OT_translate"); + + ot= WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO|OPTYPE_REGISTER); + WM_operatortype_macro_define(ot, "MESH_OT_rip"); + WM_operatortype_macro_define(ot, "TFM_OT_translate"); + + ot= WM_operatortype_append_macro("MESH_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); + WM_operatortype_macro_define(ot, "MESH_OT_extrude"); + WM_operatortype_macro_define(ot, "TFM_OT_translate"); + } /* note mesh keymap also for other space? */ @@ -363,7 +379,7 @@ void ED_keymap_mesh(wmWindowManager *wm) WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "inside", 1); - WM_keymap_add_item(keymap, "MESH_OT_extrude", EKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MESH_OT_extrude_move", EKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_screw", NINEKEY, KM_PRESS, KM_CTRL, 0); @@ -386,12 +402,12 @@ void ED_keymap_mesh(wmWindowManager *wm) WM_keymap_add_item(keymap, "MESH_OT_colors_rotate",EIGHTKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_colors_mirror",EIGHTKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "MESH_OT_rip",VKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MESH_OT_rip_move",VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); /* add/remove */ WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "MESH_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, KM_SHIFT, 0); /* use KM_RELEASE because same key is used for tweaks */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index f34dc2e7c23..5fd5f4ff0ad 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -6497,8 +6497,8 @@ static int duplicate_invoke(bContext *C, wmOperator *op, wmEvent *event) { duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); +// RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); +// WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index fe092847183..c1509e78502 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -63,6 +63,8 @@ void ED_operatortypes_object(void) { + wmOperatorType *ot; + WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); WM_operatortype_append(OBJECT_OT_parent_set); @@ -147,6 +149,13 @@ void ED_operatortypes_object(void) WM_operatortype_append(LATTICE_OT_select_all_toggle); WM_operatortype_append(LATTICE_OT_make_regular); + + /* macros */ + ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + if(ot) { + WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); + WM_operatortype_macro_define(ot, "TFM_OT_translate"); + } } void ED_keymap_object(wmWindowManager *wm) @@ -185,7 +194,7 @@ void ED_keymap_object(wmWindowManager *wm) WM_keymap_verify_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_duplicate", DKEY, KM_PRESS, KM_ALT, 0)->ptr, "linked", 1); WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f278b717f10..acb3a2257dc 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -560,7 +560,7 @@ void VIEW3D_OT_viewrotate(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING; + ot->flag= OPTYPE_BLOCKING; } /* ************************ viewmove ******************************** */ @@ -644,7 +644,7 @@ void VIEW3D_OT_viewmove(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING; + ot->flag= OPTYPE_BLOCKING; } /* ************************ viewzoom ******************************** */ @@ -844,7 +844,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING; + ot->flag= OPTYPE_BLOCKING; RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); } @@ -925,7 +925,7 @@ void VIEW3D_OT_view_all(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; RNA_def_boolean(ot->srna, "center", 0, "Center", ""); } @@ -1064,7 +1064,7 @@ void VIEW3D_OT_view_center(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; } /* ********************* Set render border operator ****************** */ @@ -1312,7 +1312,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; /* rna */ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); @@ -1477,7 +1477,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view"); } @@ -1546,7 +1546,7 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit"); } @@ -1596,7 +1596,7 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan"); } @@ -1628,7 +1628,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; } @@ -1730,7 +1730,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; /* rna */ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); @@ -1783,7 +1783,7 @@ void VIEW3D_OT_drawtype(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER; + ot->flag= 0; /* rna XXX should become enum */ RNA_def_int(ot->srna, "draw_type", 0, INT_MIN, INT_MAX, "Draw Type", "", INT_MIN, INT_MAX); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 69b297b2e03..c82db3bbe32 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -218,8 +218,8 @@ void view3d_keymap(wmWindowManager *wm) WM_keymap_add_item(keymap, "VIEW3D_OT_snap_menu", SKEY, KM_PRESS, KM_SHIFT, 0); - /* drag & drop */ - WM_keymap_add_item(keymap, "VIEW3D_OT_drag", MOUSEDRAG, KM_ANY, 0, 0); + /* drag & drop (disabled) */ +// WM_keymap_add_item(keymap, "VIEW3D_OT_drag", MOUSEDRAG, KM_ANY, 0, 0); /* radial control */ RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 1564fcb169b..67d8bc3e5ee 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -109,7 +109,7 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2) int retval; printf("operator redo %s\n", lastop->type->name); - ED_undo_pop(C); + ED_undo_pop_op(C, lastop); retval= WM_operator_repeat(C, lastop); if((retval & OPERATOR_FINISHED)==0) { printf("operator redo failed %s\n", lastop->type->name); @@ -118,11 +118,25 @@ static void redo_cb(bContext *C, void *arg_op, void *arg2) } } +static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op) +{ + wmWindowManager *wm= CTX_wm_manager(C); + PointerRNA ptr; + + if(!op->properties) { + IDPropertyTemplate val = {0}; + op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); + } + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + uiDefAutoButsRNA(C, pa->layout, &ptr, 1); + +} + static void view3d_panel_operator_redo(const bContext *C, Panel *pa) { wmWindowManager *wm= CTX_wm_manager(C); wmOperator *op; - PointerRNA ptr; uiBlock *block; block= uiLayoutGetBlock(pa->layout); @@ -139,13 +153,13 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) uiBlockSetFunc(block, redo_cb, op, NULL); - if(!op->properties) { - IDPropertyTemplate val = {0}; - op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties"); + if(op->macro.first) { + for(op= op->macro.first; op; op= op->next) + view3d_panel_operator_redo_buts(C, pa, op); + } + else { + view3d_panel_operator_redo_buts(C, pa, op); } - - RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(C, pa->layout, &ptr, 1); } /* ******************* */ diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 8484ad78bc4..17a1e0b6cdb 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -297,6 +297,21 @@ static void undo_number(bContext *C, int nr) undo_editmode_step(C, 0); } +void undo_editmode_name(bContext *C, const char *undoname) +{ + UndoElem *uel; + + for(uel= undobase.last; uel; uel= uel->prev) { + if(strcmp(undoname, uel->name)==0) + break; + } + if(uel && uel->prev) { + curundo= uel->prev; + undo_editmode_step(C, 0); + } +} + + /* ************** for interaction with menu/pullown */ void undo_editmode_menu(bContext *C) diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index be04cdecac6..435f2c7ecf4 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -71,6 +71,8 @@ #include "UI_interface.h" #include "UI_resources.h" +#include "util_intern.h" + /* ***************** generic undo system ********************* */ /* ********* XXX **************** */ @@ -81,7 +83,7 @@ void ED_undo_push(bContext *C, char *str) { wmWindowManager *wm= CTX_wm_manager(C); Object *obedit= CTX_data_edit_object(C); - + if(obedit) { if (U.undosteps == 0) return; @@ -114,13 +116,7 @@ void ED_undo_push(bContext *C, char *str) } } -void ED_undo_push_op(bContext *C, wmOperator *op) -{ - /* in future, get undo string info? */ - ED_undo_push(C, op->type->name); -} - -static int ed_undo_step(bContext *C, int step) +static int ed_undo_step(bContext *C, int step, const char *undoname) { Object *obedit= CTX_data_edit_object(C); ScrArea *sa= CTX_wm_area(C); @@ -140,8 +136,12 @@ static int ed_undo_step(bContext *C, int step) ED_text_undo_step(C, step); } else if(obedit) { - if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) - undo_editmode_step(C, step); + if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) { + if(undoname) + undo_editmode_name(C, undoname); + else + undo_editmode_step(C, step); + } } else { int do_glob_undo= 0; @@ -163,7 +163,10 @@ static int ed_undo_step(bContext *C, int step) #ifndef DISABLE_PYTHON // XXX BPY_scripts_clear_pyobjects(); #endif - BKE_undo_step(C, step); + if(undoname) + BKE_undo_name(C, undoname); + else + BKE_undo_step(C, step); sound_initialize_sounds(); } @@ -177,22 +180,35 @@ static int ed_undo_step(bContext *C, int step) void ED_undo_pop(bContext *C) { - ed_undo_step(C, 1); + ed_undo_step(C, 1, NULL); } void ED_undo_redo(bContext *C) { - ed_undo_step(C, -1); + ed_undo_step(C, -1, NULL); +} + +void ED_undo_push_op(bContext *C, wmOperator *op) +{ + /* in future, get undo string info? */ + ED_undo_push(C, op->type->name); +} + +void ED_undo_pop_op(bContext *C, wmOperator *op) +{ + /* search back a couple of undo's, in case something else added pushes */ + ed_undo_step(C, 0, op->type->name); } static int ed_undo_exec(bContext *C, wmOperator *op) { /* "last operator" should disappear, later we can tie ths with undo stack nicer */ WM_operator_stack_clear(C); - return ed_undo_step(C, 1); + return ed_undo_step(C, 1, NULL); } + static int ed_redo_exec(bContext *C, wmOperator *op) { - return ed_undo_step(C, -1); + return ed_undo_step(C, -1, NULL); } void ED_undo_menu(bContext *C) diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index 37e6c5c25e1..8a0787dde3f 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -33,6 +33,7 @@ /* editmode_undo.c */ void undo_editmode_clear(void); +void undo_editmode_name(bContext *C, const char *undoname); #endif /* ED_UTIL_INTERN_H */ |