diff --git a/Scalebar.H b/Scalebar.H index 9dc0ff4..f97af4c 100644 --- a/Scalebar.H +++ b/Scalebar.H @@ -31,11 +31,16 @@ class Scalebar : public Fl_Scrollbar bool _zoom_changed; + double _zoom_min; + double _zoom_max; + public: Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H ) { _zoom = 1.0f; + _zoom_min = 0; + _zoom_max = 256; _zoom_changed = true; step( 1 ); @@ -44,6 +49,7 @@ public: bool zoom_changed ( void ) const { return _zoom_changed; } double zoom ( void ) const { return _zoom; } double value ( void ) const { return Fl_Slider::value(); } + void zoom_range ( double zmin, double zmax ) { _zoom_min = zmin; _zoom_max = zmax; } int handle ( int m ) @@ -54,6 +60,8 @@ public: { int d = Fl::event_dy(); + double z = _zoom; + if ( d < 0 ) while ( d++ ) _zoom /= 2; @@ -61,11 +69,20 @@ public: while ( d-- ) _zoom *= 2; - _zoom_changed = true; - do_callback(); - _zoom_changed = false; + if ( _zoom > _zoom_max ) + _zoom = _zoom_max; + else + if ( _zoom < _zoom_min ) + _zoom = _zoom_min; - slider_size( w() / maximum() ); + if ( z != _zoom ) + { + _zoom_changed = true; + do_callback(); + _zoom_changed = false; + + slider_size( w() / maximum() ); + } return 1; } diff --git a/Timeline.H b/Timeline.H index b4f8cdf..d72d023 100644 --- a/Timeline.H +++ b/Timeline.H @@ -24,6 +24,8 @@ #include #include +#include "Scalebar.H" + #include "Audio_File.H" // just for nframes_t #include @@ -60,7 +62,7 @@ struct Timeline : public Fl_Group Fl_Scroll *scroll; Fl_Pack *tracks; Fl_Pack *rulers; - Fl_Scrollbar *scrollbar; + Scalebar *scrollbar; Tempo_Track *tempo_track; Time_Track *time_track; diff --git a/main.C b/main.C index 94083e5..f7d0c35 100644 --- a/main.C +++ b/main.C @@ -58,8 +58,10 @@ cb_scroll ( Fl_Widget *w, void *v ) if ( sb->zoom_changed() ) { - timeline->fpp = sb->zoom() * 256; - timeline->fpp = max( min( timeline->fpp, 4096.0f ), (float)2 ); +// timeline->fpp = sb->zoom() * 256; + timeline->fpp = sb->zoom() * 1; + +/* timeline->fpp = max( min( timeline->fpp, 4096.0f ), (float)2 ); */ int maxx = timeline->ts_to_x( timeline->length ); sb->range( 0, maxx ); @@ -121,6 +123,7 @@ main ( int argc, char **argv ) timeline->scrollbar = new Scalebar( 0, 600 - 24, 800, 24 ); timeline->scrollbar->range( 0, 48000 * 2 ); + timeline->scrollbar->zoom_range( 2, 8192 ); timeline->scrollbar->type( 1 ); timeline->scrollbar->callback( cb_scroll, 0 );