@@ -159,7 +159,7 @@ Audio_Sequence::draw ( void ) | |||||
/* if ( o->x() == (*r)->x() && o->w() == (*r)->w() ) */ | /* if ( o->x() == (*r)->x() && o->w() == (*r)->w() ) */ | ||||
/* printf( "complete superposition\n" ); */ | /* printf( "complete superposition\n" ); */ | ||||
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() ) | |||||
if ( o->contains( *r ) ) | |||||
/* completely inside */ | /* completely inside */ | ||||
continue; | continue; | ||||
@@ -195,7 +195,7 @@ Audio_Sequence::draw ( void ) | |||||
if ( *o <= **r ) | if ( *o <= **r ) | ||||
{ | { | ||||
if ( (*r)->x() >= o->x() && (*r)->x() + (*r)->w() <= o->x() + o->w() ) | |||||
if ( o->contains( *r ) ) | |||||
/* completely inside */ | /* completely inside */ | ||||
continue; | continue; | ||||
@@ -101,14 +101,13 @@ Sequence::overlaps ( Sequence_Widget *r ) | |||||
for ( list <Sequence_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ ) | for ( list <Sequence_Widget *>::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ ) | ||||
{ | { | ||||
if ( *i == r ) continue; | if ( *i == r ) continue; | ||||
if ( ! ( (*i)->start() > r->start() + r->length() || (*i)->start() + (*i)->length() < r->start() ) ) | |||||
if ( (*i)->overlaps( r ) ) | |||||
return *i; | return *i; | ||||
} | } | ||||
return NULL; | return NULL; | ||||
} | } | ||||
void | void | ||||
Sequence::draw ( void ) | Sequence::draw ( void ) | ||||
{ | { | ||||
@@ -314,6 +314,21 @@ public: | |||||
int active_r ( void ) const { return _sequence->active_r(); } | int active_r ( void ) const { return _sequence->active_r(); } | ||||
/** returns true if widget /w/ begins and ends completely within the range of this widget */ | |||||
bool contains ( const Sequence_Widget *w ) const | |||||
{ | |||||
return w->start() >= start() && w->start() + w->length() <= start() + length(); | |||||
} | |||||
/** returns true of widget /w/ overlaps this widget in any place */ | |||||
bool overlaps ( const Sequence_Widget *w ) const | |||||
{ | |||||
return ! ( w->start() > start() + length() || w->start() + w->length() < start() ); | |||||
} | |||||
virtual Fl_Boxtype box ( void ) const { return FL_UP_BOX; } | virtual Fl_Boxtype box ( void ) const { return FL_UP_BOX; } | ||||
virtual Fl_Align align ( void ) const { return (Fl_Align)0; } | virtual Fl_Align align ( void ) const { return (Fl_Align)0; } | ||||