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:
authorTon Roosendaal <ton@blender.org>2009-07-29 21:56:38 +0400
committerTon Roosendaal <ton@blender.org>2009-07-29 21:56:38 +0400
commit4a1266baadf2251bf19ac8ebe15e334273b1f5a3 (patch)
treebfe8d1125ed33ab1732a718c7539d3be6081fa5f /source/blender/editors/util
parentfa7a2091f1afb50e276730c5fdc0ff4b7141f327 (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/util')
-rw-r--r--source/blender/editors/util/editmode_undo.c15
-rw-r--r--source/blender/editors/util/undo.c46
-rw-r--r--source/blender/editors/util/util_intern.h1
3 files changed, 47 insertions, 15 deletions
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 */