Permit adding of tracks from GUI.

pull/3/head
Jonathan Moore Liles 2008-04-18 21:26:27 -05:00
parent 793fb05176
commit d316e8772c
2 changed files with 71 additions and 10 deletions

View File

@ -715,14 +715,49 @@ Timeline::handle ( int m )
{
take_focus();
if ( ! Fl::event_button1() )
if ( Fl::event_button1() )
{
assert( ! drag );
drag = new Drag( X - x(), Y - y() );
_selection.x = drag->x;
_selection.y = drag->y;
}
else if ( Fl::event_button3() )
{
Fl_Menu_Item menu[] =
{
{ "Add Track", 0, 0, 0, FL_SUBMENU },
{ "Audio", 0, 0, 0 },
{ 0 },
{ 0 },
};
const Fl_Menu_Item *r = menu->popup( X, Y, "Timeline" );
if ( r == &menu[1] )
{
/* FIXME: prompt for I/O config? */
/* add audio track */
Track_Header *t = new Track_Header( 0, 0, tracks->w(), 30 );
add_track( t );
Track *o = new Audio_Track( 0, 0, 1, 100 );
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() );
}
}
else
return 0;
assert( ! drag );
drag = new Drag( X - x(), Y - y() );
_selection.x = drag->x;
_selection.y = drag->y;
break;
}
case FL_DRAG:
@ -762,6 +797,32 @@ Timeline::handle ( int m )
}
void
Timeline::add_track ( Track_Header *track )
{
printf( "added new track to the timeline\n" );
/* FIXME: do locking */
tracks->add( track );
/* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
redraw();
}
void
Timeline::remove_track ( Track_Header *track )
{
printf( "removed track from the timeline\n" );
/* FIXME: do locking */
/* FIXME: what to do about track contents? */
tracks->remove( track );
/* FIXME: why is this necessary? doesn't the above add do DAMAGE_CHILD? */
redraw();
}
/**********/
/* Engine */
/**********/

View File

@ -45,10 +45,7 @@ extern Timeline *timeline;
class Tempo_Track;
class Time_Track;
class Ruler_Track;
/* #include <list> */
/* using std::list; */
class Track_Header;
// disables double-buffering to make unnecessary redrawing more apparent
// #define DEBUG_TIMELINE_DRAWING
@ -153,6 +150,9 @@ public:
void select( const Rectangle &r );
void add_track ( Track_Header *track );
void remove_track ( Track_Header *track );
private:
friend class Engine; // FIXME: only Engine::process() needs to be friended.x