From 1d5966570202a34c4ef88416281346a9e5460b62 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 7 Jun 2012 00:29:54 -0700 Subject: [PATCH] Timeline: Eliminate some unnecessary repeated drawing of measure lines. --- timeline/src/Audio_Region.C | 40 +++++++++++++++------------------ timeline/src/Audio_Region.H | 10 +++++++-- timeline/src/Audio_Sequence.C | 5 ++--- timeline/src/Control_Sequence.C | 8 +++---- timeline/src/Sequence.C | 35 +++++++++++++---------------- timeline/src/Sequence.H | 1 + timeline/src/Sequence_Region.C | 2 +- timeline/src/Sequence_Widget.C | 5 +++++ timeline/src/Sequence_Widget.H | 1 + timeline/src/Track.C | 3 --- 10 files changed, 55 insertions(+), 55 deletions(-) diff --git a/timeline/src/Audio_Region.C b/timeline/src/Audio_Region.C index 8eb6de5..d0423ba 100644 --- a/timeline/src/Audio_Region.C +++ b/timeline/src/Audio_Region.C @@ -452,7 +452,7 @@ Audio_Region::draw_box( void ) } Fl_Boxtype b; - Fl_Color c = color; + Fl_Color c = selected() ? selection_color : color; if ( Audio_Region::show_box ) { @@ -462,14 +462,8 @@ Audio_Region::draw_box( void ) { b = FL_DOWN_FRAME; } - - if ( selected() ) - fl_draw_box( fl_down( b ), x(), y(), w(), h(), selection_color ); - else - fl_draw_box( b, x(), y(), w(), h(), c ); - /* used to draw fades here */ - /* draw fades */ + fl_draw_box( b, x(), y(), w(), h(), c ); fl_pop_clip(); } @@ -633,16 +627,14 @@ Audio_Region::draw ( void ) // DMESSAGE( "using cached peaks" ); } - Fl_Color c = _color; - + Fl_Color c = Fl::get_color( _color ); -// c = fl_color_average( FL_BLACK, FL_RED, 0.20 ); + c = fl_color_add_alpha( c, 220 ); if ( peaks && pbuf ) { int ch = (h() - Fl::box_dh( box() )) / channels; - for ( int i = 0; i < channels; ++i ) { Waveform::draw( X + xo, @@ -664,8 +656,6 @@ Audio_Region::draw ( void ) } while ( _loop && xo < W ); - timeline->draw_measure_lines( X, Y, W, H ); - if ( _loop && offset < _loop ) { const int lx = timeline->ts_to_x( _loop - offset ); @@ -703,14 +693,7 @@ Audio_Region::draw ( void ) /* fl_line( rx, Y, rx, Y + H ); */ /* fl_line( rx + rw - 1, Y, rx + rw - 1, Y + H ); */ - if ( _clip->dummy() ) - { - char pat[256]; - snprintf( pat, sizeof( pat ), "Missing Source!: %s", _clip->name() ); - draw_label( pat, align() ); - } - else - draw_label( _clip->name(), align() ); + /* if ( current() ) */ /* { */ @@ -727,6 +710,19 @@ Audio_Region::draw ( void ) } +void +Audio_Region::draw_label ( void ) +{ + if ( _clip->dummy() ) + { + char pat[256]; + snprintf( pat, sizeof( pat ), "Missing Source!: %s", _clip->name() ); + draw_label( pat, align() ); + } + else + draw_label( _clip->name(), align() ); +} + /** split region at absolute frame /where/ */ void Audio_Region::split ( nframes_t where ) diff --git a/timeline/src/Audio_Region.H b/timeline/src/Audio_Region.H index df45c9e..6ed700f 100644 --- a/timeline/src/Audio_Region.H +++ b/timeline/src/Audio_Region.H @@ -119,8 +119,14 @@ protected: virtual void get ( Log_Entry &e ) const; virtual void set ( Log_Entry &e ); + void draw_label ( const char *label, Fl_Align align ) + { + Sequence_Widget::draw_label( label, align ); + } + int handle ( int m ); - void draw_box( void ); + void draw_label ( void ); + void draw_box ( void ); void draw ( void ); void resize ( void ); @@ -152,7 +158,7 @@ public: ~Audio_Region ( ); Fl_Boxtype box ( void ) const { return Audio_Region::_box; } - Fl_Align align ( void ) const { return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM /*| FL_ALIGN_CLIP*/ | FL_ALIGN_INSIDE); } + Fl_Align align ( void ) const { return (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_INSIDE | FL_ALIGN_CLIP ); } void normalize ( void ); void split ( nframes_t where ); diff --git a/timeline/src/Audio_Sequence.C b/timeline/src/Audio_Sequence.C index ad0ea7b..a6ec2d5 100644 --- a/timeline/src/Audio_Sequence.C +++ b/timeline/src/Audio_Sequence.C @@ -164,7 +164,6 @@ Audio_Sequence::draw ( void ) { if ( *o <= **r ) { - /* if ( o->x() == (*r)->x() && o->w() == (*r)->w() ) */ /* printf( "complete superposition\n" ); */ @@ -189,8 +188,8 @@ Audio_Sequence::draw ( void ) 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_Widget::draw_box( FL_FLAT_BOX, b.x - 100, b.y, b.w + 200, b.h, c ); + Fl_Widget::draw_box( FL_UP_FRAME, b.x - 100, b.y, b.w + 200, b.h, c ); fl_pop_clip(); diff --git a/timeline/src/Control_Sequence.C b/timeline/src/Control_Sequence.C index 8a47132..5f3bd2a 100644 --- a/timeline/src/Control_Sequence.C +++ b/timeline/src/Control_Sequence.C @@ -310,13 +310,13 @@ Control_Sequence::draw_curve ( bool flip, bool filled ) void Control_Sequence::draw ( void ) { - if ( ! fl_not_clipped( x(), y(), w(), h() ) ) - return; +// draw_box(); fl_push_clip( x(), y(), w(), h() ); + /* draw the box with the ends cut off. */ - draw_box( box(), x() - Fl::box_dx( box() ), y(), w() + Fl::box_dw( box() ) + 1, h(), color() ); +// draw_box( box(), x() - Fl::box_dx( box() ), y(), w() + Fl::box_dw( box() ) + 1, h(), color() ); const int bx = x(); const int by = y() + Fl::box_dy( box() ); @@ -387,7 +387,7 @@ Control_Sequence::draw ( void ) fl_line_style( FL_SOLID, 0 ); } - // timeline->draw_measure_lines( x(), y(), w(), h(), color ); + timeline->draw_measure_lines( X, Y, W, H ); if ( interpolation() == None || _highlighted || Fl::focus() == this ) for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) diff --git a/timeline/src/Sequence.C b/timeline/src/Sequence.C index 30434e6..40f89d6 100644 --- a/timeline/src/Sequence.C +++ b/timeline/src/Sequence.C @@ -255,42 +255,37 @@ Sequence::snap ( Sequence_Widget *r ) } +void +Sequence::draw_box ( void ) +{ + /* draw the box with the ends cut off. */ + Fl_Widget::draw_box( box(), x() - Fl::box_dx( box() ) - 1, y(), w() + Fl::box_dw( box() ) + 2, h(), color() ); +} + void Sequence::draw ( void ) { + fl_push_clip( x(), y(), w(), h() ); - if ( ! fl_not_clipped( x(), y(), w(), h() ) ) - return; + draw_box(); - fl_push_clip( x(), y(), w(), h() ); + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) + (*r)->draw_box(); - /* draw the box with the ends cut off. */ - draw_box( box(), x() - Fl::box_dx( box() ) - 1, y(), w() + Fl::box_dw( box() ) + 2, h(), color() ); + + for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) + (*r)->draw(); int X, Y, W, H; fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); -/* if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->sequence() == this ) */ -/* { */ -/* /\* make sure the Sequence_Widget::pushed widget is above all others *\/ */ -/* remove( Sequence_Widget::pushed() ); */ -/* add( Sequence_Widget::pushed() ); */ -/* } */ - -// printf( "track::draw %d,%d %dx%d\n", X,Y,W,H ); - timeline->draw_measure_lines( X, Y, W, H ); for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) - (*r)->draw_box(); - - - for ( list ::const_iterator r = _widgets.begin(); r != _widgets.end(); ++r ) - (*r)->draw(); + (*r)->draw_label(); fl_pop_clip(); - } #include "FL/test_press.H" diff --git a/timeline/src/Sequence.H b/timeline/src/Sequence.H index 81471c6..54e807a 100644 --- a/timeline/src/Sequence.H +++ b/timeline/src/Sequence.H @@ -136,6 +136,7 @@ public: virtual void snap ( Sequence_Widget *r ); virtual int handle ( int m ); virtual void draw ( void ); + virtual void draw_box ( void ); virtual nframes_t process ( nframes_t ) { return 0; } diff --git a/timeline/src/Sequence_Region.C b/timeline/src/Sequence_Region.C index 354bf06..60636c1 100644 --- a/timeline/src/Sequence_Region.C +++ b/timeline/src/Sequence_Region.C @@ -247,7 +247,7 @@ Sequence_Region::handle ( int m ) void Sequence_Region::draw_box ( void ) { - fl_draw_box( box(), line_x(), y(), abs_w(), h(), box_color() ); + fl_draw_box( box(), line_x(), y(), abs_w(), h(), fl_color_add_alpha( box_color(), 127 ) ); } void diff --git a/timeline/src/Sequence_Widget.C b/timeline/src/Sequence_Widget.C index 3fb5674..ccc880c 100644 --- a/timeline/src/Sequence_Widget.C +++ b/timeline/src/Sequence_Widget.C @@ -230,6 +230,11 @@ Sequence_Widget::start ( nframes_t where ) } } +void +Sequence_Widget::draw_label ( void ) +{ +} + void Sequence_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color, int xo, int yo ) { diff --git a/timeline/src/Sequence_Widget.H b/timeline/src/Sequence_Widget.H index 6cfa5d2..c65696e 100644 --- a/timeline/src/Sequence_Widget.H +++ b/timeline/src/Sequence_Widget.H @@ -281,6 +281,7 @@ public: virtual void draw_box ( void ); virtual void draw ( void ); + virtual void draw_label ( void ); bool operator< ( const Sequence_Widget & rhs ) const diff --git a/timeline/src/Track.C b/timeline/src/Track.C index 8f7aa26..92d4d34 100644 --- a/timeline/src/Track.C +++ b/timeline/src/Track.C @@ -839,8 +839,6 @@ Track::draw ( void ) fl_clip_box( x(), y(), w(), h(), X, Y, W, H ); - timeline->draw_measure_lines( X, Y, W, H ); - if ( _selected ) { Fl_Color c = color(); @@ -854,7 +852,6 @@ Track::draw ( void ) else Fl_Group::draw(); - fl_pop_clip(); }