Move range trimming math into Range class.
This commit is contained in:
parent
f41f23c306
commit
99795a4f56
|
@ -90,9 +90,8 @@ Sequence_Region::trim ( enum trim_e t, int X )
|
|||
|
||||
// td = _r->length - timeline->x_to_ts( 1 );
|
||||
|
||||
_r->offset += td;
|
||||
_r->start += td;
|
||||
_r->length -= td;
|
||||
_r->trim_left( 0 - td );
|
||||
|
||||
break;
|
||||
}
|
||||
case RIGHT:
|
||||
|
@ -106,9 +105,9 @@ Sequence_Region::trim ( enum trim_e t, int X )
|
|||
// printf( "%li %li\n", td, _r->length - _r->offset );
|
||||
|
||||
if ( td >= 0 && _r->length < (nframes_t)td )
|
||||
_r->length = timeline->x_to_ts( 1 );
|
||||
else
|
||||
_r->length -= td;
|
||||
td = _r->length - timeline->x_to_ts( 1 );
|
||||
|
||||
_r->trim_right( 0 - td );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -40,13 +40,40 @@ struct Drag
|
|||
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
|
||||
{
|
||||
nframes_t start; /* where on the timeline */
|
||||
nframes_t offset; /* first sample from clip */
|
||||
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 */
|
||||
class Sequence_Widget : public Loggable
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue