Don't draw more waveform than necessary.

pull/3/head
Jonathan Moore Liles 2008-02-25 23:37:17 -06:00
parent 63fb8971a2
commit a81a46510d
5 changed files with 18 additions and 8 deletions

View File

@ -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 );

View File

@ -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();

View File

@ -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 <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw_box( X, Y, W, H );

View File

@ -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 ];

View File

@ -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 );