From 4b51c8f82aaed75228441692d55036f6737643af Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 2 May 2008 21:17:34 -0500 Subject: [PATCH] Make zoom follow mouse. --- Timeline/Timeline.C | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 8fb4906..6eec54a 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -89,10 +89,15 @@ Timeline::cb_scroll ( Fl_Widget *w ) { if ( hscroll->zoom_changed() ) { + + nframes_t under_mouse = x_to_offset( Fl::event_x() ); + _fpp = hscroll->zoom(); - const int tw = tracks->w() - Track::width() - vscroll->w(); - hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( _length ) ); + const int tw = tracks->w() - Track::width(); +// hscroll->value( ts_to_x( xoffset ), tw, 0, ts_to_x( _length ) ); + hscroll->value( max( 0, ts_to_x( under_mouse ) - ( Fl::event_x() - tracks->x() - Track::width() ) ), + tw, 0, ts_to_x( _length ) ); redraw(); }