Browse Source

Improve event handling for control tracks.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
4de8751032
4 changed files with 40 additions and 28 deletions
  1. +31
    -17
      Control_Point.H
  2. +5
    -7
      Control_Track.H
  3. +3
    -3
      Track_Point.H
  4. +1
    -1
      Track_Widget.H

+ 31
- 17
Control_Point.H 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
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 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_rectf( x(), y() + ry, 6, 6 );
// fl_draw_box( box(), x(), y(), w(), h(), box_color() );
return;
} }

}; };

+ 5
- 7
Control_Track.H 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 )
// return r;
if ( 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;
} }
}; };

+ 3
- 3
Track_Point.H View File

@@ -28,9 +28,9 @@ protected:


char *_label; char *_label;


void set ( char **a )
{
}
/* void set ( char **a ) */
/* { */
/* } */


public: public:




+ 1
- 1
Track_Widget.H 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


Loading…
Cancel
Save