Timecode printing is more or less duplicated in two different places,

so make them both use the same style and note down for future.
This commit is contained in:
Guillermo S. Romero
2009-06-09 20:03:52 +00:00
parent 677abc7f49
commit a796a74fb5
2 changed files with 18 additions and 10 deletions

View File

@@ -83,12 +83,16 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time)
glScalef(1.0f/xscale, 1.0f, 1.0f);
if (time) {
/* (Pseudo) SMPTE timecode style:
/* 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).
* (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
*/
float val= FRA2TIME(CFRA);
int hours=0, minutes=0, seconds=0, frames=0;
@@ -124,9 +128,9 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time)
}
/* print timecode to temp string buffer */
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);
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
sprintf(str, " %d", CFRA);

View File

@@ -1289,12 +1289,16 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
/* get string to print */
if (unit == V2D_UNIT_SECONDS) {
/* SMPTE timecode style:
/* 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 convention of ';' for frames, ala QuickTime).
* (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]= "";
@@ -1335,9 +1339,9 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
/* 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);
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 */