From 42a19831164db89f1df98d8e20111a2925e72a1b Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 4 May 2008 18:06:36 -0500 Subject: [PATCH] Allow each track to contain multiple Annotation_Sequences. --- Timeline/Annotation_Sequence.H | 54 +++++++++++++++++++++++++++++++++- Timeline/Timeline.C | 15 +++++----- Timeline/Track.C | 33 +++++++++++++++++++-- Timeline/Track.H | 8 ++++- Timeline/main.C | 1 + 5 files changed, 99 insertions(+), 12 deletions(-) diff --git a/Timeline/Annotation_Sequence.H b/Timeline/Annotation_Sequence.H index c2d5f80..f9cdde1 100644 --- a/Timeline/Annotation_Sequence.H +++ b/Timeline/Annotation_Sequence.H @@ -23,18 +23,70 @@ #include "Annotation_Point.H" #include "Timeline.H" -class Annotation_Sequence : public Sequence +class Annotation_Sequence : public Sequence, public Loggable { +protected: + + virtual void get ( Log_Entry &e ) const + { + e.add( ":t", _track ); + } + + void + set ( Log_Entry &e ) + { + for ( int i = 0; i < e.size(); ++i ) + { + const char *s, *v; + + e.get( i, &s, &v ); + + if ( ! strcmp( ":t", s ) ) + { + int i; + sscanf( v, "%X", &i ); + Track *t = (Track*)Loggable::find( i ); + + assert( t ); + + t->track( this ); + } + } + } + + Annotation_Sequence ( ) : Sequence ( 0, 0, 0, 0 ) + { + } + public: + + LOG_CREATE_FUNC( Annotation_Sequence ); + Fl_Cursor cursor ( void ) const { return FL_CURSOR_INSERT; } + Annotation_Sequence ( Track *track ) : Sequence( 0, 0, 0, 0 ) + { + _track = track; + + color( fl_darker( FL_GREEN ) ); + + log_create(); + +// labeltype( FL_NO_LABEL ); + } + Annotation_Sequence ( int X, int Y, int W, int H ) : Sequence ( X, Y, W, H ) { // box( FL_UP_BOX ); } + ~Annotation_Sequence ( ) + { + log_destroy(); + } + /* void */ /* draw ( void ) */ /* { */ diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index 09283f2..a2fd69d 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -179,16 +179,17 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi o->time( 0, 4, 4 ); } - { - Annotation_Sequence *o = new Annotation_Sequence( 0, 24, 800, 24 ); - o->color( fl_gray_ramp( 'F' ) ); +/* { */ +/* Annotation_Sequence *o = new Annotation_Sequence( 0, 24, 800, 24 ); */ - o->label( "Ruler" ); - o->align( FL_ALIGN_LEFT ); +/* o->color( fl_gray_ramp( 'F' ) ); */ - ruler_track = o; - } +/* o->label( "Ruler" ); */ +/* o->align( FL_ALIGN_LEFT ); */ + +/* ruler_track = o; */ +/* } */ o->size( o->w(), o->child( 0 )->h() * o->children() ); rulers = o; diff --git a/Timeline/Track.C b/Timeline/Track.C index 4504d75..f5b8eeb 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -33,6 +33,9 @@ // #include #include +#include "Control_Sequence.H" +#include "Annotation_Sequence.H" + int Track::_soloing = 0; const char *Track::capture_format = "Wav 24"; @@ -203,6 +206,11 @@ Track::init ( void ) resizable( o ); + { + Fl_Pack *o = annotation = new Fl_Pack( width(), 0, pack->w(), 115 ); + o->end(); + } + { Fl_Pack *o = control = new Fl_Pack( width(), 0, pack->w(), 115 ); o->end(); @@ -260,9 +268,14 @@ static int pack_visible( Fl_Pack *p ) void Track::resize ( void ) { + + for ( int i = takes->children(); i--; ) takes->child( i )->size( w(), height() ); + for ( int i = annotation->children(); i--; ) + annotation->child( i )->size( w(), 24 ); + for ( int i = control->children(); i--; ) control->child( i )->size( w(), height() ); @@ -277,6 +290,8 @@ Track::resize ( void ) Fl_Group::size( w(), height() * ( 1 + pack_visible( control ) ) ); } + Fl_Group::size( w(), h() + ( ( 24 ) * pack_visible( annotation ) ) ); + if ( track() ) track()->size( w(), height() ); @@ -346,7 +361,7 @@ Track::track ( Sequence * t ) add( track() ); _track = t; - pack->insert( *t, 0 ); + pack->insert( *t, 1 ); t->labeltype( FL_NO_LABEL ); @@ -356,7 +371,7 @@ Track::track ( Sequence * t ) void Track::add ( Control_Sequence *t ) { - printf( "adding control sequence\n" ); + DMESSAGE( "adding control sequence\n" ); t->track( this ); @@ -369,6 +384,18 @@ Track::add ( Control_Sequence *t ) resize(); } +void +Track::add ( Annotation_Sequence *t ) +{ + DMESSAGE( "adding annotation sequence\n" ); + + t->track( this ); + + annotation->add( t ); + + resize(); +} + /** add all widget on this track falling within the given rectangle to the selection. */ void @@ -494,7 +521,7 @@ Track::handle ( int m ) } else if ( r == &menu[ 7 ] ) { -// new Annotation_Sequence; + add( new Annotation_Sequence( this ) ); } else if ( r == &menu[ 8 ] ) { diff --git a/Timeline/Track.H b/Timeline/Track.H index 65d3bee..25a33c0 100644 --- a/Timeline/Track.H +++ b/Timeline/Track.H @@ -39,8 +39,9 @@ using std::vector; #include "Port.H" #include "Timeline.H" -#include "Control_Sequence.H" +class Control_Sequence; +class Annotation_Sequence; class Playback_DS; class Record_DS; class Port; @@ -104,9 +105,11 @@ public: Fl_Group *controls; Fl_Pack *pack; + Fl_Pack *annotation; Fl_Pack *control; Fl_Pack *takes; + vector input; /* input ports... */ vector output; /* output ports... */ vector control_out; /* control ports... */ @@ -185,6 +188,9 @@ public: /* for loggable */ LOG_CREATE_FUNC( Track ); + void add ( Annotation_Sequence *t ); + void remove ( Annotation_Sequence *t ); + void add ( Control_Sequence *t ); void add ( Sequence *t ); void remove ( Sequence *t ); diff --git a/Timeline/main.C b/Timeline/main.C index 01a8fb8..ee3ddc5 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -94,6 +94,7 @@ main ( int argc, char **argv ) LOG_REGISTER_CREATE( Track ); LOG_REGISTER_CREATE( Audio_Sequence ); LOG_REGISTER_CREATE( Control_Sequence ); + LOG_REGISTER_CREATE( Annotation_Sequence ); init_boxtypes();