Cleanup region code a bit.

This commit is contained in:
Jonathan Moore Liles 2008-02-16 02:09:11 -06:00
parent 76d2d70611
commit 043517166e
1 changed files with 14 additions and 18 deletions

View File

@ -47,6 +47,7 @@ Region::Region ( const Region & rhs ) : Waveform( rhs )
color( rhs.color() ); color( rhs.color() );
selection_color( rhs.selection_color() ); selection_color( rhs.selection_color() );
labelcolor( rhs.labelcolor() ); labelcolor( rhs.labelcolor() );
labeltype( rhs.labeltype() );
_track = rhs._track; _track = rhs._track;
} }
@ -92,12 +93,13 @@ Region::handle ( int m )
static bool copied = false; static bool copied = false;
int X = Fl::event_x();
int Y = Fl::event_y();
switch ( m ) switch ( m )
{ {
case FL_PUSH: case FL_PUSH:
{ {
int X = Fl::event_x();
int Y = Fl::event_y();
if ( Fl::event_state() & FL_SHIFT ) if ( Fl::event_state() & FL_SHIFT )
{ {
@ -117,13 +119,8 @@ Region::handle ( int m )
} }
else else
{ {
ox = x() - Fl::event_x(); ox = x() - X;
oy = y() - Fl::event_y(); oy = y() - Y;
if ( Fl::event_button() == 2 )
{
// _track->add( new Region( *this ) );
}
return 1; return 1;
} }
@ -140,7 +137,7 @@ Region::handle ( int m )
if ( Fl::event_state() & FL_SHIFT ) if ( Fl::event_state() & FL_SHIFT )
if ( trimming ) if ( trimming )
{ {
trim( trimming, Fl::event_x() ); trim( trimming, X );
return 1; return 1;
} }
else else
@ -156,34 +153,33 @@ Region::handle ( int m )
} }
} }
if ( ox + Fl::event_x() >= _track->x() ) if ( ox + X >= _track->x() )
position( ox + Fl::event_x(), y() ); position( ox + X, y() );
if ( Fl::event_y() > y() + h() ) if ( Y > y() + h() )
{ {
if ( _track->next() ) if ( _track->next() )
_track->next()->add( this ); _track->next()->add( this );
} }
else else
if ( Fl::event_y() < y() ) if ( Y < y() )
{ {
if ( _track->prev() ) if ( _track->prev() )
_track->prev()->add( this ); _track->prev()->add( this );
} }
// if ( Fl::event_y() - oy >= h() )
parent()->redraw(); parent()->redraw();
fl_cursor( FL_CURSOR_MOVE ); fl_cursor( FL_CURSOR_MOVE );
if ( Fl::event_x() >= timeline.scroll->x() + timeline.scroll->w() || if ( X >= timeline.scroll->x() + timeline.scroll->w() ||
Fl::event_x() <= timeline.scroll->x() ) X <= timeline.scroll->x() )
{ {
/* this drag needs to scroll */ /* this drag needs to scroll */
long pos = timeline.scroll->xposition(); long pos = timeline.scroll->xposition();
if ( Fl::event_x() <= timeline.scroll->x() ) if ( X <= timeline.scroll->x() )
pos -= 100; pos -= 100;
else else
pos += 100; pos += 100;