diff --git a/Timeline/Transport.C b/Timeline/Transport.C index 3890298..7d516f6 100644 --- a/Timeline/Transport.C +++ b/Timeline/Transport.C @@ -79,48 +79,62 @@ Transport::cb_button ( Fl_Widget *w, void *v ) } void -Transport::cb_button ( Fl_Widget *w ) +Transport::update_record_state ( void ) { - if ( w == _home_button ) - locate( 0 ); - if ( w == _end_button ) - locate( timeline->length() ); - else if ( w == _play_button ) - toggle(); - else if ( w == _record_button ) - { - if ( _record_button->value() ) - w->labelcolor( FL_RED ); - else - w->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) ); + Fl_Button *w = _record_button; + + /* handle display */ + if ( w->value() ) + w->labelcolor( FL_RED ); + else + w->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) ); - redraw(); + w->redraw(); - if ( rolling ) + /* this covers the case where the record toggle button is + * pressed while the transport is already rolling. Recording + * should begin or end on the next frame */ + if ( rolling ) + { + if ( w->value() ) + { + timeline->record(); + recording = true; + } + else { - if ( _record_button->value() ) - timeline->record(); - else - timeline->stop(); + timeline->stop(); + recording = false; } } } -bool -Transport::rec_enabled ( void ) const +/** cb_button + * common handler for all transport buttons */ +void +Transport::cb_button ( Fl_Widget *w ) { - return _record_button->value(); + if ( w == _home_button ) + locate( 0 ); + else if ( w == _end_button ) + locate( timeline->length() ); + else if ( w == _play_button ) + toggle(); + else if ( w == _record_button ) + update_record_state(); } void Transport::toggle_record ( void ) { - if ( _record_button->value() ) - _record_button->value( 0 ); - else - _record_button->value( 1 ); + _record_button->value( ! _record_button->value() ); + update_record_state(); +} - _record_button->do_callback(); +bool +Transport::rec_enabled ( void ) const +{ + return _record_button->value(); } int @@ -132,7 +146,6 @@ Transport::handle ( int m ) return 0; else return Fl_Pack::handle( m ); - } /***********/ @@ -152,7 +165,9 @@ Transport::poll ( void ) void Transport::locate ( nframes_t frame ) { - jack_transport_locate( client, frame ); + if ( ! recording ) + // don't allow seeking while record is in progress + jack_transport_locate( client, frame ); } @@ -161,7 +176,10 @@ Transport::start ( void ) { // MESSAGE( "Starting transport" ); if ( _record_button->value() ) - timeline->record(); + { + rolling = true; + update_record_state(); + } jack_transport_start( client ); } @@ -171,7 +189,10 @@ Transport::stop ( void ) { // MESSAGE( "Stopping transport" ); if ( _record_button->value() ) - toggle_record(); + { + _record_button->value( 0 ); + update_record_state(); + } jack_transport_stop( client ); } diff --git a/Timeline/Transport.H b/Timeline/Transport.H index e84ba83..1e33004 100644 --- a/Timeline/Transport.H +++ b/Timeline/Transport.H @@ -47,6 +47,8 @@ private: Fl_Button *_play_button; Fl_Button *_record_button; + void update_record_state ( void ); + public: Transport ( int X, int Y, int W, int H, const char *L=0 );