diff options
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 80 |
1 files changed, 6 insertions, 74 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index b14dc5a03b6..7aabc147139 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -51,6 +51,7 @@ #include "BLF_api.h" +#include "ED_anim_api.h" #include "ED_screen.h" #include "UI_interface.h" @@ -1038,9 +1039,6 @@ void UI_view2d_view_restore(const bContext *C) /* *********************************************************************** */ /* Gridlines */ -/* minimum pixels per gridstep */ -#define MINGRIDSTEP 35 - /* View2DGrid is typedef'd in UI_view2d.h */ struct View2DGrid { float dx, dy; /* stepsize (in pixels) between gridlines */ @@ -1131,7 +1129,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh space= v2d->cur.xmax - v2d->cur.xmin; pixels= (float)(v2d->mask.xmax - v2d->mask.xmin); - grid->dx= (MINGRIDSTEP * space) / (seconddiv * pixels); + grid->dx= (U.v2d_min_gridsize * space) / (seconddiv * pixels); step_to_grid(&grid->dx, &grid->powerx, xunits); grid->dx *= seconddiv; @@ -1147,7 +1145,7 @@ View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short xunits, sh space= v2d->cur.ymax - v2d->cur.ymin; pixels= (float)winy; - grid->dy= MINGRIDSTEP * space / pixels; + grid->dy= U.v2d_min_gridsize * space / pixels; step_to_grid(&grid->dy, &grid->powery, yunits); if (yclamp == V2D_GRID_CLAMP) { @@ -1192,7 +1190,7 @@ void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int f vec2[1]= v2d->cur.ymax; /* minor gridlines */ - step= (v2d->mask.xmax - v2d->mask.xmin + 1) / MINGRIDSTEP; + step= (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a=0; a<step; a++) { @@ -1226,7 +1224,7 @@ void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int f vec1[0]= grid->startx; vec2[0]= v2d->cur.xmax; - step= (v2d->mask.ymax - v2d->mask.ymin + 1) / MINGRIDSTEP; + step= (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize; UI_ThemeColor(TH_GRID); for (a=0; a<=step; a++) { @@ -1491,72 +1489,7 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f } /* get string to print */ - if (unit == V2D_UNIT_SECONDS) { - /* Timecode: - * - In general, minutes and seconds should be shown, as most clips will be - * within this length. Hours will only be included if relevant. - * - Only show frames when zoomed in enough for them to be relevant - * (using separator of '!' for frames). - * When showing frames, use slightly different display to avoid confusion with mm:ss format - * TODO: factor into reusable function. - * Meanwhile keep in sync: - * source/blender/editors/animation/anim_draw.c - * source/blender/editors/interface/view2d.c - */ - int hours=0, minutes=0, seconds=0, frames=0; - char neg[2]= ""; - - /* get values */ - if (val < 0) { - /* correction for negative values */ - sprintf(neg, "-"); - val = -val; - } - if (val >= 3600) { - /* hours */ - /* XXX should we only display a single digit for hours since clips are - * VERY UNLIKELY to be more than 1-2 hours max? However, that would - * go against conventions... - */ - hours= (int)val / 3600; - val= (float)fmod(val, 3600); - } - if (val >= 60) { - /* minutes */ - minutes= (int)val / 60; - val= (float)fmod(val, 60); - } - if (power <= 0) { - /* seconds + frames - * Frames are derived from 'fraction' of second. We need to perform some additional rounding - * to cope with 'half' frames, etc., which should be fine in most cases - */ - seconds= (int)val; - frames= (int)floor( ((val - seconds) * FPS) + 0.5f ); - } - else { - /* seconds (with pixel offset) */ - seconds= (int)floor(val + 0.375f); - } - - /* print timecode to temp string buffer */ - if (power <= 0) { - /* include "frames" in display */ - if (hours) sprintf(str, "%s%02d:%02d:%02d!%02d", neg, hours, minutes, seconds, frames); - else if (minutes) sprintf(str, "%s%02d:%02d!%02d", neg, minutes, seconds, frames); - else sprintf(str, "%s%d!%02d", neg, seconds, frames); - } - else { - /* don't include 'frames' in display */ - if (hours) sprintf(str, "%s%02d:%02d:%02d", neg, hours, minutes, seconds); - else sprintf(str, "%s%02d:%02d", neg, minutes, seconds); - } - } - else { - /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ - if (power <= 0) sprintf(str, "%.*f", 1-power, val); - else sprintf(str, "%d", (int)floor(val + 0.375f)); - } + ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val); /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ len= strlen(str); @@ -1753,7 +1686,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v val= grid->starty; /* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */ - // XXX only relevant to Sequencer, so need to review this when we port that code if (vs->yclamp == V2D_GRID_CLAMP) fac += 0.5f * dfac; |