Move range trimming math into Range class.

This commit is contained in:
Jonathan Moore Liles 2008-05-12 11:23:55 -05:00
parent f41f23c306
commit 99795a4f56
2 changed files with 32 additions and 6 deletions

View File

@ -90,9 +90,8 @@ Sequence_Region::trim ( enum trim_e t, int X )
// td = _r->length - timeline->x_to_ts( 1 ); // td = _r->length - timeline->x_to_ts( 1 );
_r->offset += td; _r->trim_left( 0 - td );
_r->start += td;
_r->length -= td;
break; break;
} }
case RIGHT: case RIGHT:
@ -106,9 +105,9 @@ Sequence_Region::trim ( enum trim_e t, int X )
// printf( "%li %li\n", td, _r->length - _r->offset ); // printf( "%li %li\n", td, _r->length - _r->offset );
if ( td >= 0 && _r->length < (nframes_t)td ) if ( td >= 0 && _r->length < (nframes_t)td )
_r->length = timeline->x_to_ts( 1 ); td = _r->length - timeline->x_to_ts( 1 );
else
_r->length -= td; _r->trim_right( 0 - td );
break; break;
} }

View File

@ -40,13 +40,40 @@ struct Drag
Drag( int X, int Y, nframes_t start=0 ) : x( X ), y( Y ), start( start ) { state = 0; } Drag( int X, int Y, nframes_t start=0 ) : x( X ), y( Y ), start( start ) { state = 0; }
}; };
/* most common position description. /offset/ is only used by Regions,
but it's more convenient to have it here */
struct Range struct Range
{ {
nframes_t start; /* where on the timeline */ nframes_t start; /* where on the timeline */
nframes_t offset; /* first sample from clip */ nframes_t offset; /* first sample from clip */
nframes_t length; /* total number of samples */ nframes_t length; /* total number of samples */
void
trim_left ( long n )
{
start -= n;
offset -= n;
length += n;
}
void
trim_right ( long n )
{
length += n;
}
}; };
/* Used by time/tempo points or any other child of Sequence_Widget
which must be locked to a point in musical time rather than wallclock
time. Bar and beat start at 1. */
struct BBT
{
unsigned short bar;
unsigned char beat;
unsigned short tick;
};
/* Base class for virtual widget on a track */ /* Base class for virtual widget on a track */
class Sequence_Widget : public Loggable class Sequence_Widget : public Loggable
{ {