diff --git a/Timeline/Annotation_Point.H b/Timeline/Annotation_Point.H index 87532a3..c60ee62 100644 --- a/Timeline/Annotation_Point.H +++ b/Timeline/Annotation_Point.H @@ -64,6 +64,7 @@ public: /* for loggable */ LOG_CREATE_FUNC( Annotation_Point ); + SEQUENCE_WIDGET_CLONE_FUNC( Annotation_Point ); Annotation_Point ( Sequence *sequence, nframes_t when, const char *name ) { @@ -82,11 +83,6 @@ public: _label = strdup( rhs._label ); } - Sequence_Widget *clone ( const Sequence_Widget *r ) - { - return new Annotation_Point( *(Annotation_Point*)r ); - } - ~Annotation_Point ( ) { log_destroy(); diff --git a/Timeline/Annotation_Region.H b/Timeline/Annotation_Region.H index dd419d9..0197c9d 100644 --- a/Timeline/Annotation_Region.H +++ b/Timeline/Annotation_Region.H @@ -53,6 +53,7 @@ public: /* for loggable */ LOG_CREATE_FUNC( Annotation_Region ); + SEQUENCE_WIDGET_CLONE_FUNC( Annotation_Region ); Annotation_Region ( Sequence *track, nframes_t when, const char *name ); Annotation_Region ( const Annotation_Region &rhs ); @@ -62,9 +63,4 @@ public: void draw ( void ); int handle ( int m ); - Sequence_Widget *clone ( const Sequence_Widget *r ) - { - return new Annotation_Region( *(Annotation_Region*)r ); - } - }; diff --git a/Timeline/Audio_Region.C b/Timeline/Audio_Region.C index e6db9bc..8bddddd 100644 --- a/Timeline/Audio_Region.C +++ b/Timeline/Audio_Region.C @@ -140,12 +140,6 @@ Audio_Region::Audio_Region ( const Audio_Region & rhs ) log_create(); } -Sequence_Widget * -Audio_Region::clone ( const Sequence_Widget *r ) -{ - return new Audio_Region( *(Audio_Region*)r ); -} - /* */ Audio_Region::Audio_Region ( Audio_File *c ) { @@ -383,7 +377,7 @@ Audio_Region::handle ( int m ) int d = (ox + X) - x(); long td = timeline->x_to_ts( d ); - if ( td > 0 && os < td ) + if ( td > 0 && os < (nframes_t)td ) _r->offset = 0; else _r->offset = os - td; diff --git a/Timeline/Audio_Region.H b/Timeline/Audio_Region.H index 5b64e59..3082639 100644 --- a/Timeline/Audio_Region.H +++ b/Timeline/Audio_Region.H @@ -127,7 +127,7 @@ public: LOG_CREATE_FUNC( Audio_Region ); - Sequence_Widget *clone ( const Sequence_Widget *r ); + SEQUENCE_WIDGET_CLONE_FUNC( Audio_Region ); ~Audio_Region ( ) { diff --git a/Timeline/Control_Point.H b/Timeline/Control_Point.H index a516d01..1816543 100644 --- a/Timeline/Control_Point.H +++ b/Timeline/Control_Point.H @@ -41,12 +41,7 @@ public: /* for loggable */ LOG_CREATE_FUNC( Control_Point ); - - - Sequence_Widget *clone ( const Sequence_Widget *r ) - { - return new Control_Point( *(Control_Point*)r ); - } + SEQUENCE_WIDGET_CLONE_FUNC( Control_Point ); Control_Point ( Sequence *t, nframes_t when, float y ); Control_Point ( const Control_Point &rhs ); diff --git a/Timeline/Sequence_Widget.H b/Timeline/Sequence_Widget.H index c760673..8d05710 100644 --- a/Timeline/Sequence_Widget.H +++ b/Timeline/Sequence_Widget.H @@ -128,7 +128,14 @@ public: /* *this = rhs; */ /* } */ - virtual Sequence_Widget *clone ( const Sequence_Widget *r ) = 0; +#define SEQUENCE_WIDGET_CLONE_FUNC(class) \ + virtual Sequence_Widget *clone ( void ) const \ + { \ + return new class ( *this ); \ + } \ + \ +// virtual Sequence_Widget *clone ( const Sequence_Widget *r ) = 0; + virtual Sequence_Widget *clone ( void ) const = 0; bool selected ( void ) const { diff --git a/Timeline/Tempo_Point.H b/Timeline/Tempo_Point.H index 28a9235..556018d 100644 --- a/Timeline/Tempo_Point.H +++ b/Timeline/Tempo_Point.H @@ -46,9 +46,10 @@ protected: public: - static bool edit ( float *tempo ); - LOG_CREATE_FUNC( Tempo_Point ); + SEQUENCE_WIDGET_CLONE_FUNC( Tempo_Point ); + + static bool edit ( float *tempo ); Tempo_Point ( nframes_t when, float bpm ); @@ -60,11 +61,6 @@ public: _tempo = rhs._tempo; } - Sequence_Widget *clone ( const Sequence_Widget *r ) - { - return new Tempo_Point( *(Tempo_Point*)r ); - } - float tempo ( void ) const { return _tempo; } diff --git a/Timeline/Time_Point.H b/Timeline/Time_Point.H index f0fb44f..f287acc 100644 --- a/Timeline/Time_Point.H +++ b/Timeline/Time_Point.H @@ -69,6 +69,7 @@ protected: public: LOG_CREATE_FUNC( Time_Point ); + SEQUENCE_WIDGET_CLONE_FUNC( Time_Point ); Time_Point ( nframes_t when, int bpb, int note ); Time_Point ( const Time_Point &rhs ); @@ -78,10 +79,6 @@ public: log_destroy(); } - Sequence_Widget *clone ( const Sequence_Widget *r ) - { - return new Time_Point( *(Time_Point*)r ); - } void time ( int bpb, int note ) { _time.beats_per_bar = bpb; _time.beat_type = note; } time_sig time ( void ) const { return _time; }