[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18635] branches/blender2.5/blender/source /blender: 2.5

Ton Roosendaal ton at blender.org
Fri Jan 23 15:43:29 CET 2009


Revision: 18635
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18635
Author:   ton
Date:     2009-01-23 15:43:25 +0100 (Fri, 23 Jan 2009)

Log Message:
-----------
2.5

Font object + editing back.

Was quite some work due to a myriad of globals all over!
Works nicely 100% local now.

To enable a single textedit operator, I've added a new
keymap entry KM_TEXTEDIT, which gives all keyboard events
to the handler. Also had to add a new keymap-add function
to force a keymap handler in beginning of region handlers.
In future this can be used to prioritize handlers.

Also: split off the arrow keys (frame change) to a separate
region level handler. Can be set with default flag in
regiontype->keymapflag ED_KEYMAP_FRAMES

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_curve.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_font.h
    branches/blender2.5/blender/source/blender/blenkernel/BKE_global.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/anim.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/displist.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/font.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/include/ED_curve.h
    branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh.c
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/space_action/space_action.c
    branches/blender2.5/blender/source/blender/editors/space_api/spacetypes.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_image/space_image.c
    branches/blender2.5/blender/source/blender/editors/space_ipo/space_ipo.c
    branches/blender2.5/blender/source/blender/editors/space_nla/space_nla.c
    branches/blender2.5/blender/source/blender/editors/space_node/space_node.c
    branches/blender2.5/blender/source/blender/editors/space_sequencer/space_sequencer.c
    branches/blender2.5/blender/source/blender/editors/space_sound/space_sound.c
    branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_curve_types.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_api.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c
    branches/blender2.5/blender/source/blender/windowmanager/wm_event_types.h

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h
    branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c
    branches/blender2.5/blender/source/blender/editors/curve/editfont.c
    branches/blender2.5/blender/source/blender/editors/curve/lorem.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_curve.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_curve.h	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_curve.h	2009-01-23 14:43:25 UTC (rev 18635)
@@ -49,6 +49,7 @@
 
 void unlink_curve( struct Curve *cu);
 void free_curve( struct Curve *cu);
+void BKE_free_editfont(struct Curve *cu);
 struct Curve *add_curve(char *name, int type);
 struct Curve *copy_curve( struct Curve *cu);
 void make_local_curve( struct Curve *cu);

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_font.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_font.h	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_font.h	2009-01-23 14:43:25 UTC (rev 18635)
@@ -43,6 +43,7 @@
 struct Curve;
 struct objfnt;
 struct TmpFont;
+struct CharInfo;
 
 struct chartrans {
 	float xof, yof;
@@ -55,20 +56,31 @@
 	float x, y, w, h;
 } SelBox;
 
-extern struct SelBox *selboxes;
+typedef struct EditFont {	
+	wchar_t *copybuf;
+	wchar_t *copybufinfo;
+	
+	wchar_t *textbuf;
+	struct CharInfo *textbufinfo;
+	wchar_t *oldstr;
+	struct CharInfo *oldstrinfo;
+	
+	float textcurs[4][2];
+	
+} EditFont;
 
+
 void BKE_font_register_builtin(void *mem, int size);
 
 void free_vfont(struct VFont *sc); 
 void free_ttfont(void);
+struct VFont *get_builtin_font(void);
 struct VFont *load_vfont(char *name);
 struct TmpFont *vfont_find_tmpfont(struct VFont *vfont);
 
-struct chartrans *text_to_curve(struct Scene *scene, struct Object *ob, int mode);
-int style_to_sel(int style, int toggle);
-int mat_to_sel(void);
+struct chartrans *BKE_text_to_curve(struct Scene *scene, struct Object *ob, int mode);
 
-int getselection(struct Object *ob, int *start, int *end);
+int BKE_font_getselection(struct Object *ob, int *start, int *end);
 
 void chtoutf8(unsigned long c, char *o);
 void wcs2utf8s(char *dst, wchar_t *src);

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_global.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_global.h	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_global.h	2009-01-23 14:43:25 UTC (rev 18635)
@@ -76,8 +76,6 @@
 	/* Used for BMesh transformations */
 	struct BME_Glob *editBMesh;
     
-	float textcurs[4][2];
-    
 	/* Frank's variables */
 	int	save_over;
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/anim.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/anim.c	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/anim.c	2009-01-23 14:43:25 UTC (rev 18635)
@@ -991,7 +991,7 @@
 	
 	/* in par the family name is stored, use this to find the other objects */
 	
