Cleanup region mouseover.

This commit is contained in:
Jonathan Moore Liles 2008-03-08 22:19:05 -06:00
parent e0e6cb7379
commit a6e65c8159
5 changed files with 25 additions and 27 deletions

View File

@ -71,7 +71,7 @@ Audio_Track::handle ( int m )
if ( ! strcmp( text, "Region" ) )
return 0;
return 1;
char *file;

View File

@ -85,7 +85,6 @@ Region::init ( void )
_end = 0;
_scale = 1.0f;
_clip = NULL;
_current = false;
_box_color = FL_CYAN;
_color = FL_BLUE;
@ -103,7 +102,6 @@ Region::Region ( const Region & rhs )
_scale = rhs._scale;
_box_color = rhs._box_color;
_color = rhs._color;
_current = false;
log_create();
}
@ -224,12 +222,10 @@ Region::handle ( int m )
switch ( m )
{
case FL_ENTER:
_current = true;
Track_Widget::handle( m );
redraw();
break;
case FL_LEAVE:
_current = false;
Track_Widget::handle( m );
redraw();
break;
@ -476,7 +472,7 @@ Region::draw ( int X, int Y, int W, int H )
draw_label( _clip->name(), align() );
if ( _current )
if ( current() )
{
char pat[40];

View File

@ -47,8 +47,6 @@ class Region : public Track_Widget
float _scale; /* amplitude adjustment */
bool _current; /* region is receiving operations */
static Fl_Boxtype _box;
static Fl_Color _selection_color;
static Fl_Color selection_color ( void ) { return _selection_color; }
@ -153,6 +151,8 @@ protected:
init();
}
bool current ( void ) const { return this == Track::belowmouse(); }
public:
/* for loggable */

34
Track.C
View File

@ -26,7 +26,8 @@
queue <Track_Widget *> Track::_delete_queue;
Track_Widget *Track::pushed = NULL;
Track_Widget *Track::_pushed = NULL;
Track_Widget *Track::_belowmouse = NULL;
void
Track::sort ( void )
@ -241,17 +242,14 @@ done:
int
Track::handle ( int m )
{
// static Track_Widget *pushed;
static Track_Widget *belowmouse;
switch ( m )
{
case FL_DND_ENTER:
printf( "enter\n" );
if ( pushed && pushed->track()->class_name() == class_name() )
if ( pushed() && pushed()->track()->class_name() == class_name() )
{
printf( "%s -> %s\n", pushed->track()->class_name(), class_name() );
add( pushed );
add( pushed() );
redraw();
}
case FL_DND_LEAVE:
@ -260,11 +258,11 @@ Track::handle ( int m )
{
Track_Widget *r = event_widget();
if ( r != belowmouse )
if ( r != belowmouse() )
{
if ( belowmouse )
belowmouse->handle( FL_LEAVE );
belowmouse = r;
if ( belowmouse() )
belowmouse()->handle( FL_LEAVE );
_belowmouse = r;
if ( r )
r->handle( FL_ENTER );
@ -274,17 +272,17 @@ Track::handle ( int m )
}
default:
{
Track_Widget *r = pushed ? pushed : event_widget();
Track_Widget *r = pushed() ? pushed() : event_widget();
if ( r )
{
int retval = r->dispatch( m );
if ( retval && m == FL_PUSH )
pushed = r;
_pushed = r;
if ( retval && m == FL_RELEASE )
pushed = NULL;
_pushed = NULL;
Loggable::block_start();
@ -295,12 +293,12 @@ Track::handle ( int m )
_delete_queue.pop();
if ( pushed == t )
pushed = NULL;
if ( belowmouse == t )
if ( pushed() == t )
_pushed = NULL;
if ( belowmouse() == t )
{
belowmouse->handle( FL_LEAVE );
belowmouse = NULL;
belowmouse()->handle( FL_LEAVE );
_belowmouse = NULL;
}
delete t;

View File

@ -42,7 +42,8 @@ class Track : public Fl_Group, public Loggable
char *_name;
static queue <Track_Widget *> _delete_queue;
static Track_Widget *pushed;
static Track_Widget *_pushed;
static Track_Widget *_belowmouse;
protected:
@ -101,6 +102,9 @@ public:
log_destroy();
}
static Track_Widget *pushed ( void ) { return _pushed; };
static Track_Widget *belowmouse ( void ) { return _belowmouse; };
const char * name ( void ) const { return _name; }
void name ( char *s ) { if ( _name ) free( _name ); _name = s; }