[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11722] trunk/blender/source/blender/src: patch #6795 by James C (sheep):

Matt Ebb matt at mke3.net
Mon Aug 20 01:47:14 CEST 2007


Revision: 11722
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11722
Author:   broken
Date:     2007-08-20 01:47:14 +0200 (Mon, 20 Aug 2007)

Log Message:
-----------
patch #6795 by James C (sheep):
This converts the Ipo editor and Timeline windows to use the BIF_ 
API for drawing international/antialiased text, following the user 
preference or being drawn in Bitmap/Pixmap/Texture mode.

Thanks James!

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawipo.c
    trunk/blender/source/blender/src/drawtime.c

Modified: trunk/blender/source/blender/src/drawipo.c
===================================================================
--- trunk/blender/source/blender/src/drawipo.c	2007-08-19 23:46:50 UTC (rev 11721)
+++ trunk/blender/source/blender/src/drawipo.c	2007-08-19 23:47:14 UTC (rev 11722)
@@ -42,9 +42,8 @@
 #include <unistd.h>
 #else
 #include <io.h>
-#endif   
+#endif
 
-#include "BMF_Api.h"
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
@@ -80,6 +79,7 @@
 #include "BIF_glutil.h"
 #include "BIF_editseq.h"
 #include "BIF_editaction.h"
+#include "BIF_language.h"
 
 #include "BSE_drawipo.h"
 #include "BSE_view.h"
@@ -93,6 +93,7 @@
 #include "mydevice.h"
 #include "blendef.h"
 #include "butspace.h"	// shouldnt be...
+#include "interface.h"	/* for ui_rasterpos_safe */
 #include "winlay.h"
 
 /* local define... also used in editipo ... */
@@ -133,8 +134,8 @@
 		str[len+1]= 0;
 	}
 	
-	glRasterPos2f(x,  y);
-	BMF_DrawString(G.fonts, str);
+	ui_rasterpos_safe(x, y, 1.0);
+	BIF_DrawString(G.fonts, str, 0);
 }
 
 static void step_to_grid(float *step, int *macht)
@@ -709,6 +710,7 @@
 	EditIpo *ei;
 	int ipowidth = IPOBUTX;
 	int a;
+	float textwidth = 0;
 	
 	/* default width when no space ipo or no channels */
 	if (sipo == NULL) return IPOBUTX;
@@ -717,8 +719,9 @@
 	ei= sipo->editipo;
 	
 	for(a=0; a<sipo->totipo; a++, ei++) {
-		if (BMF_GetStringWidth(G.font, ei->name) + 18 > ipowidth) 
-			ipowidth = BMF_GetStringWidth(G.font, ei->name) + 18;
+		textwidth = BIF_GetStringWidth(G.font, ei->name, 0);
+		if (textwidth + 18 > ipowidth) 
+			ipowidth = textwidth + 18;
 	}
 	return ipowidth;
 

Modified: trunk/blender/source/blender/src/drawtime.c
===================================================================
--- trunk/blender/source/blender/src/drawtime.c	2007-08-19 23:46:50 UTC (rev 11721)
+++ trunk/blender/source/blender/src/drawtime.c	2007-08-19 23:47:14 UTC (rev 11722)
@@ -55,16 +55,18 @@
 #include "BKE_global.h"
 
 #include "BIF_gl.h"
+#include "BIF_interface.h"
 #include "BIF_interface_icons.h"
 #include "BIF_mywindow.h"
 #include "BIF_screen.h"
 #include "BIF_resources.h"
+#include "BIF_language.h"
 
 #include "BSE_drawipo.h"
 #include "BSE_view.h"
-#include "BMF_Api.h"
 
 #include "blendef.h"
+#include "interface.h"	/* for ui_rasterpos_safe */
 
 /* ---- prototypes ------ */
 void drawtimespace(ScrArea *, void *);
