From 84af307881d95e4665d69498148d089acb325d83 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 1 May 2008 01:07:10 -0500 Subject: [PATCH] Move audio specific sequence code into Audio_Sequence class. --- Timeline/Audio_Sequence.C | 84 +++++++++++++++++++++++++++++ Timeline/Audio_Sequence.H | 1 + Timeline/Sequence.C | 108 +------------------------------------- 3 files changed, 86 insertions(+), 107 deletions(-) diff --git a/Timeline/Audio_Sequence.C b/Timeline/Audio_Sequence.C index 69e56bb..e94fb50 100644 --- a/Timeline/Audio_Sequence.C +++ b/Timeline/Audio_Sequence.C @@ -18,6 +18,7 @@ /*******************************************************************************/ #include "Audio_Sequence.H" +#include "Waveform.H" #include "dsp.h" @@ -52,6 +53,89 @@ deurlify ( char *url ) *w = NULL; } + +void +Audio_Sequence::draw ( void ) +{ + + Sequence::draw(); + + int xfades = 0; + + /* draw crossfades */ + for ( list ::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 ::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 */ int Audio_Sequence::handle ( int m ) diff --git a/Timeline/Audio_Sequence.H b/Timeline/Audio_Sequence.H index d8e2df1..b1d77a3 100644 --- a/Timeline/Audio_Sequence.H +++ b/Timeline/Audio_Sequence.H @@ -101,6 +101,7 @@ public: // const char *class_name ( void ) { return "Audio_Sequence"; } + void draw ( void ); int handle ( int m ); void dump ( void ); void remove_selected ( void ); diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index eb2691c..323125c 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -81,8 +81,6 @@ Sequence::overlaps ( Sequence_Widget *r ) } -#include "Waveform.H" - void Sequence::draw ( void ) { @@ -99,7 +97,6 @@ Sequence::draw ( void ) fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); - if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->track() == this ) { /* make sure the Sequence_Widget::pushed widget is above all others */ @@ -107,8 +104,6 @@ Sequence::draw ( void ) add( Sequence_Widget::pushed() ); } - int xfades = 0; - // printf( "track::draw %d,%d %dx%d\n", X,Y,W,H ); timeline->draw_measure_lines( X, Y, W, H, color() ); @@ -120,109 +115,8 @@ Sequence::draw ( void ) for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) (*r)->draw(); - - /* draw crossfades */ - for ( list ::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 ::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(); + } void