From 5fb04e863bd4aafb43b10adc938d408bf0943262 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 28 May 2008 00:19:14 -0500 Subject: [PATCH] Add next/prev widget bindings for sequences. --- Timeline/Sequence.C | 43 ++++++++++++++++++++++++++++++++++++++++++- Timeline/Sequence.H | 3 +++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 1acdab5..d342d3f 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -298,8 +298,38 @@ Sequence::snap ( Sequence_Widget *r ) r->start( f ); } +/** return the location of the next widget from frame /from/ */ +nframes_t +Sequence::next ( nframes_t from ) const +{ + for ( list ::const_iterator i = _widgets.begin(); i != _widgets.end(); i++ ) + if ( (*i)->start() > from ) + return (*i)->start(); + + if ( _widgets.size() ) + return _widgets.back()->start(); + else + return 0; +} + +/** return the location of the next widget from frame /from/ */ +nframes_t +Sequence::prev ( nframes_t from ) const +{ + for ( list ::const_reverse_iterator i = _widgets.rbegin(); i != _widgets.rend(); i++ ) + if ( (*i)->start() < from ) + return (*i)->start(); + + if ( _widgets.size() ) + return _widgets.front()->start(); + else + return 0; +} + #include "FL/event_name.H" +#include "Transport.H" // for locate() + int Sequence::handle ( int m ) { @@ -310,9 +340,20 @@ Sequence::handle ( int m ) switch ( m ) { case FL_KEYBOARD: + if ( Fl::test_shortcut( FL_CTRL + FL_Right ) ) + { + transport->locate( next( transport->frame ) ); + return 1; + } + else if ( Fl::test_shortcut( FL_CTRL + FL_Left ) ) + { + transport->locate( prev( transport->frame ) ); + return 1; + } + else /* this is a hack to override FLTK's use of arrow keys for * focus navigation */ - return timeline->handle_scroll( m ); + return timeline->handle_scroll( m ); case FL_NO_EVENT: /* garbage from overlay window */ return 0; diff --git a/Timeline/Sequence.H b/Timeline/Sequence.H index daf84c9..6daa958 100644 --- a/Timeline/Sequence.H +++ b/Timeline/Sequence.H @@ -93,6 +93,9 @@ public: void sort ( void ); + nframes_t next ( nframes_t from ) const; + nframes_t prev ( nframes_t from ) const; + Track *track ( void ) const { return _track; } void track ( Track *t ) { _track = t; }