From 63ebacb872f78b260da73a57dde4e78d65d50f6c Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Fri, 25 Apr 2008 01:34:08 -0500 Subject: [PATCH] Massive consting. --- Timeline/Audio_Sequence.H | 5 ++--- Timeline/Control_Point.H | 10 ++++------ Timeline/Control_Sequence.C | 2 +- Timeline/Control_Sequence.H | 4 ++-- Timeline/Loggable.C | 12 +++++++----- Timeline/Loggable.H | 31 ++++++++++++++++++------------- Timeline/Region.H | 5 ++--- Timeline/Ruler_Point.H | 5 ++--- Timeline/Sequence.H | 6 ++++-- Timeline/Sequence_Point.H | 2 +- Timeline/Sequence_Widget.H | 8 +++++--- Timeline/TLE.fl | 27 +++++++++++++++++++++++++-- Timeline/Tempo_Point.C | 2 +- Timeline/Tempo_Point.H | 4 ++-- Timeline/Time_Point.C | 2 +- Timeline/Time_Point.H | 4 ++-- Timeline/Timeline.C | 33 +++++++++++++++++++++++++++++++++ Timeline/Timeline.H | 4 ++++ Timeline/Track.C | 6 ------ Timeline/Track.H | 7 +++---- Timeline/Transport.C | 7 +++++++ Timeline/Transport.H | 9 ++++++++- 22 files changed, 134 insertions(+), 61 deletions(-) diff --git a/Timeline/Audio_Sequence.H b/Timeline/Audio_Sequence.H index 69222c6..e1c661f 100644 --- a/Timeline/Audio_Sequence.H +++ b/Timeline/Audio_Sequence.H @@ -30,8 +30,7 @@ class Audio_Sequence : public Sequence protected: - void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { Sequence::get( e ); @@ -100,7 +99,7 @@ public: return t; } - const char *class_name ( void ) { return "Audio_Sequence"; } +// const char *class_name ( void ) { return "Audio_Sequence"; } int handle ( int m ); void dump ( void ); diff --git a/Timeline/Control_Point.H b/Timeline/Control_Point.H index 2cba959..af7dc32 100644 --- a/Timeline/Control_Point.H +++ b/Timeline/Control_Point.H @@ -36,10 +36,9 @@ class Control_Point : public Sequence_Point protected: - const char *class_name ( void ) { return "Control_Point"; } +// const char *class_name ( void ) { return "Control_Point"; } - void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { Sequence_Point::get( e ); @@ -68,7 +67,7 @@ protected: Control_Point ( ) { - + _box_color = FL_WHITE; } public: @@ -87,8 +86,7 @@ public: _track = t; _y = y; _r->offset = when; - -// _make_label(); + _box_color = FL_WHITE; log_create(); } diff --git a/Timeline/Control_Sequence.C b/Timeline/Control_Sequence.C index 724c2a3..7abcb5a 100644 --- a/Timeline/Control_Sequence.C +++ b/Timeline/Control_Sequence.C @@ -52,7 +52,7 @@ Control_Sequence::init ( void ) } void -Control_Sequence::get ( Log_Entry &e ) +Control_Sequence::get ( Log_Entry &e ) const { Sequence::get( e ); diff --git a/Timeline/Control_Sequence.H b/Timeline/Control_Sequence.H index ef0bd19..a0033a7 100644 --- a/Timeline/Control_Sequence.H +++ b/Timeline/Control_Sequence.H @@ -32,7 +32,7 @@ class Control_Sequence : public Sequence protected: - void get ( Log_Entry &e ); + virtual void get ( Log_Entry &e ) const; void set ( Log_Entry &e ); Control_Sequence ( ) : Sequence( 0, 0, 0, 1 ) @@ -55,7 +55,7 @@ public: Control_Sequence ( Track * ); ~Control_Sequence ( ); - const char *class_name ( void ) { return "Control_Sequence"; } +// const char *class_name ( void ) { return "Control_Sequence"; } void draw ( void ); int handle ( int m ); diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index b6a6df8..5f0e0cf 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -341,8 +341,10 @@ Loggable::snapshot( FILE *fp ) for ( int i = 0; i < _log_id; ++i ) { - if ( _class_map[ string( _loggables[ i ]->class_name() ) ] ) - _loggables[ i ]->log_create(); + const Loggable * l = _loggables[ i ]; + + if ( l && _class_map[ string( l->class_name() ) ] ) + l->log_create(); } _fp = ofp; @@ -428,7 +430,7 @@ Loggable::flush ( void ) } void -Loggable::log_print( char **o, char **n ) +Loggable::log_print( char **o, char **n ) const { if ( n ) for ( ; *n; n++ ) @@ -533,7 +535,7 @@ Loggable::log_end ( void ) } void -Loggable::log_create ( void ) +Loggable::log_create ( void ) const { // indent(); log( "%s 0x%X create ", class_name(), _id ); @@ -559,7 +561,7 @@ Loggable::log_create ( void ) } void -Loggable::log_destroy ( void ) +Loggable::log_destroy ( void ) const { // indent(); log( "%s 0x%X destroy (nothing) << ", class_name(), _id ); diff --git a/Timeline/Loggable.H b/Timeline/Loggable.H index 890d2b4..389cf34 100644 --- a/Timeline/Loggable.H +++ b/Timeline/Loggable.H @@ -42,14 +42,18 @@ typedef Loggable *(create_func)(Log_Entry &); #define LOG_REGISTER_CREATE( class ) \ Loggable::register_create( #class, & class ::create ); -#define LOG_CREATE_FUNC( class ) \ - static Loggable * \ - create ( Log_Entry &e ) \ - { \ - class *r = new class; \ - r->set( e ); \ - return (Loggable *)r; \ - } \ +#define LOG_NAME_FUNC( class ) \ + virtual const char *class_name ( void ) const { return #class ; } + +#define LOG_CREATE_FUNC( class ) \ + static Loggable * \ + create ( Log_Entry &e ) \ + { \ + class *r = new class; \ + r->set( e ); \ + return (Loggable *)r; \ + } \ + LOG_NAME_FUNC( class ); \ class Logger; @@ -76,7 +80,7 @@ private: int _nest; - void log_print( char **o, char **n ); + void log_print( char **o, char **n ) const; static void log ( const char *fmt, ... ); static void flush ( void ); @@ -171,8 +175,7 @@ public: } /* log messages for journal */ - virtual const char *class_name ( void ) = 0; - virtual void get ( Log_Entry &e ) = 0; + virtual void get ( Log_Entry &e ) const = 0; virtual void set ( Log_Entry &e ) = 0; static bool do_this ( const char *s, bool reverse ); @@ -181,11 +184,13 @@ protected: void log_start ( void ); void log_end ( void ); - void log_create ( void ); - void log_destroy ( void ); + void log_create ( void ) const; + void log_destroy ( void ) const; public: + virtual const char *class_name ( void ) const = 0; + int id ( void ) { return _id; } diff --git a/Timeline/Region.H b/Timeline/Region.H index 5378a3d..e100ca4 100644 --- a/Timeline/Region.H +++ b/Timeline/Region.H @@ -102,10 +102,9 @@ private: protected: - const char *class_name ( void ) { return "Region"; } +// const char *class_name ( void ) { return "Region"; } - void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { e.add( ":source", _clip ? _clip->name() : "" ); e.add( ":gain", _scale ); diff --git a/Timeline/Ruler_Point.H b/Timeline/Ruler_Point.H index 8224222..2480c26 100644 --- a/Timeline/Ruler_Point.H +++ b/Timeline/Ruler_Point.H @@ -37,10 +37,9 @@ public: protected: - const char *class_name ( void ) { return "Ruler_Point"; } +// const char *class_name ( void ) { return "Ruler_Point"; } - void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { Sequence_Point::get( e ); diff --git a/Timeline/Sequence.H b/Timeline/Sequence.H index ee12839..9eb7f82 100644 --- a/Timeline/Sequence.H +++ b/Timeline/Sequence.H @@ -54,7 +54,7 @@ protected: std::list _widgets; Sequence_Widget *event_widget ( void ); - virtual const char *class_name ( void ) { return "Sequence"; } +// virtual const char *class_name ( void ) { return "Sequence"; } virtual void set ( Log_Entry &e ) @@ -72,7 +72,7 @@ protected: } } - virtual void get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { e.add( ":n", name() ); // e.add( ":t", _track ); @@ -91,6 +91,8 @@ protected: public: + LOG_NAME_FUNC( Sequence ); + Sequence ( int X, int Y, int W, int H, Track *track=0 ); virtual ~Sequence ( ); diff --git a/Timeline/Sequence_Point.H b/Timeline/Sequence_Point.H index 5f064a1..383c4c3 100644 --- a/Timeline/Sequence_Point.H +++ b/Timeline/Sequence_Point.H @@ -28,7 +28,7 @@ protected: char *_label; - virtual void get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { e.add( ":x", _r->offset ); e.add( ":t", _track ); diff --git a/Timeline/Sequence_Widget.H b/Timeline/Sequence_Widget.H index 301287c..ffe4efd 100644 --- a/Timeline/Sequence_Widget.H +++ b/Timeline/Sequence_Widget.H @@ -77,8 +77,7 @@ protected: Drag *_drag; - virtual void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { e.add( ":x", _r->offset ); e.add( ":l", _r->start ); @@ -139,6 +138,9 @@ public: _r->offset = _r->start = _r->end = 0; _drag = NULL; + + _box_color = FL_BACKGROUND_COLOR; + _color = FL_FOREGROUND_COLOR; } virtual ~Sequence_Widget ( ) @@ -173,7 +175,7 @@ public: virtual Sequence_Widget *clone ( const Sequence_Widget *r ) = 0; - bool selected ( void ) + bool selected ( void ) const { return ::find( _selection.begin(), _selection.end(), this ) != _selection.end(); } diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index 84083d7..0812be0 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -120,6 +120,7 @@ exit( 0 );} } MenuItem {} { label Undo + callback {Loggable::undo();} selected xywh {0 0 40 25} shortcut 0x4007a } } @@ -191,8 +192,30 @@ exit( 0 );} } } } + Submenu timeline_menu { + label {&Timeline} open + xywh {0 0 74 25} + } { + Submenu {} { + label {&Snap} open + xywh {0 0 74 25} + } { + MenuItem {} { + label Bars + xywh {0 0 40 25} type Radio value 1 + } + MenuItem {} { + label Beats + xywh {10 10 40 25} type Radio + } + MenuItem {} { + label Off + xywh {20 20 40 25} type Radio + } + } + } Submenu options_menu { - label {&Options} open + label {&Options} xywh {0 0 74 25} divider } { Submenu {} { @@ -350,7 +373,7 @@ Fl::scheme( Fl::scheme() );} class Clock } Fl_Box {} { - label PLAYHEAD selected + label PLAYHEAD xywh {325 29 142 40} box BORDER_BOX color 46 code0 {o->type( Clock::BBT );} code1 {o->run( &transport->frame );} diff --git a/Timeline/Tempo_Point.C b/Timeline/Tempo_Point.C index 94fb0ae..dab9bb7 100644 --- a/Timeline/Tempo_Point.C +++ b/Timeline/Tempo_Point.C @@ -23,7 +23,7 @@ #include "Timeline.H" // for timeline->tempo_track void -Tempo_Point::get ( Log_Entry &e ) +Tempo_Point::get ( Log_Entry &e ) const { e.add( ":x", _r->offset ); e.add( ":tempo", _tempo ); diff --git a/Timeline/Tempo_Point.H b/Timeline/Tempo_Point.H index 3788e08..7b8968f 100644 --- a/Timeline/Tempo_Point.H +++ b/Timeline/Tempo_Point.H @@ -37,9 +37,9 @@ class Tempo_Point : public Sequence_Point protected: - const char *class_name ( void ) { return "Tempo_Point"; } +// const char *class_name ( void ) { return "Tempo_Point"; } - void get ( Log_Entry &e ); + virtual void get ( Log_Entry &e ) const; void set ( Log_Entry &e ); Tempo_Point ( ) diff --git a/Timeline/Time_Point.C b/Timeline/Time_Point.C index 186ca36..8abd59b 100644 --- a/Timeline/Time_Point.C +++ b/Timeline/Time_Point.C @@ -22,7 +22,7 @@ #include "Timeline.H" // for timeline->time_track void -Time_Point::get ( Log_Entry &e ) +Time_Point::get ( Log_Entry &e ) const { e.add( ":x", _r->offset ); e.add( ":beats_per_bar", _time.beats_per_bar ); diff --git a/Timeline/Time_Point.H b/Timeline/Time_Point.H index 49d32fd..5c5e807 100644 --- a/Timeline/Time_Point.H +++ b/Timeline/Time_Point.H @@ -63,9 +63,9 @@ class Time_Point : public Sequence_Point protected: - const char *class_name ( void ) { return "Time_Point"; } +// const char *class_name ( void ) { return "Time_Point"; } - void get ( Log_Entry &e ); + virtual void get ( Log_Entry &e ) const; void set ( Log_Entry &e ); diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 3ae09de..3923435 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -929,6 +929,39 @@ Timeline::remove_track ( Track *track ) redraw(); } +/** Initiate recording for all armed tracks */ +bool +Timeline::record ( void ) +{ + for ( int i = tracks->children(); i-- ; ) + { + Track *t = (Track*)tracks->child( i ); + + if ( t->armed() && t->record_ds ) + t->record_ds->start( transport->frame ); + } + + deactivate(); + + return true; +} + +/** stop recording for all armed tracks */ +void +Timeline::stop ( void ) +{ + for ( int i = tracks->children(); i-- ; ) + { + Track *t = (Track*)tracks->child( i ); + + if ( t->armed() && t->record_ds ) + t->record_ds->stop( transport->frame ); + } + + activate(); +} + + /**********/ /* Engine */ /**********/ diff --git a/Timeline/Timeline.H b/Timeline/Timeline.H index bf1b69e..0304f24 100644 --- a/Timeline/Timeline.H +++ b/Timeline/Timeline.H @@ -160,6 +160,10 @@ public: int total_input_buffer_percent ( void ); int total_output_buffer_percent ( void ); + + bool record ( void ); + void stop ( void ); + void zoom ( float secs ); void zoom_in ( void ); void zoom_out ( void ); diff --git a/Timeline/Track.C b/Timeline/Track.C index 35ea7fb..daf8f7d 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -62,12 +62,6 @@ Track::cb_button ( Fl_Widget *w ) if ( w == record_button ) { -/* /\* FIXME: wrong place for this! *\/ */ -/* if ( record_button->value() ) */ -/* record_ds->start( transport->frame ); */ -/* else */ -/* record_ds->stop( transport->frame ); */ - } if ( w == mute_button ) { diff --git a/Timeline/Track.H b/Timeline/Track.H index 8058e71..ab3e103 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -109,7 +109,7 @@ public: Playback_DS *playback_ds; Record_DS *record_ds; - const char *class_name ( void ) { return "Track"; } +// const char *class_name ( void ) { return "Track"; } void set ( Log_Entry &e ) @@ -160,8 +160,7 @@ public: } - void - get ( Log_Entry &e ) + virtual void get ( Log_Entry &e ) const { e.add( ":n", _name ); e.add( ":t", track() ); @@ -225,7 +224,7 @@ public: static int width ( void ) { return 150; } void track( Sequence * t ); - Sequence * track ( void ) { return _track; } + Sequence * track ( void ) const { return _track; } void draw ( void ); int handle ( int m ); diff --git a/Timeline/Transport.C b/Timeline/Transport.C index fe9bcc7..9f33bf1 100644 --- a/Timeline/Transport.C +++ b/Timeline/Transport.C @@ -46,6 +46,10 @@ Transport::start ( void ) { // MESSAGE( "Starting transport" ); jack_transport_start( client ); + + if ( _record_button->value() ) + timeline->record(); + } void @@ -53,6 +57,9 @@ Transport::stop ( void ) { // MESSAGE( "Stopping transport" ); jack_transport_stop( client ); + + if ( _record_button->value() ) + timeline->stop(); } void diff --git a/Timeline/Transport.H b/Timeline/Transport.H index 2a720e3..b550d81 100644 --- a/Timeline/Transport.H +++ b/Timeline/Transport.H @@ -56,7 +56,13 @@ private: else if ( w == _play_button ) toggle(); else if ( w == _record_button ) - printf( "FIXME: record now\n" ); + { + if ( rolling ) + if ( _record_button->value() ) + timeline->record(); + else + timeline->stop(); + } } public: @@ -88,6 +94,7 @@ public: 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_RED ); o->shortcut( 'R' );