KeyFrame* KeyFrames::get_keyframe()
{
+ int64_t pos = track->to_units(edl->local_session->get_selectionstart(1), 0);
// Search for keyframe on or before selection
- KeyFrame *result =
- get_prev_keyframe(
- track->to_units(edl->local_session->get_selectionstart(1), 0),
- PLAY_FORWARD);
-
-// Return nearest keyframe if not in automatic keyframe generation
- if(!edl->session->auto_keyframes)
- {
- return result;
- }
- else
-// Return new keyframe
- if(result == (KeyFrame*)default_auto ||
- result->position != track->to_units(edl->local_session->get_selectionstart(1), 0))
- {
- return (KeyFrame*)insert_auto(track->to_units(edl->local_session->get_selectionstart(1), 0));
- }
- else
-// Return existing keyframe
- {
- return result;
+ KeyFrame *result = get_prev_keyframe(pos, PLAY_FORWARD);
+ if( edl->session->auto_keyframes ) {
+ if( !result || result->position != pos ||
+ result == (KeyFrame*)default_auto )
+// generate keyframes while tweeking, and no keyframe found at pos
+ result = (KeyFrame*)insert_auto(pos);
}
-
- return 0;
+ return result;
}
void KeyFrames::update_parameter(KeyFrame *src)
{
- const int debug = 0;
// Create new keyframe if auto keyframes or replace entire keyframe.
double selection_start = edl->local_session->get_selectionstart(0);
double selection_end = edl->local_session->get_selectionend(0);
selection_start = edl->align_to_frame(selection_start, 0);
selection_end = edl->align_to_frame(selection_end, 0);
- if(EQUIV(selection_start, selection_end))
- {
-// Search for keyframe to write to
+ if( EQUIV(selection_start, selection_end) ) {
+// Search for keyframe to write
KeyFrame *dst = get_keyframe();
-
dst->copy_data(src);
}
- else
+ else {
// Replace changed parameter in all selected keyframes.
- {
BC_Hash *params = 0;
- char *text = 0;
- char *extra = 0;
-
-
+ char *text = 0, *extra = 0;
// Search all keyframes in selection but don't create a new one.
int64_t start = track->to_units(selection_start, 0);
int64_t end = track->to_units(selection_end, 0);
- KeyFrame *current = get_prev_keyframe(
- start,
- PLAY_FORWARD);
-
+ KeyFrame *current = get_prev_keyframe(start, PLAY_FORWARD);
// The first one determines the changed parameters since it is the one displayed
-// in the GUI.
- current->get_diff(src,
- ¶ms,
- &text,
- &extra);
-
-
-if(debug) printf("KeyFrames::update_parameter %d params=%p position=%jd start=%jd\n",
- __LINE__, params, current->position, track->to_units(start, 0));
-
-if(debug && params)
-{
-for(int i = 0; i < params->size(); i++)
-printf("KeyFrames::update_parameter %d changed=%s %s\n",
-__LINE__,
-params->get_key(i),
-params->get_value(i));
-}
-
+ current->get_diff(src, ¶ms, &text, &extra);
// Always update the first one
- current->update_parameter(params,
- text,
- extra);
- for(current = (KeyFrame*)NEXT ; current && current->position < end; current = (KeyFrame*)NEXT)
- {
-if(debug) printf("KeyFrames::update_parameter %d position=%jd\n",
- __LINE__, current->position);
- current->update_parameter(params,
- text,
- extra);
- }
+ current->update_parameter(params, text, extra);
+ for( current = (KeyFrame*)NEXT; current; current = (KeyFrame*)NEXT ) {
+ if( current->position >= end ) break;
+ current->update_parameter(params, text, extra);
+ }
delete params;
delete [] text,
delete [] extra;