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

@ -78,32 +78,57 @@ Transport::cb_button ( Fl_Widget *w, void *v )
((Transport*)v)->cb_button( w ); ((Transport*)v)->cb_button( w );
} }
void
Transport::update_record_state ( void )
{
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 ) );
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 ( w->value() )
{
timeline->record();
recording = true;
}
else
{
timeline->stop();
recording = false;
}
}
}
/** cb_button
* common handler for all transport buttons */
void void
Transport::cb_button ( Fl_Widget *w ) Transport::cb_button ( Fl_Widget *w )
{ {
if ( w == _home_button ) if ( w == _home_button )
locate( 0 ); locate( 0 );
if ( w == _end_button ) else if ( w == _end_button )
locate( timeline->length() ); locate( timeline->length() );
else if ( w == _play_button ) else if ( w == _play_button )
toggle(); toggle();
else if ( w == _record_button ) else if ( w == _record_button )
{ update_record_state();
if ( _record_button->value() ) }
w->labelcolor( FL_RED );
else
w->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) );
redraw(); void
Transport::toggle_record ( void )
if ( rolling ) {
{ _record_button->value( ! _record_button->value() );
if ( _record_button->value() ) update_record_state();
timeline->record();
else
timeline->stop();
}
}
} }
bool bool
@ -112,17 +137,6 @@ 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,7 +165,9 @@ Transport::poll ( void )
void void
Transport::locate ( nframes_t frame ) 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" ); // 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 );