diff --git a/Region.C b/Region.C index 66814de..b27508f 100644 --- a/Region.C +++ b/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() ); diff --git a/Region.H b/Region.H index 60eb907..669267e 100644 --- a/Region.H +++ b/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 ); diff --git a/Waveform.C b/Waveform.C index ed47f58..41c9b76 100644 --- a/Waveform.C +++ b/Waveform.C @@ -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 ) { diff --git a/Waveform.H b/Waveform.H index 1135ecd..6df3256 100644 --- a/Waveform.H +++ b/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 ); diff --git a/main.C b/main.C index 7ae291d..cdb1b6f 100644 --- a/main.C +++ b/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 );