Quit using FLTK's weird DND system for inter-track drags.

This commit is contained in:
Jonathan Moore Liles 2008-05-01 04:47:37 -05:00
parent 84a2bdcb17
commit 821a3feedc
5 changed files with 45 additions and 29 deletions

View File

@ -142,21 +142,10 @@ Audio_Sequence::handle ( int m )
{
switch ( m )
{
case FL_DND_DRAG:
return Sequence::handle( m ) | 1;
/* case FL_DND_ENTER: */
/* case FL_DND_LEAVE: */
case FL_DND_RELEASE:
return 1;
case FL_PASTE:
{
const char *text = Fl::event_text();
if ( ! strcmp( text, "Region" ) )
return 1;

View File

@ -407,7 +407,6 @@ Region::handle ( int m )
break;
}
case FL_RELEASE:
{
Sequence_Widget::handle( m );
@ -466,19 +465,22 @@ Region::handle ( int m )
}
}
/* track jumping */
if ( ! selected() )
{
if ( Y > y() + h() )
if ( Y > y() + h() || Y < y() )
{
Fl::copy( class_name(), strlen( class_name() ), 0 );
Fl::dnd();
}
else
if ( Y < y() )
{
Fl::copy( class_name(), strlen( class_name() ), 0 );
Fl::dnd();
printf( "wants to jump tracks\n" );
Track *t = timeline->track_under( Y );
fl_cursor( (Fl_Cursor)1 );
if ( t )
t->handle( FL_ENTER );
return 0;
}
}

View File

@ -255,20 +255,28 @@ Sequence::handle ( int m )
switch ( m )
{
case FL_FOCUS:
return 1;
case FL_UNFOCUS:
case FL_LEAVE:
case FL_DND_DRAG:
return 1;
case FL_ENTER:
case FL_LEAVE:
return 1;
case FL_DND_ENTER:
printf( "enter\n" );
if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->track()->class_name() == class_name() )
if ( Sequence_Widget::pushed() )
{
if ( Sequence_Widget::pushed()->track()->class_name() == class_name() )
{
/* accept objects dragged from other sequences of this type */
add( Sequence_Widget::pushed() );
redraw();
fl_cursor( FL_CURSOR_MOVE );
}
else
fl_cursor( (Fl_Cursor)1 );
}
case FL_DND_ENTER:
case FL_DND_LEAVE:
case FL_DND_RELEASE:
return 1;
case FL_MOVE:
{

View File

@ -854,6 +854,22 @@ Timeline::select_none ( void )
Sequence_Widget::select_none();
}
/** An unfortunate necessity for implementing our own DND aside from
* the (bogus) native FLTK system */
Track *
Timeline::track_under ( int Y )
{
for ( int i = tracks->children(); i-- ; )
{
Track *t = (Track*)tracks->child( i );
if ( ! ( t->y() > Y || t->y() + t->h() < Y ) )
return t;
}
}
int
Timeline::handle ( int m )
{

View File

@ -160,6 +160,7 @@ public:
static void update_cb ( void *arg );
void select( const Rectangle &r );
Track * track_under ( int Y );
void delete_selected ( void );