[Bf-blender-cvs] [9cc51d8] master: UI: cleanup odd string-width check

Campbell Barton noreply at git.blender.org
Tue Nov 11 18:42:53 CET 2014


Commit: 9cc51d8ea2b09f26b29874cdd946dce8d4651b86
Author: Campbell Barton
Date:   Tue Nov 11 18:39:43 2014 +0100
Branches: master
https://developer.blender.org/rB9cc51d8ea2b09f26b29874cdd946dce8d4651b86

UI: cleanup odd string-width check

===================================================================

M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/space_file/file_draw.c

===================================================================

diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 9cfe307..807e132 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -62,7 +62,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 {
 	float xscale, yscale, x, y;
 	char numstr[32] = "    t";  /* t is the character to start replacing from */
-	short slen;
+	int slen;
 	
 	/* because the frame number text is subject to the same scaling as the contents of the view */
 	UI_view2d_scale_get(v2d, &xscale, &yscale);
@@ -79,7 +79,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
 	else {
 		BLI_timecode_string_from_time_simple(&numstr[4], sizeof(numstr) - 4, 1, cfra);
 	}
-	slen = (short)UI_fontstyle_string_width(numstr) - 1;
+	slen = UI_fontstyle_string_width(numstr) - 1;
 	
 	/* get starting coordinates for drawing */
 	x = cfra * xscale;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 81476a8..6f63f31 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -128,12 +128,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
 	}
 	
 	/* Is there enough space for the execute / cancel buttons? */
-	loadbutton = UI_fontstyle_string_width(sfile->params->title) + btn_margin;
-	if (loadbutton < btn_minw) {
-		loadbutton = MAX2(btn_minw, 
-		                  btn_margin + UI_fontstyle_string_width(params->title));
-	}
-	
+	loadbutton = UI_fontstyle_string_width(params->title) + btn_margin;
+	CLAMP_MIN(loadbutton, btn_minw);
+
 	if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) {
 		loadbutton = 0;
 	}




More information about the Bf-blender-cvs mailing list