From ffd4dc26a82ae6747132e1cc5f3965354857c6fd Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 23 Apr 2008 21:23:29 -0500 Subject: [PATCH] Add support for additional cursors. --- Timeline/Timeline.C | 45 +++++++++++++++++++++++++++++++++++++-------- Timeline/Timeline.H | 4 ++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index bf22110..0193daa 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -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 ); } diff --git a/Timeline/Timeline.H b/Timeline/Timeline.H index 892aa09..98720b1 100644 --- a/Timeline/Timeline.H +++ b/Timeline/Timeline.H @@ -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 );