Browse Source

Fix a number of problems with region drawing.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
4543d48c41
6 changed files with 32 additions and 63 deletions
  1. +1
    -1
      Timeline/Control_Track.H
  2. +13
    -29
      Timeline/Region.C
  3. +2
    -2
      Timeline/Region.H
  4. +11
    -12
      Timeline/Track.C
  5. +2
    -2
      Timeline/Track_Point.H
  6. +3
    -17
      Timeline/Track_Widget.H

+ 1
- 1
Timeline/Control_Track.H View File

@@ -93,7 +93,7 @@ public:
timeline->draw_measure_lines( x(), y(), w(), h(), color() );

for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw_box( X, Y, W, H );
(*r)->draw_box();

fl_pop_clip();
}


+ 13
- 29
Timeline/Region.C View File

@@ -540,14 +540,11 @@ Region::draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool line, int X, in
}

void
Region::draw_box( int X, int Y, int W, int H )
Region::draw_box( void )
{
if ( ! shown() )
return;

/* dirty hack to keep the box from flipping to vertical at small sizes */

fl_push_clip( x(), Y, w(), H );
fl_push_clip( x(), y(), w(), h() );

if ( selected() )
fl_draw_box( fl_down( box() ), x() - 10, y(), w() + 50, h(), _selection_color );
@@ -556,27 +553,24 @@ Region::draw_box( int X, int Y, int W, int H )
fl_draw_box( box(), x() - 10, y(), w() + 50, h(), _box_color );

/* draw fades */
draw_fade( _fade_in, Fade::In, false, X, W );
draw_fade( _fade_out, Fade::Out, false, X, W );
draw_fade( _fade_in, Fade::In, false, x(), w() );
draw_fade( _fade_out, Fade::Out, false, x(), w() );

fl_pop_clip();
}

/** Draw (part of) region. X, Y, W and H are the rectangle we're clipped to. */
void
Region::draw ( int X, int Y, int W, int H )
Region::draw ( void )
{
if ( ! shown() )
return;

/* intersect clip with region */
/* FIXME: wouldn't it be better to get rid of the useless X Y W H arguments and
just intersect with the real clipping region? */

int X, Y, W, H;

fl_clip_box( x(), y(), w(), h(), X, Y, W, H );

if ( ! ( W > 0 && H > 0 ) )
/* WTF? */
/* no coverage */
return;

int OX = scroll_x();
@@ -587,13 +581,7 @@ Region::draw ( int X, int Y, int W, int H )
/* not in viewport */
return;

if ( x() > X + W || x() + w() < X )
/* no coverage */
return;


int rw = timeline->ts_to_x( _r->end - _r->start );

// nframes_t end = _r->offset + ( _r->end - _r->start );

/* calculate waveform offset due to scrolling */
@@ -609,7 +597,7 @@ Region::draw ( int X, int Y, int W, int H )

int rx = x();

// fl_push_clip( rx, Y, rw, H );
fl_push_clip( rx, Y, rw, H );

/* get actual peak data */
int channels;
@@ -624,10 +612,9 @@ Region::draw ( int X, int Y, int W, int H )
if ( X - rx > 0 )
start += timeline->x_to_ts( X - rx );

printf( "offset=%lu start=%lu\n", offset, start, X, rx );
if ( _clip->read_peaks( timeline->fpp(),
start,
start + timeline->x_to_ts( min( rw, W ) ),
start + timeline->x_to_ts( W ),
&peaks, &pbuf, &channels ) )
{

@@ -660,12 +647,9 @@ Region::draw ( int X, int Y, int W, int H )
/* pb[ j ].max *= g; */
/* } */

const int nx = max( X, rx );
const int nw = min( nx + W, nx + rw ) - nx;

Waveform::draw( nx,
Waveform::draw( X,
(y() + Fl::box_dy( box() )) + (i * ch),
nw,
W,
ch,
pb, peaks,
selected() ? fl_invert_color( _color ) : _color );
@@ -694,7 +678,7 @@ Region::draw ( int X, int Y, int W, int H )
draw_label( pat, (Fl_Align)(FL_ALIGN_INSIDE | FL_ALIGN_CENTER), FL_GREEN );
}

// fl_pop_clip();
fl_pop_clip();

}



+ 2
- 2
Timeline/Region.H View File

@@ -262,8 +262,8 @@ public:
int handle ( int m );
void draw_fade ( const Fade &fade, Fade::fade_dir_e dir, bool filled, int X, int W );

void draw_box( int X, int Y, int W, int H );
void draw ( int X, int Y, int W, int H );
void draw_box( void );
void draw ( void );
void resize ( void );

void normalize ( void );


+ 11
- 12
Timeline/Track.C View File

@@ -99,22 +99,19 @@ Track::draw ( void )
timeline->draw_measure_lines( x(), y(), w(), h(), color() );

for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw_box( X, Y, W, H );
(*r)->draw_box();


for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw( X, Y, W, H );
(*r)->draw();


/* draw crossfades */
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
if ( ! (*r)->shown() )
continue;

Track_Widget *o = overlaps( *r );

if ( o && o->shown() )
if ( o )
{
if ( *o <= **r )
{
@@ -153,12 +150,9 @@ Track::draw ( void )

for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
if ( ! (*r)->shown() )
continue;

Track_Widget *o = overlaps( *r );

if ( o && o->shown() )
if ( o )
{
if ( *o <= **r )
{
@@ -179,8 +173,13 @@ Track::draw ( void )
/* o->color( FL_RED ); */
/* (*r)->color( FL_GREEN ); */

o->draw( b.x, b.y, b.w, b.h );
(*r)->draw( b.x, b.y, b.w, b.h );
fl_push_clip( b.x, b.y, b.w, b.h );

o->draw();
(*r)->draw();

fl_pop_clip();

Waveform::fill = true;




+ 2
- 2
Timeline/Track_Point.H View File

@@ -49,9 +49,9 @@ public:
}

virtual void
draw ( int X, int Y, int W, int H )
draw ( void )
{
Track_Widget::draw( x(), Y, w(), H );
Track_Widget::draw();

draw_label( _label, align() );
}


+ 3
- 17
Timeline/Track_Widget.H View File

@@ -74,8 +74,6 @@ protected:
Fl_Color _color; /* color of waveform */
Fl_Color _box_color; /* color of background (box) */

bool _shown;

Drag *_drag;

public:
@@ -88,8 +86,6 @@ public:

_r->offset = _r->start = _r->end = 0;

_shown = true;

_drag = NULL;
}

@@ -165,10 +161,6 @@ public:

// static void pushed ( Track_Widget *w ) { Track_Widget::_pushed = w; }

bool shown ( void ) const { return _shown; }
void show ( void ) { _shown = true; }
void hide ( void ) { _shown = false; }

void begin_drag ( const Drag &d )
{
_drag = new Drag( d );
@@ -281,21 +273,15 @@ public:

/* just draw a simple box */
virtual void
draw_box ( int X, int Y, int W, int H )
draw_box ( void )
{
if ( x() > X + W || x() + w() < X )
return;

fl_draw_box( box(), x(), y(), w(), h(), _box_color );
}

virtual void
draw ( int X, int Y, int W, int H )
draw ( void )
{
if ( x() > X + W || x() + w() < X )
return;

draw_box( X, Y, W, H );
draw_box();
}

bool


Loading…
Cancel
Save