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; _y = y;
_offset = when; _offset = when;
@ -135,31 +136,44 @@ public:
{ {
int r = Track_Widget::handle( m ); 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; return r;
} }
int int y ( void ) const { return parent()->y() + ((float)parent()->h() * _y); }
y ( void ) const int w ( void ) const { return 6; }
{ int h ( void ) const { return 6; }
return _track->y() + ((float)h() * _y);
}
void /* void */
draw_box ( int X, int Y, int W, int H ) /* draw_box ( int X, int Y, int W, int H ) */
{ /* { */
// Track_Widget::draw_box( x(), y(), w(), h() ); /* } */
}
void void
draw ( int X, int Y, int W, int H ) 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_draw_box( box(), x(), y(), w(), h(), box_color() );
// fl_rectf( x(), y() + ry, 6, 6 ); return;
} }
}; };

View File

@ -62,7 +62,7 @@ public:
fl_line_style( FL_SOLID, 0 ); fl_line_style( FL_SOLID, 0 );
for ( list <Track_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ ) 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(); fl_pop_clip();
} }
@ -72,8 +72,8 @@ public:
{ {
int r = Track::handle( m ); int r = Track::handle( m );
// if ( r ) if ( r )
// return r; return r;
switch ( m ) switch ( m )
{ {
@ -81,17 +81,15 @@ public:
{ {
if ( Fl::event_button1() ) 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 ); add( r );
} }
return 0; return 1;
} }
default: default:
return 0; return 0;
} }
return r;
} }
}; };

View File

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

View File

@ -145,7 +145,7 @@ public:
nframes_t scroll_ts ( void ) const { return timeline->xoffset; } nframes_t scroll_ts ( void ) const { return timeline->xoffset; }
virtual int y ( void ) const { return _track->y(); } 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 ) ); } 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 virtual int w ( void ) const