From ce2b1e02edba7802daa85549ecf1561d908766be Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 21 Apr 2008 21:47:29 -0500 Subject: [PATCH] Add transport controls to the GUI. --- Timeline/Engine.C | 6 ++-- Timeline/Timeline.C | 22 ++++++++------- Timeline/Track.C | 4 +-- Timeline/Transport.C | 2 +- Timeline/Transport.H | 65 ++++++++++++++++++++++++++++++++++++++++++-- Timeline/main.C | 9 +++++- 6 files changed, 89 insertions(+), 19 deletions(-) diff --git a/Timeline/Engine.C b/Timeline/Engine.C index 09bd348..f5f378f 100644 --- a/Timeline/Engine.C +++ b/Timeline/Engine.C @@ -92,7 +92,7 @@ Engine::sync ( jack_transport_state_t state, jack_position_t *pos ) /* FIXME: what's the right thing to do here? */ // request_locate( pos->frame ); return 1; -// return transport.frame == pos->frame; +// return transport->frame == pos->frame; break; default: printf( "unknown transport state.\n" ); @@ -105,9 +105,9 @@ Engine::sync ( jack_transport_state_t state, jack_position_t *pos ) int Engine::process ( nframes_t nframes ) { - transport.poll(); + transport->poll(); - if ( ! transport.rolling ) + if ( ! transport->rolling ) /* FIXME: fill all ports with silence */ return 0; diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 7a2e9fe..04b26a7 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -561,7 +561,7 @@ Timeline::draw ( void ) void Timeline::draw_playhead ( void ) { - int x = ( ts_to_x( transport.frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width(); + int x = ( ts_to_x( transport->frame ) - ts_to_x( xoffset ) ) + tracks->x() + Track::width(); if ( x < tracks->x() + Track::width() || x > tracks->x() + tracks->w() ) return; @@ -590,10 +590,10 @@ Timeline::redraw_playhead ( void ) { static nframes_t last_playhead = -1; - if ( last_playhead != transport.frame ) + if ( last_playhead != transport->frame ) { redraw_overlay(); - last_playhead = transport.frame; + last_playhead = transport->frame; } } @@ -702,19 +702,21 @@ Timeline::handle ( int m ) return 1; } - case FL_Home: - transport.locate( 0 ); - return 1; - case ' ': - transport.toggle(); - return 1; + +/* case FL_Home: */ +/* transport->locate( 0 ); */ +/* return 1; */ +/* case ' ': */ +/* transport->toggle(); */ +/* return 1; */ + case 'p': { int X = Fl::event_x() - Track::width(); if ( X > 0 ) { - transport.locate( xoffset + x_to_ts( X ) ); + transport->locate( xoffset + x_to_ts( X ) ); } return 1; diff --git a/Timeline/Track.C b/Timeline/Track.C index 0f8e11f..ab8215f 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -62,9 +62,9 @@ Track::cb_button ( Fl_Widget *w ) { /* FIXME: wrong place for this! */ if ( record_button->value() ) - record_ds->start( transport.frame ); + record_ds->start( transport->frame ); else - record_ds->stop( transport.frame ); + record_ds->stop( transport->frame ); } else if ( w == take_menu ) diff --git a/Timeline/Transport.C b/Timeline/Transport.C index bc46c1a..fe9bcc7 100644 --- a/Timeline/Transport.C +++ b/Timeline/Transport.C @@ -20,7 +20,7 @@ #include "Transport.H" #include "Engine.H" -Transport transport; +// Transport transport; #define client engine->client() diff --git a/Timeline/Transport.H b/Timeline/Transport.H index 66c1ccc..5583957 100644 --- a/Timeline/Transport.H +++ b/Timeline/Transport.H @@ -22,8 +22,69 @@ #include #include "types.h" -struct Transport : public jack_position_t +#include +#include + +#include + +struct Transport : public jack_position_t, public Fl_Pack { + +private: + + Fl_Button *_home_button; + 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 ); + else if ( w == _play_button ) + toggle(); + else if ( w == _record_button ) + printf( "FIXME: record now\n" ); + } + +public: + + Transport ( int X, int Y, int W, int H, const char *L=0 ) + : Fl_Pack( X, Y, W, H, L ) + { + 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 ); + _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->labeltype( FL_EMBOSSED_LABEL ); + o->labelcolor( FL_RED ); + o->shortcut( 'R' ); + o->callback( cb_button, this ); + o->box( FL_UP_BOX ); + + end(); + } + bool rolling; void poll ( void ); @@ -33,4 +94,4 @@ struct Transport : public jack_position_t void toggle ( void ); }; -extern Transport transport; +extern Transport* transport; diff --git a/Timeline/main.C b/Timeline/main.C index 52f869c..72d3d24 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -47,14 +47,16 @@ #include "Time_Sequence.H" #include "Control_Sequence.H" +#include "Transport.H" + #include "Loggable.H" #include "Track.H" -// #include "const.h" #include "Engine.H" Engine *engine; Timeline *timeline; +Transport *transport; void cb_undo ( Fl_Widget *w, void *v ) { @@ -67,6 +69,7 @@ main ( int argc, char **argv ) Fl_Window *main_window = new Fl_Window( 0, 0, 1024, 768 ); Fl::visual( FL_RGB8 ); + Fl::visible_focus( 0 ); Fl::get_system_colors(); Fl::scheme( "plastic" ); @@ -83,6 +86,10 @@ main ( int argc, char **argv ) /* TODO: change to seesion dir */ + + transport = new Transport( 0, 0, 300, 24 ); + main_window->add( transport ); + /* we don't really need a pointer for this */ engine = new Engine; engine->init();