@@ -27,12 +27,12 @@ | |||
class Scalebar : public Fl_Scrollbar | |||
{ | |||
double _zoom; | |||
int _zoom; | |||
bool _zoom_changed; | |||
double _zoom_min; | |||
double _zoom_max; | |||
int _zoom_min; | |||
int _zoom_max; | |||
void constrain ( void ) | |||
{ | |||
@@ -60,9 +60,9 @@ public: | |||
Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H ) | |||
{ | |||
_zoom = 1.0f; | |||
_zoom = 1; | |||
_zoom_min = 0; | |||
_zoom_max = 256; | |||
_zoom_max = 4; | |||
_zoom_changed = false; | |||
step( 1 ); | |||
@@ -70,12 +70,12 @@ public: | |||
bool zoom_changed ( void ) const { return _zoom_changed; } | |||
double zoom ( void ) const { return _zoom; } | |||
void zoom ( double v ) { _zoom = v; } | |||
void zoom ( int v ) { _zoom = v; } | |||
// double value ( void ) const { return Fl_Slider::value(); } | |||
void zoom_range ( double zmin, double zmax ) { _zoom_min = zmin; _zoom_max = zmax; } | |||
void zoom_range ( int zmin, int zmax ) { _zoom_min = zmin; _zoom_max = zmax; } | |||
void zoom_out ( void ) { int z = _zoom; _zoom *= 2; constrain(); maybe_do_callback( z ); } | |||
void zoom_in ( void ) {int z = _zoom; _zoom /= 2; constrain(); maybe_do_callback( z ); } | |||
void zoom_out ( void ) { int z = _zoom; ++_zoom; constrain(); maybe_do_callback( z ); } | |||
void zoom_in ( void ) {int z = _zoom; --_zoom; constrain(); maybe_do_callback( z ); } | |||
int | |||
handle ( int m ) | |||
@@ -91,12 +91,7 @@ public: | |||
double z = _zoom; | |||
if ( d < 0 ) | |||
while ( d++ ) | |||
_zoom /= 2; | |||
else | |||
while ( d-- ) | |||
_zoom *= 2; | |||
_zoom += d; | |||
constrain(); | |||
@@ -65,7 +65,7 @@ Timeline::cb_scroll ( Fl_Widget *w ) | |||
{ | |||
if ( hscroll->zoom_changed() ) | |||
{ | |||
_fpp = hscroll->zoom() * 1; | |||
_fpp = hscroll->zoom(); | |||
// hscroll->range( 0, ts_to_x( _length ) - tracks->w() - Track::width() ); | |||
const int tw = tracks->w() - Track::width() - vscroll->w(); | |||
@@ -94,8 +94,11 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi | |||
o->range( 0, 48000 * 300 ); | |||
// o->zoom_range( 1, 16384 ); | |||
o->zoom_range( 1, 65536 << 4 ); | |||
o->zoom( 256 ); | |||
// o->zoom_range( 1, 65536 << 4 ); | |||
o->zoom_range( 1, 20 ); | |||
o->zoom( 8 ); | |||
o->type( FL_HORIZONTAL ); | |||
o->callback( cb_scroll, this ); | |||
@@ -155,7 +158,7 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi | |||
{ | |||
// sample_rate() = engine->sample_rate(); | |||
_fpp = 256; | |||
_fpp = 8; | |||
// _length = sample_rate() * 60 * 2; | |||
/* FIXME: hack */ | |||
_length = -1; | |||
@@ -914,7 +917,7 @@ Timeline::zoom ( float secs ) | |||
const int sw = w() - vscroll->w() - Track::width(); | |||
/* FIXME: we actually need to set this in the scalebar */ | |||
_fpp = (int)((secs * sample_rate()) / sw); | |||
// _fpp = (int)((secs * sample_rate()) / sw); | |||
redraw(); | |||
} | |||
@@ -98,7 +98,7 @@ class Timeline : public Fl_Overlay_Window, public RWLock | |||
static void cb_scroll ( Fl_Widget *w, void *v ); | |||
void cb_scroll ( Fl_Widget *w ); | |||
float _fpp; /* frames per pixel */ | |||
int _fpp; /* frames per pixel, power of two */ | |||
nframes_t _length; | |||
@@ -127,11 +127,11 @@ public: | |||
Timeline ( int X, int Y, int W, int H, const char *L=0 ); | |||
float fpp ( void ) const { return _fpp; } | |||
nframes_t fpp ( void ) const { return 1 << _fpp; } | |||
nframes_t length ( void ) const { return _length; } | |||
nframes_t sample_rate ( void ) const { return engine->sample_rate(); } | |||
int ts_to_x( nframes_t ts ) const { return ts / _fpp; } | |||
nframes_t x_to_ts ( int x ) const { return x * _fpp; } | |||
int ts_to_x( nframes_t ts ) const { return ts >> _fpp; } | |||
nframes_t x_to_ts ( int x ) const { return x << _fpp; } | |||
float beats_per_minute ( nframes_t when ) const; | |||
int beats_per_bar ( nframes_t when ) const; | |||