diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-29 13:01:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-29 13:44:01 +0400 |
commit | 39eb314cb922b805e9126d5f0352f31c2f84f151 (patch) | |
tree | 9fc861802eeaab149539eb3692a975969cea03db /source/blender/editors/interface | |
parent | f70d9660474c2be5f56d65247df3be5af0479e08 (diff) |
UI: Refactor timecode functions into BLI_timecode
- deduplicate timecode_simple_string from image.c
- replace V2D_UNIT_SECONDSSEQ with V2D_UNIT_SECONDS
- avoid possible buffer overflow bugs (sprintf -> BLI_snprintf)
- remove option not to use timecode and split into 2 functions
Patch D227 by Andrew Buttery with own refactoring.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index aadb1b30f5b..ea350fd08df 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_timecode.h" #include "BKE_context.h" #include "BKE_screen.h" @@ -1613,7 +1614,13 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* get string to print */ - ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val); + if (unit == V2D_UNIT_SECONDS) { + /* not neces*/ + BLI_timecode_string_from_time(timecode_str, sizeof(timecode_str), power, val, FPS, U.timecode_style); + } + else { + BLI_timecode_string_from_time_simple(timecode_str, sizeof(timecode_str), power, val); + } /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ len = strlen(timecode_str); @@ -1737,17 +1744,6 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v scroll_printstr(scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h'); break; - case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */ - { - float time; - - fac2 = val / (float)FPS; - time = (float)floor(fac2); - fac2 = fac2 - time; - - scroll_printstr(scene, fac, h, time + (float)FPS * fac2 / 100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h'); - break; - } case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */ /* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v'); |