diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index 762ab5a..9bc006a 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -103,6 +103,9 @@ parse_alist( const char *s ) char *pair = (char*)malloc( l + 1 ); + if ( c[ strlen( c ) - 1 ] == ' ' ) + --l; + strncpy( pair, c, l ); pair[ l ] = '\0'; @@ -119,9 +122,8 @@ parse_alist( const char *s ) if ( *v == '"' ) { // v++; - v[ strlen( v ) - 2 ] = '\0'; + v[ strlen( v ) - 1 ] = '\0'; memmove( v, v + 1, strlen( v ) + 1 ); - } } diff --git a/Timeline/Region.C b/Timeline/Region.C index 8fced44..55777b8 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -221,9 +221,6 @@ Region::trim ( enum trim_e t, int X ) } } -/* convert a screen x coord into an offset into the region */ -#define x_to_offset( X ) ( timeline->x_to_ts( scroll_x() + ( (X) - _track->x() ) ) - _r->offset ) - int Region::handle ( int m ) { diff --git a/Timeline/Ruler_Point.H b/Timeline/Ruler_Point.H index 2480c26..f542593 100644 --- a/Timeline/Ruler_Point.H +++ b/Timeline/Ruler_Point.H @@ -66,7 +66,6 @@ protected: Ruler_Point ( ) { - } public: @@ -74,8 +73,10 @@ public: /* for loggable */ LOG_CREATE_FUNC( Ruler_Point ); - Ruler_Point ( nframes_t when, const char *name ) + Ruler_Point ( Sequence *track, nframes_t when, const char *name ) { + _track = track; + _r->offset = when; _label = strdup( name ); diff --git a/Timeline/Ruler_Sequence.H b/Timeline/Ruler_Sequence.H index f26e75a..5119210 100644 --- a/Timeline/Ruler_Sequence.H +++ b/Timeline/Ruler_Sequence.H @@ -38,6 +38,30 @@ public: { Sequence::draw(); timeline->draw_measure_BBT( x(), y(), w(), h(), FL_WHITE ); + } + int handle ( int m ) + { + + if ( Sequence::handle( m ) ) + return 1; + + switch ( m ) + { + case FL_PUSH: + { + if ( Fl::event_button1() ) + { + add( new Ruler_Point( this, x_to_offset( Fl::event_x() ), "mark" ) ); + redraw(); + } + break; + } + default: + break; + + } + + return 0; } }; diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 31505f0..831c7c3 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -51,6 +51,12 @@ Sequence::~Sequence ( ) // log_destroy(); } +nframes_t +Sequence::x_to_offset ( int X ) +{ + return timeline->xoffset + timeline->x_to_ts( X - x() ); +} + void Sequence::sort ( void ) { diff --git a/Timeline/Sequence.H b/Timeline/Sequence.H index 9eb7f82..4572cdc 100644 --- a/Timeline/Sequence.H +++ b/Timeline/Sequence.H @@ -31,8 +31,6 @@ #include -// using namespace std; - class Track; class Sequence_Widget; @@ -97,6 +95,8 @@ public: virtual ~Sequence ( ); + nframes_t x_to_offset ( int X ); + const char * name ( void ) const { return _name; } void name ( const char *s ) { diff --git a/Timeline/Sequence_Widget.H b/Timeline/Sequence_Widget.H index 1dd842b..34fc7ab 100644 --- a/Timeline/Sequence_Widget.H +++ b/Timeline/Sequence_Widget.H @@ -308,6 +308,11 @@ public: void start ( nframes_t v ) { _r->start = v; } nframes_t start ( void ) const { return _r->start; } + /** convert a screen x coord into an offset into the region */ + nframes_t x_to_offset ( int X ) + { + return timeline->x_to_ts( scroll_x() + ( X - _track->x() ) ) - _r->offset; + } int active_r ( void ) const { return _track->active_r(); } virtual nframes_t length ( void ) const { return _r->end - _r->start; } diff --git a/Timeline/Timeline.C b/Timeline/Timeline.C index a39c050..83bcc40 100644 --- a/Timeline/Timeline.C +++ b/Timeline/Timeline.C @@ -492,9 +492,6 @@ Timeline::draw ( void ) if ( damage() & FL_DAMAGE_CHILD ) { -// draw_box( box(), 0, 0, w(), h(), color() ); - -// fl_push_clip( rulers->x(), rulers->y(), rulers->w() - vscroll->w(), rulers->h() ); fl_push_clip( rulers->x(), rulers->y(), rulers->w(), rulers->h() ); update_child( *rulers ); fl_pop_clip(); diff --git a/Timeline/main.C b/Timeline/main.C index bee06f9..c8a138e 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -45,6 +45,7 @@ #include "Timeline.H" #include "Tempo_Sequence.H" #include "Time_Sequence.H" +#include "Ruler_Sequence.H" #include "Control_Sequence.H" #include "Transport.H" @@ -88,6 +89,7 @@ main ( int argc, char **argv ) LOG_REGISTER_CREATE( Region ); LOG_REGISTER_CREATE( Time_Point ); LOG_REGISTER_CREATE( Tempo_Point ); + LOG_REGISTER_CREATE( Ruler_Point ); LOG_REGISTER_CREATE( Control_Point ); LOG_REGISTER_CREATE( Track ); LOG_REGISTER_CREATE( Audio_Sequence );