Move audio specific sequence code into Audio_Sequence class.

This commit is contained in:
Jonathan Moore Liles 2008-05-01 01:07:10 -05:00
parent 7a1fb271d4
commit 84af307881
3 changed files with 86 additions and 107 deletions

View File

@ -18,6 +18,7 @@
/*******************************************************************************/ /*******************************************************************************/
#include "Audio_Sequence.H" #include "Audio_Sequence.H"
#include "Waveform.H"
#include "dsp.h" #include "dsp.h"
@ -52,6 +53,89 @@ deurlify ( char *url )
*w = NULL; *w = NULL;
} }
void
Audio_Sequence::draw ( void )
{
Sequence::draw();
int xfades = 0;
/* draw crossfades */
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
Sequence_Widget *o = overlaps( *r );
if ( o )
{
if ( *o <= **r )
{
/* if ( o->x() == (*r)->x() && o->w() == (*r)->w() ) */
/* printf( "complete superposition\n" ); */
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() )
/* completely inside */
continue;
++xfades;
Rectangle b( (*r)->x(),
o->y(),
(o->x() + o->w()) - (*r)->x(),
o->h() );
Fl_Color c = fl_color_average( o->box_color(), (*r)->box_color(), 0.50f );
c = fl_color_average( c, FL_YELLOW, 0.30f );
fl_push_clip( b.x, b.y, b.w, b.h );
draw_box( FL_FLAT_BOX, b.x - 100, b.y, b.w + 200, b.h, c );
draw_box( FL_UP_FRAME, b.x - 100, b.y, b.w + 200, b.h, c );
fl_pop_clip();
}
}
}
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
Sequence_Widget *o = overlaps( *r );
if ( o )
{
if ( *o <= **r )
{
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() )
/* completely inside */
continue;
Rectangle b( (*r)->x(), o->y(), (o->x() + o->w()) - (*r)->x(), o->h() );
/* draw overlapping waveforms in X-ray style. */
bool t = Waveform::fill;
Waveform::fill = false;
fl_push_clip( b.x, b.y, b.w, b.h );
o->draw();
(*r)->draw();
fl_pop_clip();
Waveform::fill = t;
}
}
}
}
/** event handler that supports DND of audio clips */ /** event handler that supports DND of audio clips */
int int
Audio_Sequence::handle ( int m ) Audio_Sequence::handle ( int m )

View File

@ -101,6 +101,7 @@ public:
// const char *class_name ( void ) { return "Audio_Sequence"; } // const char *class_name ( void ) { return "Audio_Sequence"; }
void draw ( void );
int handle ( int m ); int handle ( int m );
void dump ( void ); void dump ( void );
void remove_selected ( void ); void remove_selected ( void );

View File

@ -81,8 +81,6 @@ Sequence::overlaps ( Sequence_Widget *r )
} }
#include "Waveform.H"
void void
Sequence::draw ( void ) Sequence::draw ( void )
{ {
@ -99,7 +97,6 @@ Sequence::draw ( void )
fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); fl_clip_box( x(), y(), w(), h(), X, Y, W, H );
if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->track() == this ) if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->track() == this )
{ {
/* make sure the Sequence_Widget::pushed widget is above all others */ /* make sure the Sequence_Widget::pushed widget is above all others */
@ -107,8 +104,6 @@ Sequence::draw ( void )
add( Sequence_Widget::pushed() ); add( Sequence_Widget::pushed() );
} }
int xfades = 0;
// printf( "track::draw %d,%d %dx%d\n", X,Y,W,H ); // printf( "track::draw %d,%d %dx%d\n", X,Y,W,H );
timeline->draw_measure_lines( X, Y, W, H, color() ); timeline->draw_measure_lines( X, Y, W, H, color() );
@ -120,109 +115,8 @@ Sequence::draw ( void )
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw(); (*r)->draw();
/* draw crossfades */
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
Sequence_Widget *o = overlaps( *r );
if ( o )
{
if ( *o <= **r )
{
/* if ( o->x() == (*r)->x() && o->w() == (*r)->w() ) */
/* printf( "complete superposition\n" ); */
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() )
/* completely inside */
continue;
++xfades;
Rectangle b( (*r)->x(),
o->y(),
(o->x() + o->w()) - (*r)->x(),
o->h() );
Fl_Color c = fl_color_average( o->box_color(), (*r)->box_color(), 0.50f );
c = fl_color_average( c, FL_YELLOW, 0.30f );
fl_push_clip( b.x, b.y, b.w, b.h );
draw_box( FL_FLAT_BOX, b.x - 100, b.y, b.w + 200, b.h, c );
draw_box( FL_UP_FRAME, b.x - 100, b.y, b.w + 200, b.h, c );
fl_pop_clip();
}
}
}
// printf( "There are %d xfades\n", xfades );
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
{
Sequence_Widget *o = overlaps( *r );
if ( o )
{
if ( *o <= **r )
{
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() )
/* completely inside */
continue;
Rectangle b( (*r)->x(), o->y(), (o->x() + o->w()) - (*r)->x(), o->h() );
/* draw overlapping waveforms in X-ray style. */
bool t = Waveform::fill;
Waveform::fill = false;
/* Fl_Color oc = o->color(); */
/* Fl_Color rc = (*r)->color(); */
/* /\* give each region a different color *\/ */
/* o->color( FL_RED ); */
/* (*r)->color( FL_GREEN ); */
fl_push_clip( b.x, b.y, b.w, b.h );
o->draw();
(*r)->draw();
fl_pop_clip();
Waveform::fill = t;
/* o->color( oc ); */
/* (*r)->color( rc ); */
/* fl_color( FL_BLACK ); */
/* fl_line_style( FL_DOT, 4 ); */
/* b.x = (*r)->line_x(); */
/* b.w = min( 32767, (*r)->abs_w() ); */
/* fl_line( b.x, b.y, b.x + b.w, b.y + b.h ); */
/* fl_line( b.x, b.y + b.h, b.x + b.w, b.y ); */
/* fl_line_style( FL_SOLID, 0 ); */
// fl_pop_clip();
}
}
}
fl_pop_clip(); fl_pop_clip();
} }
void void