From 0da462b62d9a09900e946ea39fda7f18a1a6b8f9 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 2 May 2008 17:34:43 -0500 Subject: [PATCH] Make zoom to time work again. --- Timeline/Scalebar.H | 2 +- Timeline/Timeline.C | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Timeline/Scalebar.H b/Timeline/Scalebar.H index cb94cda..39bbb75 100644 --- a/Timeline/Scalebar.H +++ b/Timeline/Scalebar.H @@ -70,7 +70,7 @@ public: bool zoom_changed ( void ) const { return _zoom_changed; } double zoom ( void ) const { return _zoom; } - void zoom ( int v ) { _zoom = v; } + void zoom ( int v ) { int z = _zoom ; _zoom = v; constrain(); maybe_do_callback( z ); } // double value ( void ) const { return Fl_Slider::value(); } void zoom_range ( int zmin, int zmax ) { _zoom_min = zmin; _zoom_max = zmax; } diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 419f7ab..5315d73 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -1061,10 +1061,14 @@ Timeline::zoom_out ( void ) void Timeline::zoom ( float secs ) { - const int sw = w() - vscroll->w() - Track::width(); + const int sw = tracks->w() - Track::width(); - /* FIXME: we actually need to set this in the scalebar */ -// _fpp = (int)((secs * sample_rate()) / sw); + int fpp = (int)((secs * sample_rate()) / sw); + + int p = 0; + while ( 1 << p < fpp ) p++; + + hscroll->zoom( p ); redraw(); }