Begin generalizing track class as base class.
This commit is contained in:
parent
825d16c5b7
commit
9321a19a5d
38
Track.C
38
Track.C
|
@ -35,7 +35,7 @@ sort_func ( Track_Widget *lhs, Track_Widget *rhs )
|
||||||
void
|
void
|
||||||
Track::sort ( void )
|
Track::sort ( void )
|
||||||
{
|
{
|
||||||
_regions.sort( sort_func );
|
_widgets.sort( sort_func );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -47,29 +47,29 @@ Track::draw ( void )
|
||||||
|
|
||||||
fl_push_clip( x(), y(), w(), h() );
|
fl_push_clip( x(), y(), w(), h() );
|
||||||
|
|
||||||
for ( list <Track_Widget *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
(*r)->draw_box( x(), y(), w(), h() );
|
(*r)->draw_box( x(), y(), w(), h() );
|
||||||
|
|
||||||
/* TODO: detect overlap and draw with transparency/crossfade */
|
/* TODO: detect overlap and draw with transparency/crossfade */
|
||||||
for ( list <Track_Widget *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
(*r)->draw( x(), y(), w(), h() );
|
(*r)->draw( x(), y(), w(), h() );
|
||||||
|
|
||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::remove_region ( Track_Widget *r )
|
Track::remove ( Track_Widget *r )
|
||||||
{
|
{
|
||||||
_regions.remove( r );
|
_widgets.remove( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Track_Widget *
|
Track_Widget *
|
||||||
Track::event_region ( void )
|
Track::event_widget ( void )
|
||||||
{
|
{
|
||||||
// FIXME: doesn't handle overlap!
|
// FIXME: doesn't handle overlap!
|
||||||
int ets = timeline.xoffset + timeline.x_to_ts( Fl::event_x() );
|
int ets = timeline.xoffset + timeline.x_to_ts( Fl::event_x() );
|
||||||
for ( list <Track_Widget *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
for ( list <Track_Widget *>::iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
||||||
if ( ets > (*r)->offset() && ets < (*r)->offset() + (*r)->length() )
|
if ( ets > (*r)->offset() && ets < (*r)->offset() + (*r)->length() )
|
||||||
return (*r);
|
return (*r);
|
||||||
|
|
||||||
|
@ -81,19 +81,13 @@ Track::add ( Track_Widget *r )
|
||||||
{
|
{
|
||||||
if ( r->track() )
|
if ( r->track() )
|
||||||
{
|
{
|
||||||
r->track()->remove_region( r );
|
r->track()->remove( r );
|
||||||
r->track()->redraw();
|
r->track()->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
_regions.push_back( r );
|
_widgets.push_back( r );
|
||||||
|
|
||||||
r->track( this );
|
r->track( this );
|
||||||
|
|
||||||
// Fl_Group::add( r );
|
|
||||||
// add( r );
|
|
||||||
|
|
||||||
// r->position( r->x(), y() );
|
|
||||||
// r->redraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* snap /r/ to nearest edge */
|
/* snap /r/ to nearest edge */
|
||||||
|
@ -105,7 +99,7 @@ Track::snap ( Track_Widget *r )
|
||||||
int rx1 = r->x();
|
int rx1 = r->x();
|
||||||
int rx2 = r->x() + r->w();
|
int rx2 = r->x() + r->w();
|
||||||
|
|
||||||
for ( list <Track_Widget*>::iterator i = _regions.begin(); i != _regions.end(); i++ )
|
for ( list <Track_Widget*>::iterator i = _widgets.begin(); i != _widgets.end(); i++ )
|
||||||
{
|
{
|
||||||
const Track_Widget *w = (*i);
|
const Track_Widget *w = (*i);
|
||||||
|
|
||||||
|
@ -146,7 +140,7 @@ done:
|
||||||
int
|
int
|
||||||
Track::handle ( int m )
|
Track::handle ( int m )
|
||||||
{
|
{
|
||||||
static Track_Widget *current_region;
|
static Track_Widget *current_widget;
|
||||||
|
|
||||||
switch ( m )
|
switch ( m )
|
||||||
{
|
{
|
||||||
|
@ -195,19 +189,19 @@ Track::handle ( int m )
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Track_Widget *r = event_region();
|
Track_Widget *r = event_widget();
|
||||||
if ( current_region )
|
if ( current_widget )
|
||||||
r = current_region;
|
r = current_widget;
|
||||||
|
|
||||||
if ( r )
|
if ( r )
|
||||||
{
|
{
|
||||||
int retval = r->handle( m );
|
int retval = r->handle( m );
|
||||||
|
|
||||||
if ( retval && m == FL_PUSH )
|
if ( retval && m == FL_PUSH )
|
||||||
current_region = r;
|
current_widget = r;
|
||||||
|
|
||||||
if ( retval && m == FL_RELEASE )
|
if ( retval && m == FL_RELEASE )
|
||||||
current_region = NULL;
|
current_widget = NULL;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
10
Track.H
10
Track.H
|
@ -39,11 +39,11 @@ class Track : public Fl_Group
|
||||||
Track *_next;
|
Track *_next;
|
||||||
Track *_prev;
|
Track *_prev;
|
||||||
|
|
||||||
list <Track_Widget *> _regions;
|
list <Track_Widget *> _widgets;
|
||||||
|
|
||||||
char *_name;
|
char *_name;
|
||||||
|
|
||||||
Track_Widget *event_region ( void );
|
Track_Widget *event_widget ( void );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ public:
|
||||||
color( fl_darker( FL_GRAY ) );
|
color( fl_darker( FL_GRAY ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Track *next ( void ) { return _next; }
|
Track *next ( void ) const { return _next; }
|
||||||
Track *prev ( void ) { return _prev; }
|
Track *prev ( void ) const { return _prev; }
|
||||||
void prev ( Track *t ) { _prev = t; }
|
void prev ( Track *t ) { _prev = t; }
|
||||||
void next ( Track *t ) { _next = t; }
|
void next ( Track *t ) { _next = t; }
|
||||||
|
|
||||||
|
|
||||||
void draw ( void );
|
void draw ( void );
|
||||||
void remove_region ( Track_Widget *r );
|
void remove ( Track_Widget *r );
|
||||||
void add ( Track_Widget *r );
|
void add ( Track_Widget *r );
|
||||||
void snap ( Track_Widget *r );
|
void snap ( Track_Widget *r );
|
||||||
int handle ( int m );
|
int handle ( int m );
|
||||||
|
|
Loading…
Reference in New Issue