Browse Source

Don't allow transport relocation while recording.

tags/non-daw-v1.1.0
Jonathan Moore Liles 15 years ago
parent
commit
5c06e9d2c8
2 changed files with 54 additions and 31 deletions
  1. +52
    -31
      Timeline/Transport.C
  2. +2
    -0
      Timeline/Transport.H

+ 52
- 31
Timeline/Transport.C View File

@@ -79,48 +79,62 @@ 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 )
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 void
Transport::toggle_record ( 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 int
@@ -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 );
} }


+ 2
- 0
Timeline/Transport.H 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 );


Loading…
Cancel
Save