Clean up scalebar zoom extremes.
This commit is contained in:
parent
e1da3ffd00
commit
128ce9d577
25
Scalebar.H
25
Scalebar.H
|
@ -31,11 +31,16 @@ class Scalebar : public Fl_Scrollbar
|
||||||
|
|
||||||
bool _zoom_changed;
|
bool _zoom_changed;
|
||||||
|
|
||||||
|
double _zoom_min;
|
||||||
|
double _zoom_max;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H )
|
Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H )
|
||||||
{
|
{
|
||||||
_zoom = 1.0f;
|
_zoom = 1.0f;
|
||||||
|
_zoom_min = 0;
|
||||||
|
_zoom_max = 256;
|
||||||
_zoom_changed = true;
|
_zoom_changed = true;
|
||||||
|
|
||||||
step( 1 );
|
step( 1 );
|
||||||
|
@ -44,6 +49,7 @@ public:
|
||||||
bool zoom_changed ( void ) const { return _zoom_changed; }
|
bool zoom_changed ( void ) const { return _zoom_changed; }
|
||||||
double zoom ( void ) const { return _zoom; }
|
double zoom ( void ) const { return _zoom; }
|
||||||
double value ( void ) const { return Fl_Slider::value(); }
|
double value ( void ) const { return Fl_Slider::value(); }
|
||||||
|
void zoom_range ( double zmin, double zmax ) { _zoom_min = zmin; _zoom_max = zmax; }
|
||||||
|
|
||||||
int
|
int
|
||||||
handle ( int m )
|
handle ( int m )
|
||||||
|
@ -54,6 +60,8 @@ public:
|
||||||
{
|
{
|
||||||
int d = Fl::event_dy();
|
int d = Fl::event_dy();
|
||||||
|
|
||||||
|
double z = _zoom;
|
||||||
|
|
||||||
if ( d < 0 )
|
if ( d < 0 )
|
||||||
while ( d++ )
|
while ( d++ )
|
||||||
_zoom /= 2;
|
_zoom /= 2;
|
||||||
|
@ -61,11 +69,20 @@ public:
|
||||||
while ( d-- )
|
while ( d-- )
|
||||||
_zoom *= 2;
|
_zoom *= 2;
|
||||||
|
|
||||||
_zoom_changed = true;
|
if ( _zoom > _zoom_max )
|
||||||
do_callback();
|
_zoom = _zoom_max;
|
||||||
_zoom_changed = false;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <FL/Fl_Scrollbar.H>
|
#include <FL/Fl_Scrollbar.H>
|
||||||
#include <FL/Fl_Widget.H>
|
#include <FL/Fl_Widget.H>
|
||||||
|
|
||||||
|
#include "Scalebar.H"
|
||||||
|
|
||||||
#include "Audio_File.H" // just for nframes_t
|
#include "Audio_File.H" // just for nframes_t
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ struct Timeline : public Fl_Group
|
||||||
Fl_Scroll *scroll;
|
Fl_Scroll *scroll;
|
||||||
Fl_Pack *tracks;
|
Fl_Pack *tracks;
|
||||||
Fl_Pack *rulers;
|
Fl_Pack *rulers;
|
||||||
Fl_Scrollbar *scrollbar;
|
Scalebar *scrollbar;
|
||||||
|
|
||||||
Tempo_Track *tempo_track;
|
Tempo_Track *tempo_track;
|
||||||
Time_Track *time_track;
|
Time_Track *time_track;
|
||||||
|
|
7
main.C
7
main.C
|
@ -58,8 +58,10 @@ cb_scroll ( Fl_Widget *w, void *v )
|
||||||
|
|
||||||
if ( sb->zoom_changed() )
|
if ( sb->zoom_changed() )
|
||||||
{
|
{
|
||||||
timeline->fpp = sb->zoom() * 256;
|
// timeline->fpp = sb->zoom() * 256;
|
||||||
timeline->fpp = max( min( timeline->fpp, 4096.0f ), (float)2 );
|
timeline->fpp = sb->zoom() * 1;
|
||||||
|
|
||||||
|
/* timeline->fpp = max( min( timeline->fpp, 4096.0f ), (float)2 ); */
|
||||||
|
|
||||||
int maxx = timeline->ts_to_x( timeline->length );
|
int maxx = timeline->ts_to_x( timeline->length );
|
||||||
sb->range( 0, maxx );
|
sb->range( 0, maxx );
|
||||||
|
@ -121,6 +123,7 @@ main ( int argc, char **argv )
|
||||||
|
|
||||||
timeline->scrollbar = new Scalebar( 0, 600 - 24, 800, 24 );
|
timeline->scrollbar = new Scalebar( 0, 600 - 24, 800, 24 );
|
||||||
timeline->scrollbar->range( 0, 48000 * 2 );
|
timeline->scrollbar->range( 0, 48000 * 2 );
|
||||||
|
timeline->scrollbar->zoom_range( 2, 8192 );
|
||||||
timeline->scrollbar->type( 1 );
|
timeline->scrollbar->type( 1 );
|
||||||
timeline->scrollbar->callback( cb_scroll, 0 );
|
timeline->scrollbar->callback( cb_scroll, 0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue