From 9a013896242a8df91049d98176d3641b856359eb Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 8 Mar 2008 15:48:06 -0600 Subject: [PATCH] Separate track, control tracks, and takes. --- Timeline.C | 14 ++---- Track_Header.C | 127 +++++++++++++++++++++++++++++++++++++++---------- Track_Header.H | 45 +++++------------- 3 files changed, 119 insertions(+), 67 deletions(-) diff --git a/Timeline.C b/Timeline.C index a6b9455..4fbd583 100644 --- a/Timeline.C +++ b/Timeline.C @@ -163,17 +163,11 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi l = o; // o->end(); - t->add( o ); - t->add( new Control_Track( 0, 0, 1, 100 ) ); - t->color( (Fl_Color)rand() ); - } - - { - Track_Header *t = new Track_Header( 0, 0, W, 30 ); - Track *o = new Control_Track( 0, 0, 1, 100 ); - o->color( FL_BLUE ); - t->color( FL_RED ); t->track( o ); + t->add( new Audio_Track( 0, 0, 1, 100 ) ); + t->add( new Audio_Track( 0, 0, 1, 100 ) ); + t->add_control( new Control_Track( 0, 0, 1, 100 ) ); + t->color( (Fl_Color)rand() ); } tracks = o; diff --git a/Track_Header.C b/Track_Header.C index 10f3c25..66e96aa 100644 --- a/Track_Header.C +++ b/Track_Header.C @@ -56,29 +56,29 @@ Track_Header::cb_button ( Fl_Widget *w ) } else - if ( w == take_menu ) - { - int v = take_menu->value(); - - if ( v == 0 ) + if ( w == take_menu ) { - show_all_takes( take_menu->menu()[ v ].value() ); - return; - } + int v = take_menu->value(); - const char *s = take_menu->menu()[ v ].text; - - for ( int i = takes->children(); i--; ) - { - Track *t = (Track*)takes->child( i ); - if ( ! strcmp( s, t->name() ) ) + if ( v == 0 ) { - track( t ); - redraw(); - break; + show_all_takes( take_menu->menu()[ v ].value() ); + return; + } + + const char *s = take_menu->menu()[ v ].text; + + for ( int i = takes->children(); i--; ) + { + Track *t = (Track*)takes->child( i ); + if ( ! strcmp( s, t->name() ) ) + { + track( t ); + redraw(); + break; + } } } - } } @@ -86,6 +86,7 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) : Fl_Group ( X, Y, W, H, L ) { + _track = NULL; _name = NULL; _selected = false; _show_all_takes = false; @@ -161,12 +162,23 @@ Track_Header::Track_Header ( int X, int Y, int W, int H, const char *L ) : o->end(); } { - Fl_Pack *o = takes = new Fl_Pack( 150, 0, 1006, 115 ); + Fl_Pack *o = pack = new Fl_Pack( width(), 0, 1006, 115 ); o->labeltype( FL_NO_LABEL ); - o->align( FL_ALIGN_CLIP ); o->resize( x() + width(), y(), w() - width(), h() ); - o->end(); Fl_Group::current()->resizable( o ); + + { + Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 115 ); + o->end(); + } + + { + Fl_Pack *o = takes = new Fl_Pack( width(), 0, pack->w(), 115 ); + o->end(); + o->hide(); + } + + o->end(); } end(); @@ -178,15 +190,80 @@ Track_Header::~Track_Header ( ) log_destroy(); } -int -Track_Header::width() + +static int pack_visible( Fl_Pack *p ) { - return 150; + int v = 0; + for ( int i = p->children(); i--; ) + if ( p->child( i )->visible() ) + v++; + + return v; +} + +/* adjust size of widget and children */ +void +Track_Header::resize ( void ) +{ + for ( int i = takes->children(); i--; ) + takes->child( i )->size( w(), height() ); + + for ( int i = control->children(); i--; ) + control->child( i )->size( w(), height() ); + + if ( _show_all_takes ) + { + takes->show(); + Fl_Group::size( w(), height() * ( 1 + takes->children() + pack_visible( control ) ) ); + } + else + { + takes->hide(); + Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) ); + } + + if ( track() ) + track()->size( w(), height() ); + + + if ( controls->y() + controls->h() > y() + h() ) + controls->hide(); + else + controls->show(); + + parent()->redraw(); +} + +void +Track_Header::size ( int v ) +{ + if ( v < 0 || v > 3 ) + return; + + _size = v; + + resize(); } void Track_Header::track( Track * t ) { // t->size( 1, h() ); - takes->insert( *t, 0 ); + if ( track() ) + add( track() ); + +// takes->insert( *track(), 0 ); + + _track = t; + pack->insert( *t, 0 ); + + resize(); +} + +void +Track_Header::add_control( Track *t ) +{ + control->add( t ); + + resize(); } diff --git a/Track_Header.H b/Track_Header.H index cbc1583..381b6f5 100644 --- a/Track_Header.H +++ b/Track_Header.H @@ -52,6 +52,8 @@ private: enum { AUDIO } _type; + Track *_track; + public: Fl_Input * name_field; @@ -60,8 +62,13 @@ public: Fl_Button *solo_button; Fl_Menu_Button *take_menu; Fl_Group *controls; + + Fl_Pack *pack; + Fl_Pack *control; Fl_Pack *takes; + + const char *class_name ( void ) { return "Track_Header"; } void set ( char **sa ) @@ -166,38 +173,12 @@ public: Fl_Group::draw(); } + void add_control( Track *t ); + int size ( void ) const { return _size; } - /* adjust size of widget and children */ - void resize ( void ) - { - 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 ( controls->y() + controls->h() > y() + h() ) - controls->hide(); - else - controls->show(); - - parent()->redraw(); - } - - void size ( int v ) - { - if ( v < 0 || v > 3 ) - return; - - _size = v; - - resize(); - } + void resize ( void ); + void size ( int v ); int height ( void ) const { @@ -224,10 +205,10 @@ public: void cb_button ( Fl_Widget *w ); - static int width(); + static int width ( void ) { return 150; } void track( Track * t ); - Track * track ( void ) { return (Track*)takes->child( 0 ); } + Track * track ( void ) { return _track; } void add ( Track * t ) {