From e6313394cd9da4f5228e1fc929d6da996876661c Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sat, 5 Oct 2013 21:12:43 -0700 Subject: [PATCH] Timeline: Allow recording in punch mode when playhead is in the middle of a punch cursor. --- timeline/src/Engine/Timeline.C | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/timeline/src/Engine/Timeline.C b/timeline/src/Engine/Timeline.C index e967f40..e6f6537 100644 --- a/timeline/src/Engine/Timeline.C +++ b/timeline/src/Engine/Timeline.C @@ -60,14 +60,29 @@ Timeline::record ( void ) { DMESSAGE( "Finding next punch region following frame %lu...", (unsigned long)frame); - const Sequence_Widget *w = punch_cursor_track->next( frame ); + const Sequence_Widget *p = punch_cursor_track->prev( frame ); + const Sequence_Widget *n = punch_cursor_track->next( frame ); - if ( w && w->start() >= frame ) + if (p || n ) { - frame = w->start(); - _punch_out_frame = w->start() + w->length(); - - DMESSAGE( "Punch enabled... Will punch in at frame %lu.", (unsigned long)frame ); + if ( p && frame > p->start() && frame < p->start() + p->length() ) + { + /* recording started in the middle of a punch + * cursor... Just start recording and punch out at the + * end of it */ + _punch_out_frame = p->start() + p->length(); + } + else if ( n && n->start() >= frame ) + { + /* recording started outside of a punch cursor, set + * punch in frame to beginning of next cursor */ + frame = n->start(); + _punch_out_frame = n->start() + n->length(); + } + + DMESSAGE( "Punch enabled... Range %lu:%lu", + (unsigned long)frame, + (unsigned long)_punch_out_frame); } }