diff --git a/Timeline/Audio_Sequence.C b/Timeline/Audio_Sequence.C index e94fb50..510c4f4 100644 --- a/Timeline/Audio_Sequence.C +++ b/Timeline/Audio_Sequence.C @@ -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; diff --git a/Timeline/Region.C b/Timeline/Region.C index 0f80e5a..c6a94ab 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -407,7 +407,6 @@ Region::handle ( int m ) break; } case FL_RELEASE: - { Sequence_Widget::handle( m ); @@ -466,20 +465,23 @@ 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(); + 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; } - else - if ( Y < y() ) - { - Fl::copy( class_name(), strlen( class_name() ), 0 ); - Fl::dnd(); - } } ret = Sequence_Widget::handle( m ); diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 323125c..6637985 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -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() ) { - 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_RELEASE: return 1; case FL_MOVE: { diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 0a627e4..b7edda1 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -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 ) { diff --git a/Timeline/Timeline.H b/Timeline/Timeline.H index 3efcf3f..f58cf96 100644 --- a/Timeline/Timeline.H +++ b/Timeline/Timeline.H @@ -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 );