diff --git a/timeline/src/Engine/Audio_Region.C b/timeline/src/Engine/Audio_Region.C index 161651f..3d186b9 100644 --- a/timeline/src/Engine/Audio_Region.C +++ b/timeline/src/Engine/Audio_Region.C @@ -229,6 +229,27 @@ Audio_Region::prepare ( void ) // log_start(); } + +class SequenceRedrawRequest { +public: + nframes_t start; + nframes_t length; + Sequence *sequence; +}; + +static +void +sequence_redraw_request_handle ( void *v ) +{ + THREAD_ASSERT(UI); + + SequenceRedrawRequest *o = (SequenceRedrawRequest*)v; + + o->sequence->damage( FL_DAMAGE_USER1, timeline->offset_to_x( o->start ), o->sequence->y(), timeline->ts_to_x( o->length ), o->sequence->h() ); + + delete o; +}; + /** write /nframes/ from /buf/ to source. /buf/ is interleaved and must match the channel layout of the write source! */ nframes_t @@ -242,9 +263,12 @@ Audio_Region::write ( nframes_t nframes ) if ( W ) { - Fl::lock(); - sequence()->damage(FL_DAMAGE_USER1, x(), y(), w(), h()); - Fl::unlock(); + SequenceRedrawRequest *o = new SequenceRedrawRequest(); + o->sequence = sequence(); + o->start = _range.start + ( _range.length - timeline->x_to_ts( 20 ) ); + o->length = timeline->x_to_ts( 20 ); + + Fl::awake(sequence_redraw_request_handle, o); } } diff --git a/timeline/src/Timeline.C b/timeline/src/Timeline.C index 6c26f36..300ab5d 100644 --- a/timeline/src/Timeline.C +++ b/timeline/src/Timeline.C @@ -940,6 +940,12 @@ Timeline::x_to_offset ( int x ) const return x_to_ts( max( 0, x - Track::width() ) ) + xoffset; } +int +Timeline::offset_to_x ( nframes_t frame ) const +{ + return ts_to_x( frame - xoffset ) + Track::width(); +} + /** draws a single measure line */ void Timeline::draw_measure_cb ( nframes_t frame, const BBT &bbt, void *v ) diff --git a/timeline/src/Timeline.H b/timeline/src/Timeline.H index e4e2e40..14de37b 100644 --- a/timeline/src/Timeline.H +++ b/timeline/src/Timeline.H @@ -85,7 +85,6 @@ struct Rectangle Rectangle ( int X, int Y, int W, int H ) : x( X ), y( Y ), w( W ), h( H ) {} }; - #ifdef USE_WIDGET_FOR_TIMELINE class Timeline : public Fl_Group, public RWLock #else @@ -214,6 +213,7 @@ public: int ts_to_x( nframes_t ts ) const { return ts >> _fpp; } nframes_t x_to_ts ( int x ) const { return x << _fpp; } nframes_t x_to_offset ( int x ) const; + int offset_to_x ( nframes_t frame ) const; float beats_per_minute ( nframes_t when ) const; int beats_per_bar ( nframes_t when ) const;