Try to make snapping more accurate.

pull/3/head
Jonathan Moore Liles 2008-02-18 18:35:37 -06:00
parent a055856c56
commit 2d6a93b448
4 changed files with 29 additions and 10 deletions

View File

@ -221,6 +221,8 @@ Region::handle ( int m )
// nx = _track->snap( this, nx );
// _offset = timeline.x_to_ts( nx );
position( nx, y() );
_track->snap( this );
@ -260,7 +262,7 @@ Region::handle ( int m )
timeline.scroll->position( pos, timeline.scroll->yposition() );
}
_offset = timeline.x_to_ts( x() );
// _offset = timeline.x_to_ts( x() );
return 1;
default:

View File

@ -48,9 +48,9 @@ public:
void resize ( void );
Track * track ( void ) { return _track; }
Track * track ( void ) const { return _track; }
void track ( Track *t ) { _track = t; }
nframes_t offset ( void ) { return _offset; }
nframes_t offset ( void ) const { return _offset; }
void offset ( nframes_t o ) { _offset = o; }
};

27
Track.H
View File

@ -25,6 +25,9 @@
#include <stdio.h>
#include <assert.h>
#include <list>
using std::list;
@ -88,7 +91,7 @@ public:
for ( int i = children(); i-- ; )
{
const Fl_Widget *w = child( i );
const Region *w = (Region*)child( i );
if ( w == r )
continue;
@ -98,17 +101,29 @@ public:
if ( abs( rx1 - wx2 ) < snap_pixels )
{
rx1 = wx2 - 1;
break;
r->offset( w->offset() + ( w->end() - w->start() ) + 1 );
printf( "snap: %lu | %lu\n", w->offset() + (w->end() - w->start()), r->offset() );
goto done;
}
if ( abs( rx2 - wx1 ) < snap_pixels )
{
rx1 = (wx1 - r->w()) + 1;
break;
r->offset( (w->offset() - ( r->end() - r->start() )) - 1 );
printf( "snap: %lu | %lu\n", r->offset() + (r->end() - r->start()), w->offset() );
goto done;
}
}
r->position( rx1, y() );
r->offset( timeline.x_to_ts( r->x() ));
done:
r->resize();
// r->position( rx1, y() );
}
int handle ( int m )

View File

@ -68,9 +68,11 @@ public:
void draw ( int X, int Y, int W, int H );
void start ( nframes_t s ) { _start = s; }
nframes_t start ( void ) const { return _start; }
void end ( nframes_t e ) { _end = e; }
nframes_t end ( void ) const { return _end; }
void scale ( float s ) { _scale = s; }
float scale ( void ) { return _scale; }
float scale ( void ) const { return _scale; }
// void peaks ( float *p ) { _peaks = p; }
void normalize ( void );