diff --git a/Timeline.C b/Timeline.C index a5faf67..96628fd 100644 --- a/Timeline.C +++ b/Timeline.C @@ -163,8 +163,13 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi l = o; // o->end(); - t->track( o ); + t->add( o ); + t->add( new Control_Track( 0, 0, 1, 100 ) ); + t->show_all_takes(); + t->color( (Fl_Color)rand() ); + + } { diff --git a/Track.H b/Track.H index 3b171f1..12fc30e 100644 --- a/Track.H +++ b/Track.H @@ -107,6 +107,9 @@ public: void prev ( Track *t ) { _prev = t; } void next ( Track *t ) { _next = t; } + const char * name ( void ) const { return _name; } + void name ( char *s ) { if ( _name ) free( _name ); _name = s; } + void sort ( void ); void remove ( Track_Widget *r ); diff --git a/Track_Header.C b/Track_Header.C index 2a86fd3..0a761ef 100644 --- a/Track_Header.C +++ b/Track_Header.C @@ -55,6 +55,24 @@ Track_Header::cb_button ( Fl_Widget *w ) } + else + if ( w == take_menu ) + { + printf( "%d\n", take_menu->value() ); + + const char *s = take_menu->menu()[ take_menu->value() ].text; + + for ( int i = takes->children(); i--; ) + { + Track *t = (Track*)takes->child( i ); + if ( ! strcmp( s, t->name() ) ) + { + track( t ); + redraw(); + break; + } + } + } } @@ -62,10 +80,9 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) : Fl_Group ( X, Y, W, H, L ) { - _name = NULL; - _track = NULL; _selected = false; + _show_all_takes = false; _size = 1; Fl_Group::size( w(), height() ); @@ -122,6 +139,7 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) : o->box( FL_THIN_UP_BOX ); o->color( FL_LIGHT1 ); o->align( FL_ALIGN_LEFT | FL_ALIGN_INSIDE ); + o->callback( cb_button, this ); } o->end(); } @@ -162,8 +180,6 @@ Track_Header::width() void Track_Header::track( Track * t ) { - _track = t; - - t->size( 1, takes->h() ); - takes->add( t ); + t->size( 1, h() ); + takes->insert( *t, 0 ); } diff --git a/Track_Header.H b/Track_Header.H index d7b2faf..00ad7a5 100644 --- a/Track_Header.H +++ b/Track_Header.H @@ -40,12 +40,14 @@ public: private: - Track * _track; +// Track * _track; char *_name; bool _selected; + bool _show_all_takes; + int _size; enum { AUDIO } _type; @@ -102,7 +104,7 @@ public: assert( t ); - _track = t; + track( t ); } @@ -120,7 +122,7 @@ public: int i = 0; asprintf( &sa[ i++ ], ":name \"%s\"", _name ? _name : "" ); - asprintf( &sa[ i++ ], ":track 0x%X", _track ? _track->id() : 0 ); + asprintf( &sa[ i++ ], ":track 0x%X", track() ? track()->id() : 0 ); asprintf( &sa[ i++ ], ":selected %d", _selected ); /* asprintf( &sa[ i++ ], ":record %d", record_button->value() ); */ /* asprintf( &sa[ i++ ], ":solo %d", solo_button->value() ); */ @@ -172,9 +174,17 @@ public: return; _size = v; - Fl_Group::size( w(), height() ); - if ( _track ) - _track->size( _track->w(), height() ); + + + for ( int i = takes->children(); i--; ) + { + takes->child( i )->size( w(), height() ); + } + + if ( _show_all_takes ) + Fl_Group::size( w(), height() * takes->children() ); + else + Fl_Group::size( w(), height() ); if ( _size == 0 ) controls->hide(); @@ -191,6 +201,8 @@ public: return table[ _size ]; } + void show_all_takes ( void ) { Fl_Group::size( w(), height() * takes->children() ); _show_all_takes = true; } + const char * name ( void ) const { return _name; } bool mute ( void ) const { return mute_button->value(); } bool solo ( void ) const { return solo_button->value(); } @@ -206,7 +218,22 @@ public: static int width(); void track( Track * t ); - Track * track ( void ) { return _track; } + Track * track ( void ) { return (Track*)takes->child( 0 ); } + + void add ( Track * t ) + { + takes->add( t ); + char pat[20]; + snprintf( pat, sizeof( pat ), "%d", takes->children() ); + t->name( strdup( pat ) ); + take_menu->add( t->name() ); + } + + void remote ( Track *t ) + { + takes->remove( t ); +// take_menu->remove( t->name() ); + } int handle ( int m ) { diff --git a/Waveform.C b/Waveform.C index d92e7ca..e223d0a 100644 --- a/Waveform.C +++ b/Waveform.C @@ -29,6 +29,9 @@ #include +const bool outline = true; +const bool vary_color = true; + /** draw a portion of /clip/'s waveform. coordinates are the portion to draw */ void draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color ) @@ -57,8 +60,10 @@ draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chann p.max *= _scale; p.min *= _scale; - // FIXME: cache this stuff. - fl_color( fl_color_average( FL_RED, color, fabs( p.max - p.min ) - 1.0 ) ); + if ( vary_color ) + fl_color( fl_color_average( FL_RED, color, fabs( p.max - p.min ) - 1.0 ) ); + else + fl_color( color ); if ( p.min < -1.0 || p.max > 1.0 ) fl_color( FL_RED ); @@ -67,39 +72,44 @@ draw_waveform ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int chann } - fl_color( fl_darker( fl_darker( color ) ) ); + if ( outline ) + { - fl_line_style( FL_SOLID, 2 ); + fl_color( fl_darker( fl_darker( color ) ) ); - fl_begin_line(); + fl_line_style( FL_SOLID, 2 ); - j = start; - for ( int x = X; x <= X + W; ++x, ++j ) - { - Peak p = (*pk)[ j ]; + fl_begin_line(); - p.min *= _scale; + j = start; + for ( int x = X; x <= X + W; ++x, ++j ) + { + Peak p = (*pk)[ j ]; - fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.min )); - } + p.min *= _scale; - fl_end_line(); + fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.min )); + } - fl_begin_line(); + fl_end_line(); - j = start; - for ( int x = X; x <= X + W; ++x, ++j ) - { - Peak p = (*pk)[ j ]; + fl_begin_line(); - p.max *= _scale; + j = start; + for ( int x = X; x <= X + W; ++x, ++j ) + { + Peak p = (*pk)[ j ]; - fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.max )); - } + p.max *= _scale; + + fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.max )); + } - fl_end_line(); + fl_end_line(); - fl_line_style( FL_SOLID, 0 ); + fl_line_style( FL_SOLID, 0 ); + + } fl_pop_clip(); } diff --git a/main.C b/main.C index 802f738..2962ab6 100644 --- a/main.C +++ b/main.C @@ -65,6 +65,7 @@ main ( int argc, char **argv ) Fl::get_system_colors(); Fl::scheme( "plastic" ); +// Fl::scheme( "gtk+" ); Loggable::open( "history" ); /* welcome to C++ */ @@ -81,7 +82,7 @@ main ( int argc, char **argv ) o->callback( cb_undo, 0 ); main_window->end(); - main_window->show(); + main_window->show( argc, argv ); Fl::run(); }