-	chartransdata= text_to_curve(scene, par, FO_DUPLI);
+	chartransdata= BKE_text_to_curve(scene, par, FO_DUPLI);
 	if(chartransdata==0) return;
 	
 	memset(obar, 0, 256*sizeof(void *));

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c	2009-01-23 14:43:25 UTC (rev 18635)
@@ -56,6 +56,7 @@
 #include "BKE_anim.h"  
 #include "BKE_curve.h"  
 #include "BKE_displist.h"  
+#include "BKE_font.h" 
 #include "BKE_global.h" 
 #include "BKE_key.h"  
 #include "BKE_library.h"  
@@ -86,14 +87,32 @@
 	cu->key= 0;
 }
 
+/* frees editcurve entirely */
+void BKE_free_editfont(Curve *cu)
+{
+	if(cu->editfont) {
+		EditFont *ef= cu->editfont;
+		
+		if(ef->oldstr) MEM_freeN(ef->oldstr);
+		if(ef->oldstrinfo) MEM_freeN(ef->oldstrinfo);
+		if(ef->textbuf) MEM_freeN(ef->textbuf);
+		if(ef->textbufinfo) MEM_freeN(ef->textbufinfo);
+		if(ef->copybuf) MEM_freeN(ef->copybuf);
+		if(ef->copybufinfo) MEM_freeN(ef->copybufinfo);
+		
+		MEM_freeN(ef);
+		cu->editfont= NULL;
+	}
+}
 
-/* niet curve zelf vrijgeven */
+/* don't free curve itself */
 void free_curve(Curve *cu)
 {
 
 	freeNurblist(&cu->nurb);
 	BLI_freelistN(&cu->bev);
 	freedisplist(&cu->disp);
+	BKE_free_editfont(cu);
 	
 	if(cu->editnurb) {
 		freeNurblist(cu->editnurb);
@@ -131,6 +150,18 @@
 	
 	cu->bb= unit_boundbox();
 	
+	if(type==OB_FONT) {
+		cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font();
+		cu->vfont->id.us+=4;
+		cu->str= MEM_mallocN(12, "str");
+		strcpy(cu->str, "Text");
+		cu->pos= 4;
+		cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo");
+		cu->totbox= cu->actbox= 1;
+		cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox");
+		cu->tb[0].w = cu->tb[0].h = 0.0;
+	}
+	
 	return cu;
 }
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/displist.c	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/displist.c	2009-01-23 14:43:25 UTC (rev 18635)
@@ -1477,7 +1477,7 @@
 		if(cu->path) free_path(cu->path);
 		cu->path= NULL;
 		
-		if(ob->type==OB_FONT) text_to_curve(scene, ob, 0);
+		if(ob->type==OB_FONT) BKE_text_to_curve(scene, ob, 0);
 		
 		if(!forOrco) curve_calc_modifiers_pre(scene, ob, 0, &originalVerts, &deformedVerts, &numVerts);
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/font.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/font.c	2009-01-23 14:08:02 UTC (rev 18634)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/font.c	2009-01-23 14:43:25 UTC (rev 18635)
@@ -65,10 +65,6 @@
 #include "BKE_curve.h"
 #include "BKE_displist.h"
 
-#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
- 
-struct SelBox *selboxes= NULL;
-
 static ListBase ttfdata= {NULL, NULL};
 
 /* UTF-8 <-> wchar transformations */
@@ -454,6 +450,17 @@
 	}			
 }
 
+VFont *get_builtin_font(void)
+{
+	VFont *vf;
+	
+	for (vf= G.main->vfont.first; vf; vf= vf->id.next)
+		if (BLI_streq(vf->name, "<builtin>"))
+			return vf;
+	
+	return load_vfont("<builtin>");
+}
+
 static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, int charidx, short mat_nr)
 {
 	Nurb *nu2;
@@ -622,11 +629,11 @@
 	}
 }
 
-int getselection(Object *ob, int *start, int *end)
+int BKE_font_getselection(Object *ob, int *start, int *end)
 {
 	Curve *cu= ob->data;
 	
-	if (cu->editstr==NULL || ob->type != OB_FONT) return 0;
+	if (cu->editfont==NULL || ob->type != OB_FONT) return 0;
 
 	if (cu->selstart == 0) return 0;
 	if (cu->selstart <= cu->selend) {
@@ -641,30 +648,23 @@
 	}
 }
 
