Improve event handling for control tracks.

pull/3/head
Jonathan Moore Liles 2008-03-07 18:06:42 -06:00
parent e202523e51
commit 4de8751032
4 changed files with 40 additions and 28 deletions

View File

@ -111,8 +111,9 @@ public:
}
Control_Point ( nframes_t when, float y )
Control_Point ( Track *t, nframes_t when, float y )
{
_track = t;
_y = y;
_offset = when;
@ -135,31 +136,44 @@ public:
{
int r = Track_Widget::handle( m );
if ( m == FL_RELEASE )
switch ( m )
{
_track->sort();
timeline->redraw();
case FL_RELEASE:
_track->sort();
redraw();
break;
case FL_DRAG:
{
int Y = Fl::event_y() - parent()->y();
if ( Y >= 0 && Y < parent()->h() )
{
_y = (float)Y / parent()->h();
redraw();
}
break;
}
}
return r;
}
int
y ( void ) const
{
return _track->y() + ((float)h() * _y);
}
int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
int w ( void ) const { return 6; }
int h ( void ) const { return 6; }
void
draw_box ( int X, int Y, int W, int H )
{
// Track_Widget::draw_box( x(), y(), w(), h() );
}
/* void */
/* draw_box ( int X, int Y, int W, int H ) */
/* { */
/* } */
void
draw ( int X, int Y, int W, int H )
{
fl_color( FL_RED );
fl_draw_box( FL_UP_BOX, x(), y(), 6, 6, FL_RED );
// fl_rectf( x(), y() + ry, 6, 6 );
// fl_draw_box( box(), x(), y(), w(), h(), box_color() );
return;
}
};

View File

@ -62,7 +62,7 @@ public:
fl_line_style( FL_SOLID, 0 );
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
(*r)->draw( X, Y, W, H );
(*r)->draw_box( X, Y, W, H );
fl_pop_clip();
}
@ -72,8 +72,8 @@ public:
{
int r = Track::handle( m );
// if ( r )
// return r;
if ( r )
return r;
switch ( m )
{
@ -81,17 +81,15 @@ public:
{
if ( Fl::event_button1() )
{
Control_Point *r = new Control_Point( timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ), (float)(Fl::event_y() - y()) / h() );
Control_Point *r = new Control_Point( this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ), (float)(Fl::event_y() - y()) / h() );
add( r );
}
return 0;
return 1;
}
default:
return 0;
}
return r;
}
};

View File

@ -28,9 +28,9 @@ protected:
char *_label;
void set ( char **a )
{
}
/* void set ( char **a ) */
/* { */
/* } */
public:

View File

@ -145,7 +145,7 @@ public:
nframes_t scroll_ts ( void ) const { return timeline->xoffset; }
virtual int y ( void ) const { return _track->y(); }
int h ( void ) const { return _track->h(); }
virtual int h ( void ) const { return _track->h(); }
int x ( void ) const { return _offset < timeline->xoffset ? _track->x() - 1 : min( 32767, _track->x() + timeline->ts_to_x( _offset - timeline->xoffset ) ); }
virtual int w ( void ) const