Try to use part of FLTK's DND system for inter-track region dragging.
This commit is contained in:
parent
9a01389624
commit
e0e6cb7379
|
@ -55,18 +55,24 @@ Audio_Track::handle ( int m )
|
|||
{
|
||||
switch ( m )
|
||||
{
|
||||
|
||||
case FL_DND_DRAG:
|
||||
case FL_DND_ENTER:
|
||||
case FL_ENTER:
|
||||
// dump();
|
||||
return 1;
|
||||
case FL_DND_LEAVE:
|
||||
return Track::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 0;
|
||||
|
||||
char *file;
|
||||
|
||||
if ( ! sscanf( text, "file://%a[^\r\n]\n", &file ) )
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const char *class_name ( void ) { return "Audio_Track"; }
|
||||
|
||||
int handle ( int m );
|
||||
void dump ( void );
|
||||
void remove_selected ( void );
|
||||
|
|
|
@ -27,11 +27,14 @@ class Control_Track : public Track
|
|||
|
||||
public:
|
||||
|
||||
|
||||
Control_Track ( int X, int Y, int W, int H ) : Track( X, Y, W, H )
|
||||
{
|
||||
color( fl_darker( FL_GREEN ) );
|
||||
}
|
||||
|
||||
const char *class_name ( void ) { return "Control_Track"; }
|
||||
|
||||
void
|
||||
draw ( void )
|
||||
{
|
||||
|
|
10
Region.C
10
Region.C
|
@ -380,16 +380,14 @@ Region::handle ( int m )
|
|||
{
|
||||
if ( Y > y() + h() )
|
||||
{
|
||||
if ( _track->next() )
|
||||
if ( Y > _track->next()->y() )
|
||||
_track->next()->add( this );
|
||||
Fl::copy( class_name(), strlen( class_name() ), 0 );
|
||||
Fl::dnd();
|
||||
}
|
||||
else
|
||||
if ( Y < y() )
|
||||
{
|
||||
if ( _track->prev() )
|
||||
if ( Y < _track->prev()->y() + _track->prev()->h() )
|
||||
_track->prev()->add( this );
|
||||
Fl::copy( class_name(), strlen( class_name() ), 0 );
|
||||
Fl::dnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,17 +151,11 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
|
|||
o->type( Fl_Pack::VERTICAL );
|
||||
o->spacing( 0 );
|
||||
|
||||
Track *l = NULL;
|
||||
for ( int i = 8; i--; )
|
||||
{
|
||||
// Track_Header *t = new Track_Header( 0, 0, W, 75 );
|
||||
Track_Header *t = new Track_Header( 0, 0, W, 30 );
|
||||
Track *o = new Audio_Track( 0, 0, 1, 100 );
|
||||
o->prev( l );
|
||||
if ( l )
|
||||
l->next( o );
|
||||
l = o;
|
||||
// o->end();
|
||||
|
||||
t->track( o );
|
||||
t->add( new Audio_Track( 0, 0, 1, 100 ) );
|
||||
|
|
17
Track.C
17
Track.C
|
@ -26,6 +26,7 @@
|
|||
|
||||
|
||||
queue <Track_Widget *> Track::_delete_queue;
|
||||
Track_Widget *Track::pushed = NULL;
|
||||
|
||||
void
|
||||
Track::sort ( void )
|
||||
|
@ -240,17 +241,23 @@ done:
|
|||
int
|
||||
Track::handle ( int m )
|
||||
{
|
||||
static Track_Widget *pushed;
|
||||
// static Track_Widget *pushed;
|
||||
static Track_Widget *belowmouse;
|
||||
|
||||
switch ( m )
|
||||
{
|
||||
case FL_ENTER:
|
||||
case FL_LEAVE:
|
||||
case FL_DND_ENTER:
|
||||
printf( "enter\n" );
|
||||
if ( pushed && pushed->track()->class_name() == class_name() )
|
||||
{
|
||||
printf( "%s -> %s\n", pushed->track()->class_name(), class_name() );
|
||||
add( pushed );
|
||||
redraw();
|
||||
}
|
||||
case FL_DND_LEAVE:
|
||||
return 1;
|
||||
case FL_MOVE:
|
||||
{
|
||||
/* these aren't used, so don't bother doing lookups for them */
|
||||
Track_Widget *r = event_widget();
|
||||
|
||||
if ( r != belowmouse )
|
||||
|
@ -263,7 +270,7 @@ Track::handle ( int m )
|
|||
r->handle( FL_ENTER );
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
|
12
Track.H
12
Track.H
|
@ -38,18 +38,18 @@ class Track_Widget;
|
|||
|
||||
class Track : public Fl_Group, public Loggable
|
||||
{
|
||||
Track *_next;
|
||||
Track *_prev;
|
||||
|
||||
char *_name;
|
||||
|
||||
static queue <Track_Widget *> _delete_queue;
|
||||
static Track_Widget *pushed;
|
||||
|
||||
protected:
|
||||
|
||||
list <Track_Widget *> _widgets;
|
||||
Track_Widget *event_widget ( void );
|
||||
|
||||
const char *class_name ( void ) { return "Track"; }
|
||||
virtual const char *class_name ( void ) { return "Track"; }
|
||||
|
||||
|
||||
void set ( char ** ) { return; }
|
||||
|
@ -83,7 +83,6 @@ public:
|
|||
|
||||
Track ( int X, int Y, int W, int H ) : Fl_Group( X, Y, W, H )
|
||||
{
|
||||
_next = _prev = NULL;
|
||||
_name = NULL;
|
||||
|
||||
box( FL_DOWN_BOX );
|
||||
|
@ -102,11 +101,6 @@ public:
|
|||
log_destroy();
|
||||
}
|
||||
|
||||
Track *next ( void ) const { return _next; }
|
||||
Track *prev ( void ) const { return _prev; }
|
||||
void prev ( Track *t ) { _prev = t; }
|
||||
void next ( Track *t ) { _next = t; }
|
||||
|
||||
const char * name ( void ) const { return _name; }
|
||||
void name ( char *s ) { if ( _name ) free( _name ); _name = s; }
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ Track_Widget::handle ( int m )
|
|||
|
||||
return 1;
|
||||
case FL_DRAG:
|
||||
case FL_DND_DRAG:
|
||||
{
|
||||
if ( ! _drag )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue