More undo goodies;

- Undo for editmode Font object
- Undo for posemode :)
  (btw; it also means posemode remains active on file load)
This commit is contained in:
2004-11-07 20:11:42 +00:00
parent ac0bb78a20
commit 1ba95262f6
7 changed files with 92 additions and 23 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
/***/

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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)
if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)
undo_editmode_step(1);
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
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)
if ELEM5(G.obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL)
undo_editmode_step(-1);
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF)
undo_editmode_step(-1);
else if (G.obedit->type==OB_MBALL)
undo_editmode_step(-1);
}
else {
if(G.f & G_WEIGHTPAINT)