Don't allow transport relocation while recording.

This commit is contained in:
Jonathan Moore Liles 2009-10-27 23:03:47 -05:00
parent df344dc065
commit 5c06e9d2c8
2 changed files with 54 additions and 31 deletions

View File

@ -79,50 +79,64 @@ Transport::cb_button ( Fl_Widget *w, void *v )
} }
void void
Transport::cb_button ( Fl_Widget *w ) Transport::update_record_state ( void )
{ {
if ( w == _home_button ) Fl_Button *w = _record_button;
locate( 0 );
if ( w == _end_button ) /* handle display */
locate( timeline->length() ); if ( w->value() )
else if ( w == _play_button )
toggle();
else if ( w == _record_button )
{
if ( _record_button->value() )
w->labelcolor( FL_RED ); w->labelcolor( FL_RED );
else else
w->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) ); w->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) );
redraw(); w->redraw();
/* 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 ( rolling )
{ {
if ( _record_button->value() ) if ( w->value() )
{
timeline->record(); timeline->record();
recording = true;
}
else else
{
timeline->stop(); timeline->stop();
recording = false;
} }
} }
} }
/** cb_button
* common handler for all transport buttons */
void
Transport::cb_button ( Fl_Widget *w )
{
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 )
{
_record_button->value( ! _record_button->value() );
update_record_state();
}
bool bool
Transport::rec_enabled ( void ) const Transport::rec_enabled ( void ) const
{ {
return _record_button->value(); return _record_button->value();
} }
void
Transport::toggle_record ( void )
{
if ( _record_button->value() )
_record_button->value( 0 );
else
_record_button->value( 1 );
_record_button->do_callback();
}
int int
Transport::handle ( int m ) Transport::handle ( int m )
{ {
@ -132,7 +146,6 @@ Transport::handle ( int m )
return 0; return 0;
else else
return Fl_Pack::handle( m ); return Fl_Pack::handle( m );
} }
/***********/ /***********/
@ -152,6 +165,8 @@ Transport::poll ( void )
void void
Transport::locate ( nframes_t frame ) Transport::locate ( nframes_t frame )
{ {
if ( ! recording )
// don't allow seeking while record is in progress
jack_transport_locate( client, frame ); jack_transport_locate( client, frame );
} }
@ -161,7 +176,10 @@ Transport::start ( void )
{ {
// MESSAGE( "Starting transport" ); // MESSAGE( "Starting transport" );
if ( _record_button->value() ) if ( _record_button->value() )
timeline->record(); {
rolling = true;
update_record_state();
}
jack_transport_start( client ); jack_transport_start( client );
} }
@ -171,7 +189,10 @@ Transport::stop ( void )
{ {
// MESSAGE( "Stopping transport" ); // MESSAGE( "Stopping transport" );
if ( _record_button->value() ) if ( _record_button->value() )
toggle_record(); {
_record_button->value( 0 );
update_record_state();
}
jack_transport_stop( client ); jack_transport_stop( client );
} }

View File

@ -47,6 +47,8 @@ private:
Fl_Button *_play_button; Fl_Button *_play_button;
Fl_Button *_record_button; Fl_Button *_record_button;
void update_record_state ( void );
public: public:
Transport ( int X, int Y, int W, int H, const char *L=0 ); Transport ( int X, int Y, int W, int H, const char *L=0 );