-struct chartrans *text_to_curve(Scene *scene, Object *ob, int mode) 
+struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) 
 {
 	VFont *vfont, *oldvfont;
 	VFontData *vfd= NULL;
-	Curve *cu, *cucu;
+	Curve *cu;
+	CharInfo *info, *custrinfo;
+	TextBox *tb;
+	VChar *che;
 	struct chartrans *chartransdata=NULL, *ct;
-	float distfac, tabfac, ctime, dtime, tvec[4], vec[4], rotvec[3], minx, maxx, miny, maxy;
-	float cmat[3][3], timeofs, si, co, sizefac;
-	float *f, maxlen=0, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4;
-	int i, slen, oldflag, j;
-	short cnr=0, lnr=0, wsnr= 0;
-	wchar_t *mem, *tmp, ascii;
-	int outta;
-	float vecyo[3], curofs;
-	CharInfo *info;
-	float wsfac;
-	float ulwidth, uloverlap;
-	TextBox *tb;
+	float *f, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4;
+	float twidth;
+	int i, slen, j;
 	int curbox;
 	int selstart, selend;
-	SelBox *sb= NULL;	/* to please gcc */
-	VChar *che;
-	float twidth;
 	int utf8len;
+	short cnr=0, lnr=0, wsnr= 0;
+	wchar_t *mem, *tmp, ascii;
 
 	/* renark: do calculations including the trailing '\0' of a string
 	   because the cursor can be at that location */
@@ -674,7 +674,7 @@
 	// Set font data
 	cu= (Curve *) ob->data;
 	vfont= cu->vfont;
-
+	
 	if(cu->str == NULL) return 0;
 	if(vfont == NULL) return 0;
 
@@ -687,19 +687,23 @@
 	// Count the wchar_t string length
 	slen = wcslen(mem);
 
-	if (cu->ulheight == 0.0) cu->ulheight = 0.05;
-	if (cu->strinfo==NULL) {	/* old file */
+	if (cu->ulheight == 0.0) 
+		cu->ulheight = 0.05;
+	
+	if (cu->strinfo==NULL)	/* old file */
 		cu->strinfo = MEM_callocN((slen+1) * sizeof(CharInfo), "strinfo compat");
-	}
-	if (cu->tb==NULL) {
+	
+	custrinfo= cu->strinfo;
+	if (cu->editfont)
+		custrinfo= cu->editfont->textbufinfo;
+	
+	if (cu->tb==NULL)
 		cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBox compat");
-	}
 
 	vfd= vfont_get_data(vfont);
 
 	/* The VFont Data can not be found */
-	if(!vfd)
-	{
+	if(!vfd) {
 		if(mem)
 			MEM_freeN(mem);	
 		return 0;
@@ -725,12 +729,12 @@
 
 	oldvfont = NULL;
 
-	for (i=0; i<slen; i++) cu->strinfo[i].flag &= ~CU_WRAP;
+	for (i=0; i<slen; i++) custrinfo[i].flag &= ~CU_WRAP;
 
-	if (selboxes) MEM_freeN(selboxes);
-	selboxes = NULL;
-	if (getselection(ob, &selstart, &selend))
-		selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
+	if (cu->selboxes) MEM_freeN(cu->selboxes);
+	cu->selboxes = NULL;
+	if (BKE_font_getselection(ob, &selstart, &selend))
+		cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes");
 
 	tb = &(cu->tb[0]);
 	curbox= 0;
@@ -739,14 +743,13 @@
 		// Characters in the list
 		che = vfd->characters.first;
 		ascii = mem[i];
-		info = &(cu->strinfo[i]);
+		info = &(custrinfo[i]);
 		vfont = which_vfont(cu, info);
 		
 		if(vfont==NULL) break;
 		
 		// Find the character
-		while(che)
-		{
+		while(che) {
 			if(che->index == ascii)
 				break;
 			che = che->next;
@@ -755,15 +758,13 @@
 #ifdef WITH_FREETYPE2
 		// The character wasn't in the current curve base so load it
 		// But if the font is <builtin> then do not try loading since whole font is in the memory already
-		if(che == NULL && strcmp(vfont->name, "<builtin>"))
-		{
+		if(che == NULL && strcmp(vfont->name, "<builtin>"))	{
 			BLI_vfontchar_from_freetypefont(vfont, ascii);
 		}
 
 		// Try getting the character again from the list

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list