Fix selection issues.

This fixes the bug where some selected wigets would disappear to frame 0.
It also prevents moving any widget behind 0.
This commit is contained in:
Jonathan Moore Liles 2008-05-18 21:40:42 -05:00
parent 06de784661
commit 9ef454291a
2 changed files with 58 additions and 9 deletions

View File

@ -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 <Sequence_Widget *>::iterator i = _selection.begin(); i != _selection.end(); ++i )
m = min( m, (*i)->_r->start );
d = 0 - d;
if ( m <= d )
d = m;
for ( list <Sequence_Widget *>::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 <Sequence_Widget *>::iterator i = _selection.begin(); i != _selection.end(); ++i )
{
(*i)->redraw();
(*i)->_r->start += d;
}
}
}
}
void void
Sequence_Widget::draw_label ( const char *label, Fl_Align align, Fl_Color color ) 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 ); const nframes_t of = timeline->x_to_offset( X );
if ( of >= _drag->start ) /* if ( of >= _drag->start ) */
{ /* { */
_r->start = of - _drag->start;
if ( Sequence_Widget::_current == this ) start( of - _drag->start );
sequence()->snap( this );
} if ( Sequence_Widget::_current == this )
else sequence()->snap( this );
_r->start = 0;
} }

View File

@ -326,7 +326,10 @@ public:
void sequence ( Sequence *t ) { _sequence = t; } void sequence ( Sequence *t ) { _sequence = t; }
nframes_t start ( void ) const { return _r->start; } 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; } void length ( nframes_t v ) { _r->length = v; }
virtual nframes_t length ( void ) const { return _r->length; } virtual nframes_t length ( void ) const { return _r->length; }