Timeline: Allow drag and drop moving of tracks.
This commit is contained in:
parent
0552a9a7cf
commit
b664d0ed04
|
@ -1619,6 +1619,16 @@ Timeline::handle_scroll ( int m )
|
||||||
return 0;
|
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
|
int
|
||||||
Timeline::handle ( int m )
|
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
|
void
|
||||||
Timeline::insert_track ( Track *track, int n )
|
Timeline::insert_track ( Track *track, int n )
|
||||||
{
|
{
|
||||||
|
|
|
@ -139,8 +139,12 @@ class Timeline : public Fl_Single_Window, public RWLock
|
||||||
void update_track_order ( void );
|
void update_track_order ( void );
|
||||||
void apply_track_order ( void );
|
void apply_track_order ( void );
|
||||||
void insert_track ( Track *track, int n );
|
void insert_track ( Track *track, int n );
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void insert_track ( Track *track, Track *before );
|
||||||
|
Track * event_inside ( void );
|
||||||
|
|
||||||
/* called when widgets are moved etc */
|
/* called when widgets are moved etc */
|
||||||
void damage_sequence ( void );
|
void damage_sequence ( void );
|
||||||
|
|
|
@ -1041,7 +1041,8 @@ Track::handle ( int m )
|
||||||
|
|
||||||
/* if ( m != FL_NO_EVENT ) */
|
/* if ( m != FL_NO_EVENT ) */
|
||||||
/* DMESSAGE( "%s", event_name( m ) ); */
|
/* DMESSAGE( "%s", event_name( m ) ); */
|
||||||
|
static Fl_Widget *dragging = NULL;
|
||||||
|
|
||||||
switch ( m )
|
switch ( m )
|
||||||
{
|
{
|
||||||
case FL_DND_ENTER:
|
case FL_DND_ENTER:
|
||||||
|
@ -1087,7 +1088,12 @@ Track::handle ( int m )
|
||||||
}
|
}
|
||||||
case FL_PUSH:
|
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;
|
return 1;
|
||||||
|
|
||||||
Logger log( this );
|
Logger log( this );
|
||||||
|
@ -1123,6 +1129,15 @@ Track::handle ( int m )
|
||||||
Fl::selection_owner(0);
|
Fl::selection_owner(0);
|
||||||
}
|
}
|
||||||
return 1;
|
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:
|
case FL_DND_RELEASE:
|
||||||
receptive_to_drop = 0;
|
receptive_to_drop = 0;
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -1234,8 +1249,9 @@ Track::handle ( int m )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return Fl_Group::handle( m );
|
return Fl_Group::handle( m );
|
||||||
|
|
Loading…
Reference in New Issue