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 ) 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: case FL_PASTE:
{ {
const char *text = Fl::event_text(); const char *text = Fl::event_text();
if ( ! strcmp( text, "Region" ) ) if ( ! strcmp( text, "Region" ) )
return 1; return 1;

View File

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

View File

@ -255,20 +255,28 @@ Sequence::handle ( int m )
switch ( m ) switch ( m )
{ {
case FL_FOCUS: case FL_FOCUS:
return 1;
case FL_UNFOCUS: case FL_UNFOCUS:
case FL_LEAVE:
case FL_DND_DRAG:
return 1; return 1;
case FL_ENTER: case FL_ENTER:
case FL_LEAVE: if ( Sequence_Widget::pushed() )
return 1;
case FL_DND_ENTER:
printf( "enter\n" );
if ( Sequence_Widget::pushed() && Sequence_Widget::pushed()->track()->class_name() == class_name() )
{ {
add( Sequence_Widget::pushed() );
redraw(); 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_LEAVE:
case FL_DND_RELEASE:
return 1; return 1;
case FL_MOVE: case FL_MOVE:
{ {

View File

@ -854,6 +854,22 @@ Timeline::select_none ( void )
Sequence_Widget::select_none(); 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 int
Timeline::handle ( int m ) Timeline::handle ( int m )
{ {

View File

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