From 09eec627ed730532905b45d409f9009023623437 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jan 2015 14:25:39 +1100 Subject: UI: cleanup UI_fontstyle_string_width, UI_draw_string Both were maked as temp, but used often. Now pass uiFontStyle to both, rename UI_draw_string to UI_fontstyle_draw_simple, since its a variant of UI_fontstyle_draw that skips shadow, align... etc. --- source/blender/editors/animation/anim_channels_defines.c | 3 ++- source/blender/editors/animation/anim_draw.c | 6 ++++-- source/blender/editors/animation/anim_markers.c | 7 ++++--- source/blender/editors/animation/fmodifier_ui.c | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'source/blender/editors/animation') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index d76eba93640..7b29414c763 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3519,6 +3519,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* step 5) draw name ............................................... */ /* TODO: when renaming, we might not want to draw this, especially if name happens to be longer than channel */ if (acf->name) { + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ /* set text color */ @@ -3532,7 +3533,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float acf->name(ale, name); offset += 3; - UI_draw_string(offset, ytext, name); + UI_fontstyle_draw_simple(fstyle, offset, ytext, name); /* draw red underline if channel is disabled */ if ((ale->type == ANIMTYPE_FCURVE) && (ale->flag & FCURVE_DISABLED)) { diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 2d7656642d3..0e052279796 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -59,6 +59,7 @@ /* 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; float xscale, yscale, x, y; char numstr[32] = " t"; /* t is the character to start replacing from */ int slen; @@ -78,7 +79,8 @@ 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 = UI_fontstyle_string_width(numstr) - 1; + + slen = UI_fontstyle_string_width(fstyle, numstr) - 1; /* get starting coordinates for drawing */ x = cfra * xscale; @@ -90,7 +92,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - UI_draw_string(x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr); + UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr); /* restore view transform */ glScalef(xscale, 1.0, 1.0); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index b6c7a4aa5a0..d778b06cf5f 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -317,7 +317,7 @@ void debug_markers_print_list(ListBase *markers) /* function to draw markers */ static void draw_marker( - View2D *v2d, TimeMarker *marker, int cfra, int flag, + View2D *v2d, const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int flag, /* avoid re-calculating each time */ const float ypixels, const float xscale, const float yscale) { @@ -399,13 +399,14 @@ static void draw_marker( } #endif - UI_draw_string(x, y, marker->name); + UI_fontstyle_draw_simple(fstyle, x, y, marker->name); } } /* Draw Scene-Markers in time window */ void ED_markers_draw(const bContext *C, int flag) { + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; ListBase *markers = ED_context_get_markers(C); View2D *v2d; TimeMarker *marker; @@ -455,7 +456,7 @@ void ED_markers_draw(const bContext *C, int flag) if ((marker->frame >= v2d_clip_range_x[0]) && (marker->frame <= v2d_clip_range_x[1])) { - draw_marker(v2d, marker, scene->r.cfra, flag, + draw_marker(v2d, fstyle, marker, scene->r.cfra, flag, ypixels, xscale, yscale); } } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 8ede1a0ad76..bcdad1c93ad 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -130,6 +130,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s switch (data->mode) { case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */ { + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; float *cp = NULL; char xval[32]; unsigned int i; @@ -147,11 +148,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* calculate maximum width of label for "x^n" labels */ if (data->arraysize > 2) { BLI_snprintf(xval, sizeof(xval), "x^%u", data->arraysize); - maxXWidth = UI_fontstyle_string_width(xval) + 0.5 * UI_UNIT_X; /* XXX: UI_fontstyle_string_width is not accurate */ + /* XXX: UI_fontstyle_string_width is not accurate */ + maxXWidth = UI_fontstyle_string_width(fstyle, xval) + 0.5 * UI_UNIT_X; } else { /* basic size (just "x") */ - maxXWidth = UI_fontstyle_string_width("x") + 0.5 * UI_UNIT_X; + maxXWidth = UI_fontstyle_string_width(fstyle, "x") + 0.5 * UI_UNIT_X; } /* draw controls for each coefficient and a + sign at end of row */ -- cgit v1.2.3