Add keybinding to select sequence widget under playhead.

This commit is contained in:
Jonathan Moore Liles 2008-06-17 22:09:09 -05:00
parent 34761757ed
commit f4c825949e
2 changed files with 24 additions and 5 deletions

View File

@ -204,17 +204,23 @@ Sequence::length ( void ) const
} }
Sequence_Widget * Sequence_Widget *
Sequence::event_widget ( void ) Sequence::widget_at ( nframes_t ts, int Y )
{ {
nframes_t ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() );
for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); ++r ) for ( list <Sequence_Widget *>::const_reverse_iterator r = _widgets.rbegin(); r != _widgets.rend(); ++r )
if ( ets > (*r)->start() && ets < (*r)->start() + (*r)->length() if ( ts >= (*r)->start() && ts <= (*r)->start() + (*r)->length()
&& Fl::event_y() >= (*r)->y() && Fl::event_y() <= (*r)->y() + (*r)->h() ) && Y >= (*r)->y() && Y <= (*r)->y() + (*r)->h() )
return (*r); return (*r);
return NULL; return NULL;
} }
Sequence_Widget *
Sequence::event_widget ( void )
{
nframes_t ets = timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() );
return widget_at( ets, Fl::event_y() );
}
void void
Sequence::select_range ( int X, int W ) Sequence::select_range ( int X, int W )
{ {
@ -355,6 +361,18 @@ Sequence::handle ( int m )
transport->locate( prev( transport->frame ) ); transport->locate( prev( transport->frame ) );
return 1; return 1;
} }
else if ( Fl::test_shortcut( FL_CTRL + ' ' ) )
{
Sequence_Widget *r = widget_at( transport->frame, y() );
if ( r )
{
if ( r->selected() )
r->deselect();
else
r->select();
}
}
else else
{ {
switch ( Fl::event_key() ) switch ( Fl::event_key() )

View File

@ -59,6 +59,7 @@ protected:
friend class Timeline; // for draw_measure friend class Timeline; // for draw_measure
std::list <Sequence_Widget *> _widgets; std::list <Sequence_Widget *> _widgets;
Sequence_Widget *widget_at ( nframes_t ts, int Y );
Sequence_Widget *event_widget ( void ); Sequence_Widget *event_widget ( void );