Clean up region trimming code.

This commit is contained in:
Jonathan Moore Liles 2009-01-22 22:47:55 -06:00
parent c903e96d00
commit 99937affb9
2 changed files with 47 additions and 53 deletions

View File

@ -66,25 +66,9 @@ Sequence_Region::set ( Log_Entry &e )
}
void
Sequence_Region::trim ( enum trim_e t, int X )
Sequence_Region::trim_left ( nframes_t where )
{
X -= sequence()->x();
redraw();
switch ( t )
{
case LEFT:
{
/* if ( d < 0 ) */
/* // _track->damage( FL_DAMAGE_EXPOSE, x() + d, y(), 1 - d, h() ); */
/* _track->damage( FL_DAMAGE_EXPOSE, x(), y(), w(), h() ); */
/* else */
/* _track->damage( FL_DAMAGE_EXPOSE, x(), y(), d, h() ); */
int d = X - ( abs_x() - scroll_x() );
long td = timeline->x_to_ts( d );
long td = where - _r->start;
if ( td < 0 && _r->offset < (nframes_t)( 0 - td ) )
td = 0 - _r->offset;
@ -92,8 +76,6 @@ Sequence_Region::trim ( enum trim_e t, int X )
if ( td > 0 && (nframes_t)td >= _r->length )
td = _r->length - timeline->x_to_ts( 1 );
// td = _r->length - timeline->x_to_ts( 1 );
_r->trim_left( 0 - td );
nframes_t f = _r->start;
@ -102,17 +84,12 @@ Sequence_Region::trim ( enum trim_e t, int X )
if ( timeline->nearest_line( &f ) )
_r->set_left( f );
break;
}
case RIGHT:
{
int d = (( abs_x() - scroll_x() ) + abs_w() ) - X;
}
/* _track->damage( FL_DAMAGE_EXPOSE, x() + w(), y(), d, h() ); */
long td = timeline->x_to_ts( d );
// printf( "%li %li\n", td, _r->length - _r->offset );
void
Sequence_Region::trim_right ( nframes_t where )
{
long td = ( _r->start + _r->length ) - where;
if ( td >= 0 && _r->length < (nframes_t)td )
td = _r->length - timeline->x_to_ts( 1 );
@ -125,11 +102,25 @@ Sequence_Region::trim ( enum trim_e t, int X )
if ( timeline->nearest_line( &f ) )
_r->set_right( f );
break;
}
default:
return;
}
void
Sequence_Region::trim ( enum trim_e t, int X )
{
redraw();
nframes_t where = timeline->x_to_offset( X );
switch ( t )
{
case LEFT:
trim_left( where );
break;
case RIGHT:
trim_right( where );
break;
default:
break;
}
}

View File

@ -45,6 +45,9 @@ public:
LOG_NAME_FUNC( Region );
void trim_right ( nframes_t where );
void trim_left ( nframes_t where );
enum trim_e { NO, LEFT, RIGHT };
void trim ( enum trim_e t, int X );