diff --git a/timeline/src/Timeline.C b/timeline/src/Timeline.C index 2cfa847..30c998b 100644 --- a/timeline/src/Timeline.C +++ b/timeline/src/Timeline.C @@ -1619,6 +1619,16 @@ Timeline::handle_scroll ( int m ) return 0; } +Track * +Timeline::event_inside ( void ) +{ + for ( int i = tracks->children(); i--; ) + if ( Fl::event_inside( tracks->child(i) ) ) + return (Track*)tracks->child(i); + + return NULL; +} + int Timeline::handle ( int m ) { @@ -1901,6 +1911,14 @@ Timeline::add_track ( Track *track ) } +void +Timeline::insert_track ( Track *track, Track *before ) +{ + tracks->insert( *track, before ); + + tracks->redraw(); +} + void Timeline::insert_track ( Track *track, int n ) { diff --git a/timeline/src/Timeline.H b/timeline/src/Timeline.H index c6c59e4..3d382be 100644 --- a/timeline/src/Timeline.H +++ b/timeline/src/Timeline.H @@ -139,8 +139,12 @@ class Timeline : public Fl_Single_Window, public RWLock void update_track_order ( void ); void apply_track_order ( void ); void insert_track ( Track *track, int n ); + public: + + void insert_track ( Track *track, Track *before ); + Track * event_inside ( void ); /* called when widgets are moved etc */ void damage_sequence ( void ); diff --git a/timeline/src/Track.C b/timeline/src/Track.C index f2d3f7b..9d365fd 100644 --- a/timeline/src/Track.C +++ b/timeline/src/Track.C @@ -1041,7 +1041,8 @@ Track::handle ( int m ) /* if ( m != FL_NO_EVENT ) */ /* DMESSAGE( "%s", event_name( m ) ); */ - + static Fl_Widget *dragging = NULL; + switch ( m ) { case FL_DND_ENTER: @@ -1087,7 +1088,12 @@ Track::handle ( int m ) } case FL_PUSH: { - if ( Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) + if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->color_box ) ) + { + dragging = this; + return 1; + } + if ( Fl::event_button1() && Fl::event_inside( ((Track_Header*)child(0))->output_connector_handle ) ) return 1; Logger log( this ); @@ -1123,6 +1129,15 @@ Track::handle ( int m ) Fl::selection_owner(0); } return 1; + case FL_RELEASE: + if ( dragging == this ) + { + dragging = NULL; + timeline->insert_track( this, timeline->event_inside() ); + return 1; + } + return 0; + break; case FL_DND_RELEASE: receptive_to_drop = 0; redraw(); @@ -1234,8 +1249,9 @@ Track::handle ( int m ) return 1; } else - return 0; - + { + return 1; + } } default: return Fl_Group::handle( m );