Work in snapping some more.

This commit is contained in:
Jonathan Moore Liles 2008-02-19 00:22:42 -06:00
parent 2d6a93b448
commit 80ec2b6e35
5 changed files with 24 additions and 12 deletions

View File

@ -277,8 +277,16 @@ void
Region::resize ( void )
{
int X = timeline.ts_to_x( _offset );
assert( _end >= _start );
int W = timeline.ts_to_x( _end - _start );
printf( "%dx%d\n", X, W );
if ( W > 5000 )
W = 5000;
if ( W )
Fl_Widget::resize( X, y(), W, h() );
}

View File

@ -23,18 +23,23 @@
#include <FL/Fl_Pack.H>
#include "Clip.H"
#include <math.h>
#include <assert.h>
struct Timeline {
Fl_Scroll *scroll;
Fl_Pack *tracks;
float fpp; /* frames per pixel */
// nframes_t fpp;
nframes_t sample_rate;
int
ts_to_x( nframes_t ts )
{
// assert( ts / fpp > 0 );
return ts / fpp;
}

View File

@ -101,18 +101,18 @@ public:
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;
}
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;
}

View File

@ -71,6 +71,7 @@ public:
nframes_t start ( void ) const { return _start; }
void end ( nframes_t e ) { _end = e; }
nframes_t end ( void ) const { return _end; }
nframes_t length ( void ) const { return _end - _start; }
void scale ( float s ) { _scale = s; }
float scale ( void ) const { return _scale; }

10
main.C
View File

@ -88,15 +88,16 @@ main ( int argc, char **argv )
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->spacing( 20 );
Fl::get_system_colors();
Fl::scheme( "plastic" );
// 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->box( FL_DOWN_BOX );
@ -107,10 +108,7 @@ main ( int argc, char **argv )
// 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->selection_color( fl_darker( FL_GRAY ) );