[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43278] trunk/blender/source: minor changes to BLF api use

Campbell Barton ideasman42 at gmail.com
Wed Jan 11 06:45:49 CET 2012


Revision: 43278
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43278
Author:   campbellbarton
Date:     2012-01-11 05:45:39 +0000 (Wed, 11 Jan 2012)
Log Message:
-----------
minor changes to BLF api use
- replace calls to BLF_width & BLF_height --> BLF_width_and_height
- no need to call strlen() on length value passed to BLF_draw(). this already checks for \0 char.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_widgets.c
    trunk/blender/source/blender/editors/screen/area.c
    trunk/blender/source/blender/editors/space_clip/clip_draw.c
    trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
    trunk/blender/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-01-11 03:40:20 UTC (rev 43277)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2012-01-11 05:45:39 UTC (rev 43278)
@@ -3264,7 +3264,7 @@
 void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
 {
 	rcti trect = *rect;
-	
+	float font_dims[2] = {0.0f, 0.0f};
 	uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM);
 	
 	wt->state(wt, state);
@@ -3276,10 +3276,12 @@
 		glColor3ubv((unsigned char*)wt->wcol.text);
 	else
 		glColor3ubv((unsigned char*)wt->wcol.text_sel);
-	
+
+	BLF_width_and_height(fstyle->uifont_id, name, &font_dims[0], &font_dims[1]);
+
 	trect.xmin += 0;
-	trect.xmax = trect.xmin + BLF_width(fstyle->uifont_id, name) + 10;
+	trect.xmax = trect.xmin + font_dims[0] + 10;
 	trect.ymin += 10;
-	trect.ymax = trect.ymin + BLF_height(fstyle->uifont_id, name);
+	trect.ymax = trect.ymin + font_dims[1];
 	uiStyleFontDraw(fstyle, &trect, name);
 }

Modified: trunk/blender/source/blender/editors/screen/area.c
===================================================================
--- trunk/blender/source/blender/editors/screen/area.c	2012-01-11 03:40:20 UTC (rev 43277)
+++ trunk/blender/source/blender/editors/screen/area.c	2012-01-11 05:45:39 UTC (rev 43278)
@@ -1809,5 +1809,5 @@
 	/* text */
 	UI_ThemeColor(TH_TEXT_HI);
 	BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
-	BLF_draw(fontid, text, strlen(text));
+	BLF_draw(fontid, text, 256);
 }

Modified: trunk/blender/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-01-11 03:40:20 UTC (rev 43277)
+++ trunk/blender/source/blender/editors/space_clip/clip_draw.c	2012-01-11 05:45:39 UTC (rev 43278)
@@ -76,19 +76,19 @@
 	uiStyle *style= UI_GetStyle();
 	int fontid= style->widget.uifont_id;
 	char str[32];
-	float fontsize, fontwidth;
+	float font_dims[2] = {0.0f, 0.0f};
 
 	/* frame number */
 	BLF_size(fontid, 11.0f, U.dpi);
 	BLI_snprintf(str, sizeof(str), "%d", sc->user.framenr);
-	fontsize= BLF_height(fontid, str);
-	fontwidth= BLF_width(fontid, str);
 
-	glRecti(x, y, x+fontwidth+6, y+fontsize+4);
+	BLF_width_and_height(fontid, str, &font_dims[0], &font_dims[1]);
 
+	glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
+
 	UI_ThemeColor(TH_TEXT);
 	BLF_position(fontid, x+2.0f, y+2.0f, 0.0f);
-	BLF_draw(fontid, str, strlen(str));
+	BLF_draw(fontid, str, sizeof(str));
 }
 
 static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Scene *scene)
@@ -805,13 +805,13 @@
 		BLI_snprintf(str, sizeof(str), "%s", track->name);
 
 	BLF_position(fontid, pos[0], pos[1], 0.0f);
-	BLF_draw(fontid, str, strlen(str));
+	BLF_draw(fontid, str, sizeof(str));
 	pos[1]-= fontsize;
 
 	if(track->flag&TRACK_HAS_BUNDLE) {
 		BLI_snprintf(str, sizeof(str), "Average error: %.3f", track->error);
 		BLF_position(fontid, pos[0], pos[1], 0.0f);
-		BLF_draw(fontid, str, strlen(str));
+		BLF_draw(fontid, str, sizeof(str));
 		pos[1]-= fontsize;
 	}
 

Modified: trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp	2012-01-11 03:40:20 UTC (rev 43277)
+++ trunk/blender/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp	2012-01-11 05:45:39 UTC (rev 43278)
@@ -147,7 +147,7 @@
 
 	BLF_size(fontid, size, dpi);
 	BLF_position(fontid, 0, 0, 0);
-	BLF_draw(fontid, (char *)text, strlen(text));
+	BLF_draw(fontid, (char *)text, 65535);
 
 	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
 }

Modified: trunk/blender/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp	2012-01-11 03:40:20 UTC (rev 43277)
+++ trunk/blender/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp	2012-01-11 05:45:39 UTC (rev 43278)
@@ -305,7 +305,7 @@
 
 	BLF_size(fontid, size, dpi);
 	BLF_position(fontid, 0, 0, 0);
-	BLF_draw(fontid, (char *)text, strlen(text));
+	BLF_draw(fontid, text, 65535);
 
 	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
 	glEnable(GL_DEPTH_TEST);
@@ -350,11 +350,11 @@
 	if (mode == RAS_IRenderTools::RAS_TEXT_PADDED)
 	{
 		glColor3ub(0, 0, 0);
-		BLF_draw_default(xco+1, height-yco-1, 0.f, text, strlen(text));
+		BLF_draw_default(xco+1, height-yco-1, 0.f, text, 65536);
 	}
 
 	glColor3ub(255, 255, 255);
-	BLF_draw_default(xco, height-yco, 0.f, text, strlen(text));
+	BLF_draw_default(xco, height-yco, 0.f, text, 65536);
 
 	// Restore view settings
 	glMatrixMode(GL_PROJECTION);



More information about the Bf-blender-cvs mailing list