From c79d48c663ba27a701806e0fc6261d75ee2bfe60 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 22 May 2008 15:34:21 -0500 Subject: [PATCH] Rebuffer when an audio region is moved. --- Timeline/Audio_Region.C | 5 +++-- Timeline/Audio_Sequence.C | 13 +++++++++++++ Timeline/Audio_Sequence.H | 2 ++ Timeline/Loggable.H | 1 + Timeline/Sequence.H | 6 ++++++ Timeline/Sequence_Widget.C | 2 -- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Timeline/Audio_Region.C b/Timeline/Audio_Region.C index 2915ead..45ab957 100644 --- a/Timeline/Audio_Region.C +++ b/Timeline/Audio_Region.C @@ -25,7 +25,6 @@ #include #include - #include "Sequence.H" #include "Audio_Region.H" #include "Timeline.H" @@ -210,7 +209,7 @@ Audio_Region::handle ( int m ) int ret; - if ( Sequence_Region::handle( m ) ) + if ( m != FL_RELEASE && Sequence_Region::handle( m ) ) return 1; Logger _log( this ); @@ -361,6 +360,8 @@ Audio_Region::handle ( int m ) copied = false; + sequence()->handle_widget_change( _r->start, _r->length ); + return 1; } case FL_DRAG: diff --git a/Timeline/Audio_Sequence.C b/Timeline/Audio_Sequence.C index b9b1cb4..ca62b01 100644 --- a/Timeline/Audio_Sequence.C +++ b/Timeline/Audio_Sequence.C @@ -25,6 +25,7 @@ #include "Track.H" #include "Engine/Audio_File.H" // for ::from_file() +#include "Transport.H" // for locate() Audio_Sequence::Audio_Sequence ( Track *track ) : Sequence( track ) { @@ -116,6 +117,18 @@ deurlify ( char *url ) } +void +Audio_Sequence::handle_widget_change ( nframes_t start, nframes_t length ) +{ + /* a region has changed. we may need to rebuffer... */ + + /* trigger rebuffer */ + /* FIXME: we really only need to rebuffer *this* sequence! */ + /* FIXME: how does this fit into the selection? */ + if ( start > transport->frame || start + length > transport->frame ) + transport->locate( transport->frame ); +} + void Audio_Sequence::draw ( void ) { diff --git a/Timeline/Audio_Sequence.H b/Timeline/Audio_Sequence.H index 4e25350..4b8eb88 100644 --- a/Timeline/Audio_Sequence.H +++ b/Timeline/Audio_Sequence.H @@ -39,6 +39,8 @@ protected: } + void handle_widget_change ( nframes_t start, nframes_t length ); + public: LOG_CREATE_FUNC( Audio_Sequence ); diff --git a/Timeline/Loggable.H b/Timeline/Loggable.H index b4ac22b..e961281 100644 --- a/Timeline/Loggable.H +++ b/Timeline/Loggable.H @@ -231,6 +231,7 @@ protected: void log_start ( void ); void log_end ( void ); + void log_create ( void ) const; void log_destroy ( void ) const; diff --git a/Timeline/Sequence.H b/Timeline/Sequence.H index cb5d067..d488399 100644 --- a/Timeline/Sequence.H +++ b/Timeline/Sequence.H @@ -60,8 +60,14 @@ protected: std::list _widgets; Sequence_Widget *event_widget ( void ); + public: + /* child classes should implement this if they need to take + special action when a widget is changed/moved/resized. /start/ + and /length/ define the affected region */ + virtual void handle_widget_change ( nframes_t start, nframes_t length ) { (void)(start + length); } + /* welcome to C++ */ LOG_NAME_FUNC( Sequence ); diff --git a/Timeline/Sequence_Widget.C b/Timeline/Sequence_Widget.C index 8dcd433..7489c55 100644 --- a/Timeline/Sequence_Widget.C +++ b/Timeline/Sequence_Widget.C @@ -95,8 +95,6 @@ Sequence_Widget::end_drag ( void ) timeline->unlock(); - /* TODO: perhaps trigger rebuffer here? */ - delete _r; _r = &_range;