diff --git a/Timeline/Sequence_Widget.C b/Timeline/Sequence_Widget.C index 4574248..4575fe7 100644 --- a/Timeline/Sequence_Widget.C +++ b/Timeline/Sequence_Widget.C @@ -78,6 +78,54 @@ Sequence_Widget::set ( Log_Entry &e ) } +/** set position of widget on the timeline. */ +void +Sequence_Widget::start ( nframes_t where ) +{ + /* this is pretty complicated because of selection and snapping */ + + if ( ! selected() ) + { + redraw(); + _r->start = where; + } + else + { + if ( this != Sequence_Widget::_current ) + return; + + long d = where - _r->start; + + if ( d < 0 ) + { + /* first, make sure we stop at 0 */ + nframes_t m = (nframes_t)-1; + + for ( list ::iterator i = _selection.begin(); i != _selection.end(); ++i ) + m = min( m, (*i)->_r->start ); + + d = 0 - d; + + if ( m <= d ) + d = m; + + for ( list ::iterator i = _selection.begin(); i != _selection.end(); ++i ) + { + (*i)->redraw(); + (*i)->_r->start -= d; + } + } + else + { + /* TODO: do like the above and disallow wrapping */ + for ( list ::iterator i = _selection.begin(); i != _selection.end(); ++i ) + { + (*i)->redraw(); + (*i)->_r->start += d; + } + } + } +} void Sequence_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color ) @@ -253,15 +301,13 @@ Sequence_Widget::handle ( int m ) { const nframes_t of = timeline->x_to_offset( X ); - if ( of >= _drag->start ) - { - _r->start = of - _drag->start; +/* if ( of >= _drag->start ) */ +/* { */ - if ( Sequence_Widget::_current == this ) - sequence()->snap( this ); - } - else - _r->start = 0; + start( of - _drag->start ); + + if ( Sequence_Widget::_current == this ) + sequence()->snap( this ); } diff --git a/Timeline/Sequence_Widget.H b/Timeline/Sequence_Widget.H index 42e21db..9aebc32 100644 --- a/Timeline/Sequence_Widget.H +++ b/Timeline/Sequence_Widget.H @@ -326,7 +326,10 @@ public: void sequence ( Sequence *t ) { _sequence = t; } nframes_t start ( void ) const { return _r->start; } - void start ( nframes_t o ) { _r->start = o; } + +/* void start ( nframes_t o ) { _r->start = o; } */ + + void start ( nframes_t where ); void length ( nframes_t v ) { _r->length = v; } virtual nframes_t length ( void ) const { return _r->length; }