diff --git a/Control_Point.H b/Control_Point.H index 0d2fd7b..6615c80 100644 --- a/Control_Point.H +++ b/Control_Point.H @@ -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; } + }; diff --git a/Control_Track.H b/Control_Track.H index 5ae0ae6..ba0a9a8 100644 --- a/Control_Track.H +++ b/Control_Track.H @@ -62,7 +62,7 @@ public: fl_line_style( FL_SOLID, 0 ); for ( list ::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; } }; diff --git a/Track_Point.H b/Track_Point.H index 44e2806..e024824 100644 --- a/Track_Point.H +++ b/Track_Point.H @@ -28,9 +28,9 @@ protected: char *_label; - void set ( char **a ) - { - } +/* void set ( char **a ) */ +/* { */ +/* } */ public: diff --git a/Track_Widget.H b/Track_Widget.H index b593732..57eb5de 100644 --- a/Track_Widget.H +++ b/Track_Widget.H @@ -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