Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2010-01-30 07:43:36 +0300
committerJoshua Leung <aligorith@gmail.com>2010-01-30 07:43:36 +0300
commite1fdf7fc58573de84fba5514bcdef1749bb61d16 (patch)
tree301a9bfee9018170f18327e86f6a1e460123c335 /source/blender/editors/interface/view2d.c
parentd86a9da07ca7901c1984c79b420cb87b363cbafa (diff)
View2D/TimeCode Drawing:
This commit introduces a few cleanups and tweaks to the way that timecodes (i.e. the timing indications used instead of frame numbers) get displayed. 1. Custom Spacing of TimeCodes/Gridlines Made the minimum number of pixels between gridlines/timecode indications a user-preference, instead of being a hardcoded constant. This allows to set the spacing tighter/looser than the defaults, and is also used for the other changes. 2. Default timecode display style, (now named 'minimal') uses '+' as the delimeter for the sub-second frames. This hopefully makes it a bit clearer what those values represent, as opposed to the '!', which can sometimes look too much like a colon. 3. Added various timecode display styles as user-preference. - These include always displaying full SMPTE, to showing milliseconds instead of frams for sub-second times, and also an option to just show the times as seconds only. - When changing the timecode style, the spacing setting is automatically modified so that the timecodes are spaced far apart enough so that they won't clash (under most circumstances). This automatic modification is only done if the spacing is too tight for the style being set. 4. Unified the code for generating timecode strings between the View2D scrollbar drawing and the current frame indicator drawing.
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c80
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;