Add support for additional cursors.

This commit is contained in:
Jonathan Moore Liles 2008-04-23 21:23:29 -05:00
parent b609a6f727
commit ffd4dc26a8
2 changed files with 41 additions and 8 deletions

View File

@ -526,26 +526,23 @@ Timeline::draw ( void )
}
void
Timeline::draw_playhead ( void )
Timeline::draw_cursor ( nframes_t frame, Fl_Color color )
{
int x = ( ts_to_x( transport->frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width();
int x = ( ts_to_x( frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width();
if ( x < tracks->x() + Track::width() || x > tracks->x() + tracks->w() )
return;
fl_color( FL_RED );
fl_color( color );
int y = rulers->y() + rulers->h();
int h = this->h() - hscroll->h();
fl_push_clip( Track::width(), y, tracks->w(), h );
// fl_rectf( x - 2, y, 5, 2 );
fl_line( x, y, x, h );
fl_color( fl_darker( FL_RED ) );
fl_color( fl_darker( color ) );
fl_line( x - 1, y, x - 1, h );
@ -554,7 +551,7 @@ Timeline::draw_playhead ( void )
fl_line( x + 1, y, x + 1, h );
/* draw cap */
fl_color( FL_RED );
fl_color( color );
fl_begin_polygon();
fl_vertex( x - 8, y );
@ -575,6 +572,16 @@ Timeline::draw_playhead ( void )
fl_end_line();
fl_pop_clip();
}
void
Timeline::draw_playhead ( void )
{
draw_cursor( p1, FL_BLUE );
draw_cursor( p2, FL_GREEN );
draw_cursor( transport->frame, FL_RED );
}
void
@ -713,6 +720,28 @@ Timeline::handle ( int m )
return 1;
}
case '[':
{
int X = Fl::event_x() - Track::width();
if ( X > 0 )
{
p1 = xoffset + x_to_ts( X );
}
return 1;
}
case ']':
{
int X = Fl::event_x() - Track::width();
if ( X > 0 )
{
p2 = xoffset + x_to_ts( X );
}
return 1;
}
default:
return Fl_Overlay_Window::handle( m );
}

View File

@ -111,6 +111,9 @@ class Timeline : public Fl_Overlay_Window, public RWLock
nframes_t _length;
nframes_t p1, p2; /* cursors */
public:
Tempo_Sequence *tempo_track;
@ -141,6 +144,7 @@ public:
void xposition ( int X );
void yposition ( int Y );
void draw_cursor ( nframes_t frame, Fl_Color color );
void draw_playhead ( void );
void redraw_playhead ( void );
void resize ( int X, int Y, int W, int H );