diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-12-02 13:33:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-12-02 14:10:07 +0400 |
commit | 1815225faa75eb64e83fdc9f066fcd6339502d52 (patch) | |
tree | 6558780d85792c9c41fcf280069870fae70eed7a /source/blender/editors/space_image/image_draw.c | |
parent | f64ae4cbe5a724496624de9e479c04f325613be5 (diff) |
Blender Font (BLF): add length argument to string width/height functions
This also fixes a crash editing buttons longer then UI_MAX_DRAW_STR
Diffstat (limited to 'source/blender/editors/space_image/image_draw.c')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 89e57955339..3d5f6a6ce7e 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -195,21 +195,21 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_Y, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); if (zp) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff)); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } if (zpf) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } if (channels >= 3) { @@ -222,7 +222,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " R:-"); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); glColor3ubv(green); if (fp) @@ -233,7 +233,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " G:-"); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); glColor3ubv(blue); if (fp) @@ -244,7 +244,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " B:-"); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); if (channels == 4) { glColor3ub(255, 255, 255); @@ -256,7 +256,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), "- "); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } if (color_manage) { @@ -276,7 +276,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } } @@ -350,12 +350,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), "V:%-.4f", val); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } else if (channels >= 3) { rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val); @@ -364,22 +364,22 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def BLI_snprintf(str, sizeof(str), "H:%-.4f", hue); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); BLI_snprintf(str, sizeof(str), " S:%-.4f", sat); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); BLI_snprintf(str, sizeof(str), " V:%-.4f", val); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str); + dx += BLF_width(blf_mono_font, str, sizeof(str)); } (void)dx; |