Permit removal of Track_Widgets.

This commit is contained in:
Jonathan Moore Liles 2008-02-21 01:17:49 -06:00
parent 408bf5b296
commit f5aaee31f7
4 changed files with 34 additions and 0 deletions

View File

@ -21,6 +21,8 @@
#include "Track.H" #include "Track.H"
#include <FL/Fl_Input.H>
class Audio_Track : public Track class Audio_Track : public Track
{ {
@ -28,6 +30,11 @@ public:
Audio_Track ( int X, int Y, int W, int H ) : Track( X, Y, W, H ) Audio_Track ( int X, int Y, int W, int H ) : Track( X, Y, W, H )
{ {
/* Fl_Group *o = new Fl_Group( 0, 0, 100, H ); */
/* new Fl_Input( 0, 0, 100, 24, "name:" ); */
/* o->end(); */
} }
/** event handler that supports DND of audio clips */ /** event handler that supports DND of audio clips */

View File

@ -204,6 +204,13 @@ public:
ox = x() - X; ox = x() - X;
oy = y() - Y; oy = y() - Y;
if ( Fl::event_state() & FL_CTRL &&
Fl::event_button() == 3 )
{
_track->queue_delete( this );
return 0;
}
return 1; return 1;
} }
case FL_RELEASE: case FL_RELEASE:

11
Track.C
View File

@ -25,6 +25,8 @@
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
Track_Widget * Track::_queued_widget = NULL;
static bool static bool
sort_func ( Track_Widget *lhs, Track_Widget *rhs ) sort_func ( Track_Widget *lhs, Track_Widget *rhs )
{ {
@ -163,6 +165,15 @@ Track::handle ( int m )
if ( retval && m == FL_RELEASE ) if ( retval && m == FL_RELEASE )
current_widget = NULL; current_widget = NULL;
if ( _queued_widget )
{
remove( _queued_widget );
delete _queued_widget;
_queued_widget = NULL;
current_widget = NULL;
redraw();
}
return retval; return retval;
} }
else else

View File

@ -40,6 +40,8 @@ class Track : public Fl_Group
Track *_prev; Track *_prev;
char *_name; char *_name;
static Track_Widget * _queued_widget;
protected: protected:
list <Track_Widget *> _widgets; list <Track_Widget *> _widgets;
@ -67,6 +69,13 @@ public:
void remove ( Track_Widget *r ); void remove ( Track_Widget *r );
void add ( Track_Widget *r ); void add ( Track_Widget *r );
void queue_delete ( Track_Widget *r )
{
assert( ! _queued_widget );
_queued_widget = r;
}
virtual void snap ( Track_Widget *r ); virtual void snap ( Track_Widget *r );
virtual int handle ( int m ); virtual int handle ( int m );