@@ -92,6 +94,7 @@
 	if(stime->flag & TIME_CFRA_NUM) {
 		short mval[2];
 		float x,  y;
+		float xscale, yscale;
 		char str[32];
 		/* little box with frame */
 		
@@ -107,61 +110,68 @@
 		areamouseco_to_ipoco(G.v2d, mval, &x, &y);
 		
 		if(stime->flag & TIME_DRAWFRAMES) 
-			sprintf(str, "   %d\n", (G.scene->r.cfra));
-		else sprintf(str, "   %.2f\n", (G.scene->r.cfra/(float)G.scene->r.frs_sec));
+			sprintf(str, "   %d", (G.scene->r.cfra));
+		else sprintf(str, "   %.2f", (G.scene->r.cfra/(float)G.scene->r.frs_sec));
 		
 		/* HACK! somehow the green color won't go away... */
 		glColor4ub(0, 0, 0, 0);
 		BIF_ThemeColor(TH_TEXT);
 		
-		glRasterPos2f(x, y);
-		BMF_DrawString(G.fonts, str);
+		xscale = (G.v2d->mask.xmax-G.v2d->mask.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
+		yscale = (G.v2d->mask.ymax-G.v2d->mask.ymin)/(G.v2d->cur.ymax-G.v2d->cur.ymin);
 		
+		/* because the frame number text is subject to the same scaling as the contents of the view */
+		glScalef( 1.0/xscale, 1.0/yscale, 1.0);
+		
+		ui_rasterpos_safe(x * xscale, y * yscale, 1.0);
+		BIF_DrawString(G.fonts, str, 0);
+		
+		glScalef(xscale, yscale, 1.0);
 	}
 	
 }
 
 static void draw_marker(TimeMarker *marker)
 {
-	float xpos, xspace, yspace, xpixels, ypixels;
+	float xpos, ypixels, xscale, yscale;
 
 	xpos = marker->frame;
 	/* no time correction for framelen! space is drawn with old values */
 	
-	xspace= G.v2d->cur.xmax - G.v2d->cur.xmin;
-	yspace= G.v2d->cur.ymax - G.v2d->cur.ymin;
-	xpixels= G.v2d->mask.xmax-G.v2d->mask.xmin;
 	ypixels= G.v2d->mask.ymax-G.v2d->mask.ymin;
+	xscale = (G.v2d->mask.xmax-G.v2d->mask.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin);
+	yscale = (G.v2d->mask.ymax-G.v2d->mask.ymin)/(G.v2d->cur.ymax-G.v2d->cur.ymin);
 
+	glScalef( 1.0/xscale, 1.0/yscale, 1.0);
+
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);			
 	
 	/* 5 px to offset icon to align properly, space / pixels corrects for zoom */
 	if(marker->flag & SELECT)
-		BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER_HLT);
+		BIF_icon_draw(xpos*xscale-5.0, 12.0, ICON_MARKER_HLT);
 	else
-		BIF_icon_draw(xpos-(5.0*(xspace/xpixels)), 12.0*yspace/ypixels, ICON_MARKER);
+		BIF_icon_draw(xpos*xscale-5.0, 12.0, ICON_MARKER);
 	
 	glBlendFunc(GL_ONE, GL_ZERO);
-	glDisable(GL_BLEND);		
-
+	glDisable(GL_BLEND);
+			
 	/* and the marker name too, shifted slightly to the top-right */
 	if(marker->name && marker->name[0]) {
 		if(marker->flag & SELECT) {
 			BIF_ThemeColor(TH_TEXT_HI);
-			glRasterPos2f(xpos+(4.0*(xspace/xpixels)),
-					((ypixels<=39.0)?(ypixels-10.0):29.0)*yspace/ypixels);
+			ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
 		}
 		else {
 			BIF_ThemeColor(TH_TEXT);
 			if((marker->frame <= G.scene->r.cfra) && (marker->frame+5 > G.scene->r.cfra))
-				glRasterPos2f(xpos+(4.0*(xspace/xpixels)),
-						((ypixels<=39.0)?(ypixels-10.0):29.0)*yspace/ypixels);
+				ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
 			else
-				glRasterPos2f(xpos+(4.0*(xspace/xpixels)), 17.0*yspace/ypixels);
+				ui_rasterpos_safe(xpos*xscale+4.0, 17.0, 1.0);
 		}
-		BMF_DrawString(G.font, marker->name);
+		BIF_DrawString(G.font, marker->name, 0);
 	}
+	glScalef(xscale, yscale, 1.0);
 }
 
 static void draw_markers_time(void)





More information about the Bf-blender-cvs mailing list