diff options
author | Ton Roosendaal <ton@blender.org> | 2005-05-08 16:00:28 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-05-08 16:00:28 +0400 |
commit | eec4e3271442808f47bc8f4226b82692ffbcc541 (patch) | |
tree | 2db20ec32afc3f52eaec7ff2341fb738b122d652 | |
parent | 744bb6f19a4e0679bc047c0311a187d2121eb23b (diff) |
Another Transform todo: correct Undo names for using Transform.
Martin; I've added calls like:
BIF_TransformSetUndo("Add Duplicate");
In advance of calling transform itself, to indicate that this is the
string name to be used for Undo, and also has to be done on ESC.
To make that possible I had to add a memset() to zero the global struct
TransInfo. Nicely done with if(Trans.mode==TRANS_INIT)
Not sure how this relates to setting constraints in advance... I always
found it tricky to work a non-initalized global struct. :)
-rwxr-xr-x | source/blender/include/BIF_transform.h | 3 | ||||
-rwxr-xr-x | source/blender/include/transform.h | 2 | ||||
-rw-r--r-- | source/blender/src/editarmature.c | 3 | ||||
-rw-r--r-- | source/blender/src/editcurve.c | 8 | ||||
-rw-r--r-- | source/blender/src/editmball.c | 1 | ||||
-rw-r--r-- | source/blender/src/editmesh_add.c | 1 | ||||
-rw-r--r-- | source/blender/src/editmesh_tools.c | 1 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 6 | ||||
-rwxr-xr-x | source/blender/src/transform.c | 59 |
9 files changed, 71 insertions, 13 deletions
diff --git a/source/blender/include/BIF_transform.h b/source/blender/include/BIF_transform.h index 680b324d917..aea415725c0 100755 --- a/source/blender/include/BIF_transform.h +++ b/source/blender/include/BIF_transform.h @@ -36,6 +36,7 @@ /* ******************** Macros & Prototypes *********************** */ /* MODE AND NUMINPUT FLAGS */ +#define TFM_INIT -1 #define TFM_REPEAT 0 #define TFM_TRANSLATION 1 #define TFM_ROTATION 2 @@ -74,6 +75,8 @@ void BIF_setLocalLockConstraint(char axis, char *text); void BIF_drawConstraint(void); void BIF_drawPropCircle(void); +void BIF_TransformSetUndo(char *str); + /* view3d manipulators */ void ManipulatorTransform(int mode); diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index 6a1d7ae8445..115e5a57e59 100755 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -152,6 +152,8 @@ typedef struct TransInfo { float vec[3]; /* translation, to show for widget */ float mat[3][3]; /* rot/rescale, to show for widget */ + + char *undostr; /* if set, uses this string for undo */ } TransInfo; diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 0dc6f5e44b7..ec0c46801e9 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1996,6 +1996,7 @@ void extrude_armature(void) /* Transform the endpoints */ countall(); + BIF_TransformSetUndo("Extrude"); Transform(TFM_TRANSLATION, CTX_NO_PET); allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWBUTSOBJECT, 0); @@ -2159,7 +2160,7 @@ void adduplicate_armature(void) curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } - + BIF_TransformSetUndo("Add Duplicate"); Transform(TFM_TRANSLATION, CTX_NO_PET); allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWBUTSOBJECT, 0); diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index ec956b8e991..e4610015e25 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -2793,7 +2793,10 @@ void addvert_Nurb(int mode) allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSEDIT, 0); - if(mode=='e') Transform(TFM_TRANSLATION, CTX_NO_PET); + if(mode=='e') { + BIF_TransformSetUndo("Extrude"); + Transform(TFM_TRANSLATION, CTX_NO_PET); + } else while(get_mbut()&R_MOUSE) BIF_wait_for_statechange(); if(mode!='e') { @@ -2828,8 +2831,8 @@ void extrude_nurb() if(ok) { makeDispList(G.obedit); - BIF_undo_push("Extrude"); countall(); + BIF_TransformSetUndo("Extrude"); Transform(TFM_TRANSLATION, CTX_NO_PET); } } @@ -3058,6 +3061,7 @@ void adduplicate_nurb() adduplicateflagNurb(1); countall(); + BIF_TransformSetUndo("Add Duplicate"); Transform(TFM_TRANSLATION, CTX_NO_PET); } diff --git a/source/blender/src/editmball.c b/source/blender/src/editmball.c index 598125db08f..1ba62b07206 100644 --- a/source/blender/src/editmball.c +++ b/source/blender/src/editmball.c @@ -312,6 +312,7 @@ void adduplicate_mball() ml= ml->prev; } + BIF_TransformSetUndo("Add Duplicate"); Transform(TFM_TRANSLATION, CTX_NO_PET); allqueue(REDRAWBUTSEDIT, 0); } diff --git a/source/blender/src/editmesh_add.c b/source/blender/src/editmesh_add.c index 6a7b11bbc42..f57fe178360 100644 --- a/source/blender/src/editmesh_add.c +++ b/source/blender/src/editmesh_add.c @@ -437,6 +437,7 @@ void adduplicate_mesh(void) waitcursor(0); countall(); + BIF_TransformSetUndo("Add Duplicate"); Transform(TFM_TRANSLATION, CTX_NO_PET); } diff --git a/source/blender/src/editmesh_tools.c b/source/blender/src/editmesh_tools.c index 2ae10c8f50a..753839698fa 100644 --- a/source/blender/src/editmesh_tools.c +++ b/source/blender/src/editmesh_tools.c @@ -580,6 +580,7 @@ void extrude_mesh(void) countall(); /* individual faces? */ + BIF_TransformSetUndo("Extrude"); if(nr==2) { Transform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_NOR_RECALC); } diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index eddad809485..749dcc0ffae 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -4132,8 +4132,10 @@ void adduplicate(float *dtrans) clear_id_newpoins(); countall(); - if(dtrans==0) Transform(TFM_TRANSLATION, CTX_NONE); - + if(dtrans==0) { + BIF_TransformSetUndo("Add Duplicate"); + Transform(TFM_TRANSLATION, CTX_NONE); + } set_active_base(BASACT); allqueue(REDRAWNLA, 0); diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 87de92863ff..ffb5a0a2c6a 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -121,7 +121,7 @@ extern void helpline(float *vec); #include "transform.h" /* GLOBAL VARIABLE THAT SHOULD MOVED TO SCREEN MEMBER OR SOMETHING */ -TransInfo Trans; +TransInfo Trans = {TFM_INIT, 0}; // enforce init on first usage int LastMode = TFM_TRANSLATION; #define TRANS_CANCEL 2 @@ -188,6 +188,37 @@ static void view_editmove(unsigned short event) } } +static char *transform_to_undostr(TransInfo *t) +{ + switch (t->mode) { + case TFM_TRANSLATION: + return "Translate"; + case TFM_ROTATION: + return "Rotate"; + case TFM_RESIZE: + return "Scale"; + case TFM_TOSPHERE: + return "To Sphere"; + case TFM_SHEAR: + return "Shear"; + case TFM_WARP: + return "Warp"; + case TFM_SHRINKFATTEN: + return "Shrink/Fatten"; + case TFM_TILT: + return "Tilt"; + case TFM_TRACKBALL: + return "Trackball"; + case TFM_PUSHPULL: + return "Push/Pull"; + case TFM_CREASE: + return "Crease"; + } + return "Transform"; +} + +/* ************************************************* */ + void Transform(int mode, int context) { int ret_val = 0; @@ -199,10 +230,8 @@ void Transform(int mode, int context) /* If MMB is pressed or not */ char mmb_press = 0; - /*joeedh -> hopefully may be what makes the old transform() constant*/ - /* ton: I doubt, but it doesnt harm for now. shouldnt be needed though */ - areawinset(curarea->win); - + /* added initialize, for external calls to set stuff in TransInfo, like undo string */ + if(Trans.mode==TFM_INIT) memset(&Trans, 0, sizeof(TransInfo)); Mat3One(mati); /* stupid PET initialisation code */ @@ -540,12 +569,16 @@ void Transform(int mode, int context) } + /* handle restoring objects and Undo */ if(ret_val == TRANS_CANCEL) { restoreTransObjects(&Trans); + if(Trans.undostr) BIF_undo_push(Trans.undostr); } else { - BIF_undo_push("Transform"); + if(Trans.undostr) BIF_undo_push(Trans.undostr); + else BIF_undo_push(transform_to_undostr(&Trans)); } + Trans.undostr= NULL; /* free data, reset vars */ postTrans(&Trans); @@ -576,7 +609,9 @@ void ManipulatorTransform(int mode) short pmval[2] = {0, 0}, mval[2], val; unsigned short event; - + /* added initialize, for external calls to set stuff in TransInfo, like undo string */ + if(Trans.mode==TFM_INIT) memset(&Trans, 0, sizeof(TransInfo)); + /* stupid PET initialisation code */ /* START */ if (Trans.propsize == 0.0f) { @@ -708,7 +743,7 @@ void ManipulatorTransform(int mode) restoreTransObjects(&Trans); } else { - BIF_undo_push("Transform"); + BIF_undo_push(transform_to_undostr(&Trans)); } /* free data, reset vars */ @@ -2161,3 +2196,11 @@ void Mirror(short mode) allqueue(REDRAWBUTSOBJECT, 0); scrarea_queue_headredraw(curarea); } + + +void BIF_TransformSetUndo(char *str) +{ + Trans.undostr= str; +} + + |