Allow copying of regions.
This commit is contained in:
parent
ece5a45cb0
commit
894d5d85d0
31
Region.C
31
Region.C
|
@ -30,7 +30,7 @@
|
|||
|
||||
extern Timeline timeline;
|
||||
|
||||
Region::Region ( int X, int Y, int W, int H, const char *L=0 ) : Waveform( X, Y, W, H, L )
|
||||
Region::Region ( int X, int Y, int W, int H, const char *L ) : Waveform( X, Y, W, H, L )
|
||||
{
|
||||
align( FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_CLIP );
|
||||
labeltype( FL_SHADOW_LABEL );
|
||||
|
@ -40,6 +40,17 @@ Region::Region ( int X, int Y, int W, int H, const char *L=0 ) : Waveform( X, Y,
|
|||
_track = NULL;
|
||||
}
|
||||
|
||||
Region::Region ( const Region & rhs ) : Waveform( rhs )
|
||||
{
|
||||
box( rhs.box() );
|
||||
align( rhs.align() );
|
||||
color( rhs.color() );
|
||||
selection_color( rhs.selection_color() );
|
||||
labelcolor( rhs.labelcolor() );
|
||||
|
||||
_track = rhs._track;
|
||||
}
|
||||
|
||||
void
|
||||
Region::trim ( enum trim_e t, int X )
|
||||
{
|
||||
|
@ -79,6 +90,8 @@ Region::handle ( int m )
|
|||
static int ox, oy;
|
||||
static enum trim_e trimming;
|
||||
|
||||
static bool copied = false;
|
||||
|
||||
switch ( m )
|
||||
{
|
||||
case FL_PUSH:
|
||||
|
@ -86,7 +99,7 @@ Region::handle ( int m )
|
|||
int X = Fl::event_x();
|
||||
int Y = Fl::event_y();
|
||||
|
||||
if ( Fl::event_state() & FL_CTRL )
|
||||
if ( Fl::event_state() & FL_SHIFT )
|
||||
{
|
||||
switch ( Fl::event_button() )
|
||||
{
|
||||
|
@ -119,10 +132,12 @@ Region::handle ( int m )
|
|||
}
|
||||
case FL_RELEASE:
|
||||
fl_cursor( FL_CURSOR_DEFAULT );
|
||||
copied = false;
|
||||
trimming = NO;
|
||||
return 1;
|
||||
case FL_DRAG:
|
||||
|
||||
if ( Fl::event_state() & FL_CTRL )
|
||||
if ( Fl::event_state() & FL_SHIFT )
|
||||
if ( trimming )
|
||||
{
|
||||
trim( trimming, Fl::event_x() );
|
||||
|
@ -131,6 +146,16 @@ Region::handle ( int m )
|
|||
else
|
||||
return 0;
|
||||
|
||||
if ( Fl::event_state() & FL_CTRL )
|
||||
{
|
||||
if ( ! copied )
|
||||
{
|
||||
_track->add( new Region( *this ) );
|
||||
copied = true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ox + Fl::event_x() >= _track->x() )
|
||||
position( ox + Fl::event_x(), y() );
|
||||
|
||||
|
|
4
Region.H
4
Region.H
|
@ -34,7 +34,9 @@ class Region : public Waveform
|
|||
|
||||
public:
|
||||
|
||||
Region ( int X, int Y, int W, int H, const char *L );
|
||||
Region ( int X, int Y, int W, int H, const char *L=0 );
|
||||
|
||||
Region ( const Region & rhs );
|
||||
|
||||
int handle ( int m );
|
||||
void draw ( void );
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
extern Fl_Color velocity_colors[];
|
||||
|
||||
|
||||
Waveform::Waveform ( int X, int Y, int W, int H, const char *L=0 ) : Fl_Widget( X, Y, W, H, L )
|
||||
Waveform::Waveform ( int X, int Y, int W, int H, const char *L ) : Fl_Widget( X, Y, W, H, L )
|
||||
{
|
||||
|
||||
|
||||
|
|
13
Waveform.H
13
Waveform.H
|
@ -26,7 +26,9 @@ typedef unsigned long tick_t;
|
|||
|
||||
class Waveform : public Fl_Widget
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
float *_peaks;
|
||||
|
||||
tick_t _start;
|
||||
|
@ -37,7 +39,16 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
Waveform ( int X, int Y, int W, int H, const char *L );
|
||||
Waveform ( int X, int Y, int W, int H, const char *L=0 );
|
||||
|
||||
Waveform ( const Waveform & rhs ) : Fl_Widget( rhs.x(), rhs.y(), rhs.w(), rhs.h(), rhs.label() )
|
||||
{
|
||||
// Fl_Widget::resize( rhs.x(), rhs.y(), rhs.w(), rhs.h() );
|
||||
|
||||
_peaks = rhs._peaks;
|
||||
_start = rhs._start;
|
||||
_end = rhs._end;
|
||||
}
|
||||
|
||||
int handle ( int m );
|
||||
void draw ( void );
|
||||
|
|
4
main.C
4
main.C
|
@ -106,7 +106,9 @@ main ( int argc, char **argv )
|
|||
|
||||
Track *track2 = new Track( 40, 0, 5000, 100 );
|
||||
|
||||
Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
|
||||
// Region *wave2 = new Region( 0, 0, 350, 100, "bar" );
|
||||
|
||||
Region *wave2 = new Region( *wave );
|
||||
|
||||
wave2->peaks( peaks );
|
||||
wave2->start( 300 );
|
||||
|
|
Loading…
Reference in New Issue