Move code out of transport header. Turn off record button after recording has stopped.

This commit is contained in:
Jonathan Moore Liles 2008-06-09 21:14:43 -05:00
parent 077086e538
commit 635acb78e1
2 changed files with 108 additions and 95 deletions

View File

@ -58,7 +58,7 @@ Transport::stop ( void )
{
// MESSAGE( "Stopping transport" );
if ( _record_button->value() )
timeline->stop();
toggle_record();
jack_transport_stop( client );
}
@ -71,3 +71,104 @@ Transport::toggle ( void )
else
start();
}
/*******/
/* GUI */
/*******/
Transport::Transport ( int X, int Y, int W, int H, const char *L )
: Fl_Pack( X, Y, W, H, L )
{
recording = false;
rolling = false;
const int bw = W / 3;
type( HORIZONTAL );
Fl_Button *o;
_home_button = o = new Fl_Button( 0, 0, bw, 0, "@|<" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( FL_Home );
o->box( FL_UP_BOX );
_end_button = o = new Fl_Button( 0, 0, bw, 0, "@>|" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( FL_End );
_play_button = o = new Fl_Button( 0, 0, bw, 0, "@>" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( ' ' );
o->box( FL_UP_BOX );
_record_button = o = new Fl_Button( 0, 0, bw, 0, "@circle" );
o->type( FL_TOGGLE_BUTTON );
o->labeltype( FL_EMBOSSED_LABEL );
o->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) );
o->shortcut( 'R' );
o->callback( cb_button, this );
o->when( FL_WHEN_CHANGED );
o->box( FL_UP_BOX );
end();
}
void
Transport::cb_button ( Fl_Widget *w, void *v )
{
((Transport*)v)->cb_button( w );
}
void
Transport::cb_button ( Fl_Widget *w )
{
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 ) );
redraw();
if ( rolling )
if ( _record_button->value() )
timeline->record();
else
timeline->stop();
}
}
void
Transport::toggle_record ( void )
{
if ( _record_button->value() )
_record_button->value( 0 );
else
_record_button->value( 1 );
_record_button->do_callback();
}
int
Transport::handle ( int m )
{
/* FIXME: hack to avoid stealing focus */
if ( m == FL_FOCUS )
return 0;
else
return Fl_Pack::handle( m );
}

View File

@ -35,6 +35,9 @@ struct Transport : public jack_position_t, public Fl_Pack
private:
static void cb_button ( Fl_Widget *w, void *arg );
void cb_button ( Fl_Widget *w );
/* not permitted */
Transport ( const Transport &rhs );
Transport & operator = ( const Transport &rhs );
@ -44,104 +47,13 @@ private:
Fl_Button *_play_button;
Fl_Button *_record_button;
static
void
cb_button ( Fl_Widget *w, void *v )
{
((Transport*)v)->cb_button( w );
}
void
cb_button ( Fl_Widget *w )
{
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 ) );
redraw();
if ( rolling )
if ( _record_button->value() )
timeline->record();
else
timeline->stop();
}
}
public:
void toggle_record ( void )
{
if ( _record_button->value() )
_record_button->value( 0 );
else
_record_button->value( 1 );
_record_button->do_callback();
}
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 )
: Fl_Pack( X, Y, W, H, L )
{
recording = false;
rolling = false;
const int bw = W / 3;
type( HORIZONTAL );
Fl_Button *o;
_home_button = o = new Fl_Button( 0, 0, bw, 0, "@|<" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( FL_Home );
o->box( FL_UP_BOX );
_end_button = o = new Fl_Button( 0, 0, bw, 0, "@>|" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( FL_End );
_play_button = o = new Fl_Button( 0, 0, bw, 0, "@>" );
o->labeltype( FL_EMBOSSED_LABEL );
o->callback( cb_button, this );
o->shortcut( ' ' );
o->box( FL_UP_BOX );
_record_button = o = new Fl_Button( 0, 0, bw, 0, "@circle" );
o->type( FL_TOGGLE_BUTTON );
o->labeltype( FL_EMBOSSED_LABEL );
o->labelcolor( fl_color_average( FL_RED, FL_WHITE, 0.25f ) );
o->shortcut( 'R' );
o->callback( cb_button, this );
o->when( FL_WHEN_CHANGED );
o->box( FL_UP_BOX );
end();
}
int
handle ( int m )
{
/* FIXME: hack to avoid stealing focus */
if ( m == FL_FOCUS )
return 0;
else
return Fl_Pack::handle( m );
}
void toggle_record ( void );
int handle ( int m );
bool rolling;
bool recording;