diff --git a/Region.C b/Region.C index b424043..3aae149 100644 --- a/Region.C +++ b/Region.C @@ -225,7 +225,7 @@ Region::handle ( int m ) _offset = timeline.x_to_ts( nx ) + timeline.xoffset; -// _track->snap( this ); + _track->snap( this ); } if ( Y > y() + h() ) diff --git a/Region.H b/Region.H index c687334..2da8e54 100644 --- a/Region.H +++ b/Region.H @@ -49,10 +49,10 @@ public: Region ( const Region & rhs ); Region ( Clip *c ); - int y ( void ) { return _track->y(); } - int h ( void ) { return _track->h(); } - int x ( void ) { return _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ); } - int w ( void ) { return timeline.ts_to_x( _end - _start ); } + int y ( void ) const { return _track->y(); } + int h ( void ) const { return _track->h(); } + int x ( void ) const { return _track->x() + timeline.ts_to_x( _offset - timeline.xoffset ); } + int w ( void ) const { return timeline.ts_to_x( _end - _start ); } int handle ( int m ); void draw ( int X, int Y, int W, int H ); diff --git a/Track.C b/Track.C index e714fb4..7e690da 100644 --- a/Track.C +++ b/Track.C @@ -76,51 +76,52 @@ Track::add ( Region *r ) // r->redraw(); } -/** snap /r/ to nearest edge */ -/* void */ -/* Track::snap ( Region *r ) */ -/* { */ -/* const int snap_pixels = 10; */ +/* snap /r/ to nearest edge */ +void +Track::snap ( Region *r ) +{ + const int snap_pixels = 10; -/* int rx1 = r->x(); */ -/* int rx2 = r->x() + r->w(); */ + int rx1 = r->x(); + int rx2 = r->x() + r->w(); -/* for ( int i = children(); i-- ; ) */ -/* { */ -/* const Region *w = (Region*)child( i ); */ + for ( list ::iterator i = _regions.begin(); i != _regions.end(); i++ ) + { + const Region *w = (*i); -/* if ( w == r ) */ -/* continue; */ + if ( w == r ) + continue; -/* int wx1 = w->x(); */ -/* int wx2 = w->x() + w->w(); */ + int wx1 = w->x(); + int wx2 = w->x() + w->w(); -/* if ( abs( rx1 - wx2 ) < snap_pixels ) */ -/* { */ -/* r->offset( w->offset() + w->length() + 1 ); */ + if ( abs( rx1 - wx2 ) < snap_pixels ) + { + r->offset( w->offset() + w->length() + 1 ); -/* printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); */ + printf( "snap: %lu | %lu\n", w->offset() + w->length(), r->offset() ); -/* goto done; */ -/* } */ + goto done; + } -/* if ( abs( rx2 - wx1 ) < snap_pixels ) */ -/* { */ -/* r->offset( ( w->offset() - r->length() ) - 1 ); */ + if ( abs( rx2 - wx1 ) < snap_pixels ) + { + r->offset( ( w->offset() - r->length() ) - 1 ); -/* printf( "snap: %lu | %lu\n", r->offset() + r->length(), 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: -/* r->resize(); */ -/* // r->position( rx1, y() ); */ -/* } */ + return; +// r->resize(); +// r->position( rx1, y() ); +} int Track::handle ( int m ) diff --git a/main.C b/main.C index 6a724b8..44d6c27 100644 --- a/main.C +++ b/main.C @@ -65,6 +65,7 @@ cb_zoom ( Fl_Widget *w, void *v ) /* ((Region*)(track->child( j )))->resize(); */ /* } */ + timeline.scroll->redraw(); if ( timeline.fpp < FRAMES_PER_PEAK ) @@ -84,11 +85,12 @@ cb_scroll ( Fl_Widget *w, void *v ) printf( "%lu\n", timeline.xoffset ); -/* for ( int i = timeline.tracks->children(); i-- ; ) */ -/* { */ -/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */ -/* track-> */ -/* } */ + for ( int i = timeline.tracks->children(); i-- ; ) + { + Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); + track->damage( FL_DAMAGE_SCROLL ); + } + /* /\* for ( int j = track->children(); j-- ; ) *\/ */ /* /\* ((Region*)(track->child( j )))->resize(); *\/ */ /* /\* } *\/ */