Browse Source

Make snapping work again.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
7501a8094b
4 changed files with 45 additions and 42 deletions
  1. +1
    -1
      Region.C
  2. +4
    -4
      Region.H
  3. +33
    -32
      Track.C
  4. +7
    -5
      main.C

+ 1
- 1
Region.C View File

@@ -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() )


+ 4
- 4
Region.H View File

@@ -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 );


+ 33
- 32
Track.C View File

@@ -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 )


+ 7
- 5
main.C View File

@@ -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…
Cancel
Save