From 193dc19c91a9555d6446f1af38f559b80b27f8ae Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 2 Dec 2008 00:14:25 -0600 Subject: [PATCH] Use timestamps (of creation) for take names instead of sequential numbers. --- Timeline/Audio_Sequence.C | 23 +++++++++++++++++++++-- Timeline/Audio_Sequence.H | 6 +++--- Timeline/Sequence.C | 5 ++++- Timeline/Sequence.H | 4 ++-- Timeline/Track.C | 9 +++------ 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Timeline/Audio_Sequence.C b/Timeline/Audio_Sequence.C index c5ae1b1..0a64db1 100644 --- a/Timeline/Audio_Sequence.C +++ b/Timeline/Audio_Sequence.C @@ -20,6 +20,7 @@ /* An Audio_Sequence is a sequence of Audio_Regions. Takes and 'track * contents' consist of these objects */ +#include #include #include "Audio_Sequence.H" @@ -35,11 +36,29 @@ using namespace std; -Audio_Sequence::Audio_Sequence ( Track *track ) : Sequence( track ) +Audio_Sequence::Audio_Sequence ( Track *track, const char *name ) : Sequence( track ) { - _track = track; + if ( name ) + Audio_Sequence::name( name ); + else + { + struct timeval tv; + + gettimeofday( &tv, NULL ); + + time_t t = tv.tv_sec; + + char s[40]; + + ctime_r( &t, s ); + + s[ strlen( s ) - 1 ] = 0; + + Audio_Sequence::name( s ); + } + if ( track ) track->add( this ); diff --git a/Timeline/Audio_Sequence.H b/Timeline/Audio_Sequence.H index 410ee9a..8e5a410 100644 --- a/Timeline/Audio_Sequence.H +++ b/Timeline/Audio_Sequence.H @@ -48,14 +48,14 @@ public: LOG_CREATE_FUNC( Audio_Sequence ); - Audio_Sequence ( Track *track ); + Audio_Sequence ( Track *track, const char *name = 0 ); ~Audio_Sequence ( ); Fl_Cursor cursor ( void ) const { return FL_CURSOR_DEFAULT; } - Sequence * clone_empty ( void ) + Sequence * clone_empty ( const char *name = 0 ) { - Audio_Sequence *t = new Audio_Sequence( track() ); + Audio_Sequence *t = new Audio_Sequence( track(), name ); return t; } diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index f87c1e9..3438333 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -41,12 +41,15 @@ queue Sequence::_delete_queue; -Sequence::Sequence ( Track *track ) : Fl_Widget( 0, 0, 0, 0 ), Loggable( true ) +Sequence::Sequence ( Track *track, const char *name ) : Fl_Widget( 0, 0, 0, 0 ), Loggable( true ) { init(); _track = track; + if ( name ) + _name = strdup( name ); + // log_create(); } diff --git a/Timeline/Sequence.H b/Timeline/Sequence.H index 2133f2e..978af7a 100644 --- a/Timeline/Sequence.H +++ b/Timeline/Sequence.H @@ -74,7 +74,7 @@ public: /* welcome to C++ */ LOG_NAME_FUNC( Sequence ); - Sequence ( Track *track=0 ); + Sequence ( Track *track=0, const char *name = 0 ); Sequence ( int X, int Y, int W, int H ); @@ -89,7 +89,7 @@ public: void name ( const char *s ) { if ( _name ) free( _name ); - _name = strdup( s ); + _name = s ? strdup( s ) : NULL; label( _name ); } diff --git a/Timeline/Track.C b/Timeline/Track.C index 530afe0..3b76f50 100644 --- a/Timeline/Track.C +++ b/Timeline/Track.C @@ -23,6 +23,7 @@ /* TODO: split into Track and Audio_Track (and maybe later Video_Track * and MIDI_Track */ +#include #include "Track.H" #include "Transport.H" @@ -502,12 +503,6 @@ void Track::add ( Audio_Sequence * t ) { takes->insert( *t, 0 ); - if ( ! t->name() ) - { - char pat[20]; - snprintf( pat, sizeof( pat ), "%d", 1 + takes->children() ); - t->name( strdup( pat ) ); - } t->labeltype( FL_ENGRAVED_LABEL ); @@ -583,6 +578,8 @@ Track::sequence ( Audio_Sequence * t ) t->labeltype( FL_NO_LABEL ); + update_take_menu(); + resize(); }