Make snapping work again.
This commit is contained in:
parent
bcfa0cb029
commit
7501a8094b
2
Region.C
2
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() )
|
||||
|
|
8
Region.H
8
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 );
|
||||
|
|
65
Track.C
65
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 <Region*>::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 )
|
||||
|
|
12
main.C
12
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(); *\/ */
|
||||
/* /\* } *\/ */
|
||||
|
|
Loading…
Reference in New Issue