From a81a46510d4d18cbf5700b4547de36ca37a882bf Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 25 Feb 2008 23:37:17 -0600 Subject: [PATCH] Don't draw more waveform than necessary. --- Region.C | 6 +++++- Timeline.H | 3 ++- Track.C | 2 ++ Waveform.C | 13 ++++++++----- Waveform.H | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Region.C b/Region.C index df8a5d0..85507f6 100644 --- a/Region.C +++ b/Region.C @@ -409,10 +409,14 @@ Region::draw ( int X, int Y, int W, int H ) int ch = h() / _clip->channels(); for ( int i = _clip->channels(); i--; ) - draw_waveform( rx, y() + (i * ch), rw, ch, _clip, i, +// draw_waveform( rx, y() + (i * ch), rw, ch, _clip, i, +// _start + offset, min( (_end - _start) - offset, _end), +// _scale, _selected ? _color : fl_invert_color( _color ) ); + draw_waveform( rx, X, y() + (i * ch), W, ch, _clip, i, _start + offset, min( (_end - _start) - offset, _end), _scale, _selected ? _color : fl_invert_color( _color ) ); + timeline->draw_measure_lines( rx, Y, rw, H, _box_color ); fl_color( FL_BLACK ); diff --git a/Timeline.H b/Timeline.H index 1ef411d..3218345 100644 --- a/Timeline.H +++ b/Timeline.H @@ -126,6 +126,7 @@ struct Timeline : public Fl_Group { Timeline *tl = (Timeline *)v; + printf( "draw_clip: %d,%d %dx%d\n", X, Y, W, H ); fl_push_clip( X, Y, W, H ); fl_color( rand() ); @@ -145,7 +146,7 @@ struct Timeline : public Fl_Group X = tracks->x() + Fl::box_dx( tracks->child( 0 )->box() ) + 1; Y = tracks->y(); - W = tracks->w() - Fl::box_dw( tracks->child( 0 )->box() ) - 2; + W = tracks->w() - Fl::box_dw( tracks->child( 0 )->box() ) - 1; H = tracks->h(); diff --git a/Track.C b/Track.C index 37bd3d7..85d874f 100644 --- a/Track.C +++ b/Track.C @@ -61,6 +61,8 @@ Track::draw ( void ) fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); +// printf( "track::draw %d,%d %dx%d\n", X,Y,W,H ); + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) (*r)->draw_box( X, Y, W, H ); diff --git a/Waveform.C b/Waveform.C index 6896c60..7ef9b36 100644 --- a/Waveform.C +++ b/Waveform.C @@ -31,20 +31,23 @@ /** draw a portion of /clip/'s waveform. coordinates are the portion to draw */ void -draw_waveform ( int X, int Y, int W, int H, Audio_File *_clip, int channel, nframes_t _start, nframes_t _end, float _scale, Fl_Color color ) +draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, nframes_t _start, nframes_t _end, float _scale, Fl_Color color ) { fl_push_clip( X, Y, W, H ); int j; - int start = timeline->ts_to_x( _start ); +// int start = timeline->ts_to_x( _start ); + int start = timeline->ts_to_x( _start ) + (X - ox); const Peaks *pk = _clip->peaks( channel ); + _start = timeline->x_to_ts( start ); + pk->fill_buffer( _start, _start + timeline->x_to_ts( W ) ); j = start; - for ( int x = X; x < X + W; ++x, ++j ) + for ( int x = X; x <= X + W; ++x, ++j ) { Peak p = (*pk)[ j ]; @@ -70,7 +73,7 @@ draw_waveform ( int X, int Y, int W, int H, Audio_File *_clip, int channel, nfra fl_begin_line(); j = start; - for ( int x = X; x < X + W; ++x, ++j ) + for ( int x = X; x <= X + W; ++x, ++j ) { Peak p = (*pk)[ j ]; @@ -84,7 +87,7 @@ draw_waveform ( int X, int Y, int W, int H, Audio_File *_clip, int channel, nfra fl_begin_line(); j = start; - for ( int x = X; x < X + W; ++x, ++j ) + for ( int x = X; x <= X + W; ++x, ++j ) { Peak p = (*pk)[ j ]; diff --git a/Waveform.H b/Waveform.H index f89e67e..6106795 100644 --- a/Waveform.H +++ b/Waveform.H @@ -26,4 +26,4 @@ #include "Audio_File.H" -void draw_waveform ( int X, int Y, int W, int H, Audio_File *_clip, int channel, nframes_t _start, nframes_t _end, float _scale, Fl_Color color ); +void draw_waveform ( int rx, int X, int Y, int W, int H, Audio_File *_clip, int channel, nframes_t _start, nframes_t _end, float _scale, Fl_Color color );