Separate track, control tracks, and takes.

This commit is contained in:
Jonathan Moore Liles 2008-03-08 15:48:06 -06:00
parent decd7d107b
commit 9a01389624
3 changed files with 119 additions and 67 deletions

View File

@ -163,17 +163,11 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
l = o; l = o;
// o->end(); // 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->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; tracks = o;

View File

@ -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 ) Fl_Group ( X, Y, W, H, L )
{ {
_track = NULL;
_name = NULL; _name = NULL;
_selected = false; _selected = false;
_show_all_takes = 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(); 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->labeltype( FL_NO_LABEL );
o->align( FL_ALIGN_CLIP );
o->resize( x() + width(), y(), w() - width(), h() ); o->resize( x() + width(), y(), w() - width(), h() );
o->end();
Fl_Group::current()->resizable( o ); 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(); end();
@ -178,15 +190,80 @@ Track_Header::~Track_Header ( )
log_destroy(); 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 void
Track_Header::track( Track * t ) Track_Header::track( Track * t )
{ {
// t->size( 1, h() ); // 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();
} }

View File

@ -52,6 +52,8 @@ private:
enum { AUDIO } _type; enum { AUDIO } _type;
Track *_track;
public: public:
Fl_Input * name_field; Fl_Input * name_field;
@ -60,8 +62,13 @@ public:
Fl_Button *solo_button; Fl_Button *solo_button;
Fl_Menu_Button *take_menu; Fl_Menu_Button *take_menu;
Fl_Group *controls; Fl_Group *controls;
Fl_Pack *pack;
Fl_Pack *control;
Fl_Pack *takes; Fl_Pack *takes;
const char *class_name ( void ) { return "Track_Header"; } const char *class_name ( void ) { return "Track_Header"; }
void set ( char **sa ) void set ( char **sa )
@ -166,38 +173,12 @@ public:
Fl_Group::draw(); Fl_Group::draw();
} }
void add_control( Track *t );
int size ( void ) const { return _size; } int size ( void ) const { return _size; }
/* adjust size of widget and children */ void resize ( void );
void resize ( void ) void size ( int v );
{
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();
}
int height ( void ) const int height ( void ) const
{ {
@ -224,10 +205,10 @@ public:
void cb_button ( Fl_Widget *w ); void cb_button ( Fl_Widget *w );
static int width(); static int width ( void ) { return 150; }
void track( Track * t ); void track( Track * t );
Track * track ( void ) { return (Track*)takes->child( 0 ); } Track * track ( void ) { return _track; }
void add ( Track * t ) void add ( Track * t )
{ {