@@ -277,8 +277,16 @@ void | |||||
Region::resize ( void ) | Region::resize ( void ) | ||||
{ | { | ||||
int X = timeline.ts_to_x( _offset ); | int X = timeline.ts_to_x( _offset ); | ||||
assert( _end >= _start ); | |||||
int W = timeline.ts_to_x( _end - _start ); | int W = timeline.ts_to_x( _end - _start ); | ||||
printf( "%dx%d\n", X, W ); | |||||
if ( W > 5000 ) | |||||
W = 5000; | |||||
if ( W ) | if ( W ) | ||||
Fl_Widget::resize( X, y(), W, h() ); | Fl_Widget::resize( X, y(), W, h() ); | ||||
} | } | ||||
@@ -23,19 +23,24 @@ | |||||
#include <FL/Fl_Pack.H> | #include <FL/Fl_Pack.H> | ||||
#include "Clip.H" | #include "Clip.H" | ||||
#include <math.h> | |||||
#include <assert.h> | |||||
struct Timeline { | struct Timeline { | ||||
Fl_Scroll *scroll; | Fl_Scroll *scroll; | ||||
Fl_Pack *tracks; | Fl_Pack *tracks; | ||||
float fpp; /* frames per pixel */ | float fpp; /* frames per pixel */ | ||||
// nframes_t fpp; | |||||
nframes_t sample_rate; | nframes_t sample_rate; | ||||
int | int | ||||
ts_to_x( nframes_t ts ) | ts_to_x( nframes_t ts ) | ||||
{ | { | ||||
return ts / fpp; | |||||
// assert( ts / fpp > 0 ); | |||||
return ts / fpp; | |||||
} | } | ||||
nframes_t | nframes_t | ||||
@@ -101,24 +101,24 @@ public: | |||||
if ( abs( rx1 - wx2 ) < snap_pixels ) | if ( abs( rx1 - wx2 ) < snap_pixels ) | ||||
{ | { | ||||
r->offset( w->offset() + ( w->end() - w->start() ) + 1 ); | |||||
r->offset( w->offset() + w->length() + 1 ); | |||||
printf( "snap: %lu | %lu\n", w->offset() + (w->end() - w->start()), r->offset() ); | |||||
printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); | |||||
goto done; | goto done; | ||||
} | } | ||||
if ( abs( rx2 - wx1 ) < snap_pixels ) | if ( abs( rx2 - wx1 ) < snap_pixels ) | ||||
{ | { | ||||
r->offset( (w->offset() - ( r->end() - r->start() )) - 1 ); | |||||
r->offset( ( w->offset() - r->length() ) - 1 ); | |||||
printf( "snap: %lu | %lu\n", r->offset() + (r->end() - r->start()), w->offset() ); | |||||
printf( "snap: %lu | %lu\n", r->offset() + r->length(), w->offset() ); | |||||
goto done; | goto done; | ||||
} | } | ||||
} | } | ||||
r->offset( timeline.x_to_ts( r->x() )); | |||||
r->offset( timeline.x_to_ts( r->x() ) ); | |||||
done: | done: | ||||
@@ -71,6 +71,7 @@ public: | |||||
nframes_t start ( void ) const { return _start; } | nframes_t start ( void ) const { return _start; } | ||||
void end ( nframes_t e ) { _end = e; } | void end ( nframes_t e ) { _end = e; } | ||||
nframes_t end ( void ) const { return _end; } | nframes_t end ( void ) const { return _end; } | ||||
nframes_t length ( void ) const { return _end - _start; } | |||||
void scale ( float s ) { _scale = s; } | void scale ( float s ) { _scale = s; } | ||||
float scale ( void ) const { return _scale; } | float scale ( void ) const { return _scale; } | ||||
@@ -88,15 +88,16 @@ main ( int argc, char **argv ) | |||||
timeline.sample_rate = 44100; | timeline.sample_rate = 44100; | ||||
timeline.tracks = new Fl_Pack( 0, 0, 5000, 5000 ); | |||||
timeline.tracks = new Fl_Pack( 0, 0, 32767, 5000 ); | |||||
timeline.tracks->type( Fl_Pack::VERTICAL ); | timeline.tracks->type( Fl_Pack::VERTICAL ); | ||||
timeline.tracks->spacing( 20 ); | |||||
Fl::get_system_colors(); | Fl::get_system_colors(); | ||||
Fl::scheme( "plastic" ); | Fl::scheme( "plastic" ); | ||||
// Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 ); | // Fl_Group *pack = new Fl_Group( 0, 0, 5000, 600 ); | ||||
Track *track1 = new Track( 40, 0, 5000, 100 ); | |||||
Track *track1 = new Track( 40, 0, 32768, 100 ); | |||||
// pack->type( Fl_Pack::VERTICAL ); | // pack->type( Fl_Pack::VERTICAL ); | ||||
// pack->box( FL_DOWN_BOX ); | // pack->box( FL_DOWN_BOX ); | ||||
@@ -107,10 +108,7 @@ main ( int argc, char **argv ) | |||||
// wave->resize( 0, 0, 500, 100 ); | // wave->resize( 0, 0, 500, 100 ); | ||||
// wave->peaks( peaks ); | |||||
wave->start( 0 ); | |||||
// wave->end( (len / sizeof( float )) / 2 ); | |||||
wave->end( 50 ); | |||||
wave->offset( 1024 ); | |||||
wave->color( FL_CYAN ); | wave->color( FL_CYAN ); | ||||
wave->selection_color( fl_darker( FL_GRAY ) ); | wave->selection_color( fl_darker( FL_GRAY ) ); | ||||