Browse Source

Clean up region trimming code.

tags/non-daw-v1.1.0
Jonathan Moore Liles 16 years ago
parent
commit
99937affb9
2 changed files with 40 additions and 46 deletions
  1. +37
    -46
      Timeline/Sequence_Region.C
  2. +3
    -0
      Timeline/Sequence_Region.H

+ 37
- 46
Timeline/Sequence_Region.C View File

@@ -66,70 +66,61 @@ Sequence_Region::set ( Log_Entry &e )
}

void
Sequence_Region::trim ( enum trim_e t, int X )
Sequence_Region::trim_left ( nframes_t where )
{
long td = where - _r->start;

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() );
if ( td < 0 && _r->offset < (nframes_t)( 0 - td ) )
td = 0 - _r->offset;

long td = timeline->x_to_ts( d );
if ( td > 0 && (nframes_t)td >= _r->length )
td = _r->length - timeline->x_to_ts( 1 );

if ( td < 0 && _r->offset < (nframes_t)( 0 - td ) )
td = 0 - _r->offset;
_r->trim_left( 0 - td );

if ( td > 0 && (nframes_t)td >= _r->length )
td = _r->length - timeline->x_to_ts( 1 );
nframes_t f = _r->start;

// td = _r->length - timeline->x_to_ts( 1 );
/* snap to beat/bar lines */
if ( timeline->nearest_line( &f ) )
_r->set_left( f );

_r->trim_left( 0 - td );

nframes_t f = _r->start;

/* snap to beat/bar lines */
if ( timeline->nearest_line( &f ) )
_r->set_left( f );
}

break;
}
case RIGHT:
{
int d = (( abs_x() - scroll_x() ) + abs_w() ) - X;
void
Sequence_Region::trim_right ( nframes_t where )
{
long td = ( _r->start + _r->length ) - where;

/* _track->damage( FL_DAMAGE_EXPOSE, x() + w(), y(), d, h() ); */
if ( td >= 0 && _r->length < (nframes_t)td )
td = _r->length - timeline->x_to_ts( 1 );

long td = timeline->x_to_ts( d );
_r->trim_right( 0 - td );

// printf( "%li %li\n", td, _r->length - _r->offset );
nframes_t f = _r->start + _r->length;

if ( td >= 0 && _r->length < (nframes_t)td )
td = _r->length - timeline->x_to_ts( 1 );
/* snap to beat/bar lines */
if ( timeline->nearest_line( &f ) )
_r->set_right( f );

_r->trim_right( 0 - td );
}

nframes_t f = _r->start + _r->length;
void
Sequence_Region::trim ( enum trim_e t, int X )
{
redraw();

/* snap to beat/bar lines */
if ( timeline->nearest_line( &f ) )
_r->set_right( f );
nframes_t where = timeline->x_to_offset( X );

switch ( t )
{
case LEFT:
trim_left( where );
break;
case RIGHT:
trim_right( where );
break;
}
default:
return;

break;
}
}



+ 3
- 0
Timeline/Sequence_Region.H 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 );



Loading…
Cancel
Save