diff options
author | Ton Roosendaal <ton@blender.org> | 2004-11-07 23:11:42 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-11-07 23:11:42 +0300 |
commit | 1ba95262f6725e2dc080933ac0020b110832870c (patch) | |
tree | acb4a34274e6d6e0ef2939f6fda2fff2ee3c7b46 /source | |
parent | ac0bb78a2029b40e9e85697d4b822197b9906bd5 (diff) |
More undo goodies;
- Undo for editmode Font object
- Undo for posemode :)
(btw; it also means posemode remains active on file load)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 11 | ||||
-rw-r--r-- | source/blender/include/BIF_editfont.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/editfont.c | 58 | ||||
-rw-r--r-- | source/blender/src/editipo.c | 11 | ||||
-rw-r--r-- | source/blender/src/poseobject.c | 15 | ||||
-rw-r--r-- | source/blender/src/space.c | 16 |
7 files changed, 91 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b4c16bc039a..90f3d327f1c 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -268,6 +268,7 @@ static void clear_global(void) static void setup_app_data(BlendFileData *bfd, char *filename) { Object *ob; + Base *base; bScreen *curscreen= NULL; Scene *curscene= NULL; char mode; @@ -339,7 +340,15 @@ static void setup_app_data(BlendFileData *bfd, char *filename) G.f= bfd->globalf; - /* few DispLists, but do text_to_curve */ + /* check posemode */ + for(base= G.scene->base.first; base; base=base->next) { + ob= base->object; + if(ob->flag & OB_POSEMODE) { + if(ob->type==OB_ARMATURE) G.obpose= ob; + } + } + + /* few DispLists, but do text_to_curve */ // this should be removed!!! But first a better displist system (ton) for (ob= G.main->object.first; ob; ob= ob->id.next) { if(ob->type==OB_FONT) { diff --git a/source/blender/include/BIF_editfont.h b/source/blender/include/BIF_editfont.h index 6f4000d957f..4614403f52c 100644 --- a/source/blender/include/BIF_editfont.h +++ b/source/blender/include/BIF_editfont.h @@ -42,6 +42,7 @@ void remake_editText(void); void free_editText(void); void paste_editText(void); void txt_export_to_object(struct Text *text); +void undo_push_font(char *); /** * @attention The argument is discarded. It is there for diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 95ca75bdb4a..7c4279a3b8a 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -333,6 +333,7 @@ extern Object workob; #define OB_DONE 1024 #define OB_RADIO 2048 #define OB_FROMGROUP 4096 +#define OB_POSEMODE 8192 /* ob->gameflag */ #define OB_DYNAMIC 1 diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c index deb1b39b8a8..6ece170cb23 100644 --- a/source/blender/src/editfont.c +++ b/source/blender/src/editfont.c @@ -61,6 +61,7 @@ #include "BKE_utildefines.h" #include "BIF_editfont.h" +#include "BIF_editmode_undo.h" #include "BIF_toolbox.h" #include "BIF_space.h" #include "BIF_mywindow.h" @@ -287,7 +288,7 @@ void txt_export_to_object(struct Text *text) if(cu->str) MEM_freeN(cu->str); - cu->str= MEM_mallocN(nchars+1, "str"); + cu->str= MEM_mallocN(nchars+4, "str"); tmp= text->lines.first; strcpy(cu->str, tmp->line); @@ -369,7 +370,7 @@ void do_textedit(unsigned short event, short val, char _ascii) filelen = BLI_filesize(file); - strp= MEM_mallocN(filelen+1, "tempstr"); + strp= MEM_mallocN(filelen+4, "tempstr"); read(file, strp, filelen); close(file); strp[filelen]= 0; @@ -493,6 +494,7 @@ void do_textedit(unsigned short event, short val, char _ascii) if(doit || cursmove) { text_to_curve(G.obedit, cursmove); if(cursmove==0) makeDispList(G.obedit); + BIF_undo_push("Textedit"); allqueue(REDRAWVIEW3D, 0); } } @@ -530,7 +532,7 @@ void paste_editText(void) cu= G.obedit->data; filelen = BLI_filesize(file); - strp= MEM_mallocN(filelen+1, "tempstr"); + strp= MEM_mallocN(filelen+4, "tempstr"); read(file, strp, filelen); close(file); strp[filelen]= 0; @@ -546,6 +548,7 @@ void paste_editText(void) text_to_curve(G.obedit, 0); makeDispList(G.obedit); allqueue(REDRAWVIEW3D, 0); + BIF_undo_push("Paste text"); } } @@ -555,7 +558,7 @@ void make_editText(void) Curve *cu; cu= G.obedit->data; - if(textbuf==NULL) textbuf= MEM_mallocN(MAXTEXT, "texteditbuf"); + if(textbuf==NULL) textbuf= MEM_mallocN(MAXTEXT+4, "texteditbuf"); BLI_strncpy(textbuf, cu->str, MAXTEXT); oldstr= cu->str; cu->str= textbuf; @@ -567,6 +570,7 @@ void make_editText(void) makeDispList(G.obedit); textediting= 1; + BIF_undo_push("Original"); } @@ -579,7 +583,7 @@ void load_editText(void) MEM_freeN(oldstr); oldstr= NULL; - cu->str= MEM_mallocN(cu->len+1, "tekstedit"); + cu->str= MEM_mallocN(cu->len+4, "tekstedit"); strcpy(cu->str, textbuf); /* this memory system is weak... */ @@ -606,6 +610,7 @@ void remake_editText(void) makeDispList(G.obedit); allqueue(REDRAWVIEW3D, 0); + BIF_undo_push("Reload"); } @@ -681,7 +686,50 @@ void to_upper(void) makeDispList(G.obedit); allqueue(REDRAWVIEW3D, 0); + BIF_undo_push("To upper"); +} + + +/* **************** undo for font object ************** */ + +static void undoFont_to_editFont(void *strv) +{ + Curve *cu= G.obedit->data; + char *str= strv; + + strncpy(textbuf, str+2, MAXTEXT); + cu->pos= *((short *)str); + + text_to_curve(G.obedit, 0); + makeDispList(G.obedit); + + allqueue(REDRAWVIEW3D, 0); +} +static void *editFont_to_undoFont(void) +{ + Curve *cu= G.obedit->data; + char *str; + + str= MEM_callocN(MAXTEXT+4, "string undo"); + + strncpy(str+2, textbuf, MAXTEXT); + *((short *)str)= cu->pos; + + return str; +} + +static void free_undoFont(void *strv) +{ + MEM_freeN(strv); +} + +/* and this is all the undo system needs to know */ +void undo_push_font(char *name) +{ + undo_editmode_push(name, free_undoFont, undoFont_to_editFont, editFont_to_undoFont); } + +/***/ diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 297681a7421..02505a7986d 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -3997,7 +3997,16 @@ void common_insertkey() base= base->next; } } - BIF_undo_push("Insert Key 3D Window"); + + if(event==0) BIF_undo_push("Insert Loc Key"); + else if(event==1) BIF_undo_push("Insert Rot Key"); + else if(event==2) BIF_undo_push("Insert Size Key"); + else if(event==3) BIF_undo_push("Insert LocRot Key"); + else if(event==4) BIF_undo_push("Insert LocRotSize Key"); + else if(event==5) BIF_undo_push("Insert Layer Key"); + else if(event==7) BIF_undo_push("Insert Vertex Key"); + else if(event==9) BIF_undo_push("Insert Avail Key"); + allspace(REMAKEIPO, 0); allqueue(REDRAWIPO, 0); allqueue(REDRAWVIEW3D, 0); diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index 28cd9c123ce..fffe435968e 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -39,6 +39,8 @@ #include "BLI_winstuff.h" #endif +#include <stdlib.h> + #include "BLI_arithb.h" #include "BLI_blenlib.h" @@ -121,8 +123,11 @@ void enter_posemode(void) case OB_ARMATURE: arm= get_armature(ob); if( arm==0 ) return; + G.obpose= ob; - /* make_poseMesh(); */ + ob->flag |= OB_POSEMODE; + base->flag= ob->flag; + allqueue(REDRAWHEADERS, 0); allqueue(REDRAWBUTSALL, 0); allqueue(REDRAWOOPS, 0); @@ -207,12 +212,16 @@ static void armature_bonechildren_filter_pose_keys (bPose *pose, Bone *bone) void exit_posemode (int freedata) { Object *ob; + Base *base= BASACT; - if(G.obpose==0) return; + if(G.obpose==NULL) return; ob= G.obpose; + ob->flag &= ~OB_POSEMODE; + base->flag= ob->flag; - G.obpose= 0; + G.obpose= NULL; + makeDispList(ob); if(freedata) { diff --git a/source/blender/src/space.c b/source/blender/src/space.c index a8b2a072067..6229e17af19 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -632,6 +632,8 @@ void BIF_undo_push(char *str) undo_push_mesh(str); else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) undo_push_curve(str); + else if (G.obedit->type==OB_FONT) + undo_push_font(str); else if (G.obedit->type==OB_MBALL) undo_push_mball(str); } @@ -644,13 +646,8 @@ void BIF_undo_push(char *str) void BIF_undo(void) { if(G.obedit) { - if(G.obedit->type==OB_MESH) - undo_editmode_step(1); - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) + if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL) undo_editmode_step(1); - else if (G.obedit->type==OB_MBALL) - undo_editmode_step(1); - } else { if(G.f & G_WEIGHTPAINT) @@ -667,13 +664,8 @@ void BIF_undo(void) void BIF_redo(void) { if(G.obedit) { - if(G.obedit->type==OB_MESH) - undo_editmode_step(-1); - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) + if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL) undo_editmode_step(-1); - else if (G.obedit->type==OB_MBALL) - undo_editmode_step(-1); - } else { if(G.f & G_WEIGHTPAINT) |