diff --git a/Timeline/Clock.H b/Timeline/Clock.H index 6f49e84..2896598 100644 --- a/Timeline/Clock.H +++ b/Timeline/Clock.H @@ -23,14 +23,32 @@ switched between Bar Beat Tick and Wallclock displays */ #include #include +#include #include "Timeline.H" #include "types.h" +const float CLOCK_UPDATE_FREQ = 0.05f; class Clock : public Fl_Widget { nframes_t _when; + nframes_t *_v; + + static void + update_cb ( void *v ) + { + ((Clock*)v)->update_cb(); + } + + void + update_cb ( void ) + { + Fl::repeat_timeout( CLOCK_UPDATE_FREQ, update_cb, this ); + + set( *_v ); + } + public: @@ -47,10 +65,12 @@ public: snprintf( dst, n, "%02d:%02d:%02.1f", H, M, S ); } + Clock ( int X, int Y, int W, int H, const char *L=0 ) : Fl_Widget( X, Y, W, H, L ) { _when = 0; + _v = 0; box( FL_BORDER_BOX ); type( HMS ); @@ -58,6 +78,18 @@ public: size( 170, 40 ); } + ~Clock ( ) + { + Fl::remove_timeout( update_cb ); + } + + void run ( nframes_t *v ) + { + _v = v; + + Fl::add_timeout( CLOCK_UPDATE_FREQ, update_cb, this ); + } + void set ( nframes_t frame ) { if ( _when != frame ) diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index a43fbfa..99c250e 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -236,10 +236,11 @@ Fl::scheme( "plastic" );} {} label PLAYHEAD selected xywh {139 29 137 40} box BORDER_BOX color 46 code0 {o->type( Clock::HMS );} + code1 {o->run( &transport->frame );} class Clock } Fl_Box {} { - label PLAYHEAD selected + label PLAYHEAD xywh {278 29 142 40} box BORDER_BOX color 46 code0 {o->type( Clock::BBT );} class Clock