From 125ce644f28dccea67ad5bdada0013eba8caafbe Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Tue, 4 Apr 2017 15:39:38 -0400 Subject: cleanup I started cleaning up UI_view2d_scale_get where the y scale was unused, then got carried away... - for loop scope - declare variables closer to where they are used - move early exits closer to function start - unsigned --> unsigned int --- source/blender/editors/animation/anim_draw.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/animation/anim_draw.c') diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 5d357e2f93e..f448a281cfc 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -71,17 +71,12 @@ /* Draw current frame number in a little green box beside the current frame indicator */ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const bool time) { - const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; - VertexFormat *format = immVertexFormat(); - unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); - unsigned char col[4]; - float xscale, yscale, x, y; char numstr[32] = " t"; /* t is the character to start replacing from */ - int slen; /* because the frame number text is subject to the same scaling as the contents of the view */ + float xscale; + UI_view2d_scale_get(v2d, &xscale, NULL); gpuPushMatrix(); - UI_view2d_scale_get(v2d, &xscale, &yscale); gpuScale2f(1.0f / xscale, 1.0f); /* get timecode string @@ -96,11 +91,15 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const BLI_timecode_string_from_time_seconds(&numstr[4], sizeof(numstr) - 4, 1, cfra); } - slen = UI_fontstyle_string_width(fstyle, numstr) - 1; + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + int slen = UI_fontstyle_string_width(fstyle, numstr) - 1; /* get starting coordinates for drawing */ - x = cfra * xscale; - y = 0.9f * U.widget_unit; + float x = cfra * xscale; + float y = 0.9f * U.widget_unit; + + VertexFormat *format = immVertexFormat(); + unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -110,7 +109,8 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const immRectf(pos, x, y, x + slen, y + 0.75f * U.widget_unit); immUnbindProgram(); - /* draw current frame number - black text */ + /* draw current frame number */ + unsigned char col[4]; UI_GetThemeColor4ubv(TH_TEXT, col); UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr, col); -- cgit v1.2.3