Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_edit.c
| Show First 20 Lines • Show All 2,481 Lines • ▼ Show 20 Lines | if (seq->type == SEQ_TYPE_META) { | ||||
| } | } | ||||
| } | } | ||||
| else if (seq->scene_sound) { | else if (seq->scene_sound) { | ||||
| BKE_sound_remove_scene_sound(scene, seq->scene_sound); | BKE_sound_remove_scene_sound(scene, seq->scene_sound); | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| } | } | ||||
| } | } | ||||
| static void sequencer_copy_animation(Scene *scene, Sequence *seq) | |||||
| { | |||||
| if (scene->adt == NULL || scene->adt->action == NULL || | |||||
| BLI_listbase_is_empty(&scene->adt->action->curves)) { | |||||
| return; | |||||
| } | |||||
| GSet *fcurves = SEQ_fcurves_by_strip_name_get(seq->name + 2, &scene->adt->action->curves); | |||||
| GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { | |||||
| BLI_addtail(&fcurves_clipboard, BKE_fcurve_copy(fcu)); | |||||
| } | |||||
| GSET_FOREACH_END(); | |||||
| BLI_gset_free(fcurves, NULL); | |||||
| } | |||||
| static int sequencer_copy_exec(bContext *C, wmOperator *op) | static int sequencer_copy_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | Editing *ed = SEQ_editing_get(scene); | ||||
| SEQ_clipboard_free(); | SEQ_clipboard_free(); | ||||
| Show All 10 Lines | SEQ_sequence_base_dupli_recursive(scene, | ||||
| &seqbase_clipboard, | &seqbase_clipboard, | ||||
| ed->seqbasep, | ed->seqbasep, | ||||
| 0, | 0, | ||||
| (LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_MAIN)); | (LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_FREE_NO_MAIN)); | ||||
| seqbase_clipboard_frame = scene->r.cfra; | seqbase_clipboard_frame = scene->r.cfra; | ||||
| SEQ_clipboard_active_seq_name_store(scene); | SEQ_clipboard_active_seq_name_store(scene); | ||||
| /* Remove anything that references the current scene. */ | |||||
| LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) { | LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) { | ||||
| /* Copy curves. */ | |||||
| sequencer_copy_animation(scene, seq); | |||||
| /* Remove anything that references the current scene. */ | |||||
| seq_copy_del_sound(scene, seq); | seq_copy_del_sound(scene, seq); | ||||
| } | } | ||||
| /* Replace datablock pointers with copies, to keep things working in case | /* Replace datablock pointers with copies, to keep things working in case | ||||
| * data-blocks get deleted or another .blend file is opened. */ | * data-blocks get deleted or another .blend file is opened. */ | ||||
| SEQ_clipboard_pointers_store(bmain, &seqbase_clipboard); | SEQ_clipboard_pointers_store(bmain, &seqbase_clipboard); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| Show All 28 Lines | if (ed == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) { | LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) { | ||||
| seq->flag &= ~SEQ_ALLSEL; | seq->flag &= ~SEQ_ALLSEL; | ||||
| } | } | ||||
| } | } | ||||
| static void sequencer_paste_animation(bContext *C) | |||||
| { | |||||
| if (BLI_listbase_is_empty(&fcurves_clipboard)) { | |||||
| return; | |||||
| } | |||||
| Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| bAction *act; | |||||
| if (scene->adt != NULL && scene->adt->action != NULL) { | |||||
| act = scene->adt->action; | |||||
| } | |||||
| else { | |||||
| /* get action to add F-Curve+keyframe to */ | |||||
| act = ED_id_action_ensure(bmain, &scene->id); | |||||
| } | |||||
| LISTBASE_FOREACH (FCurve *, fcu, &fcurves_clipboard) { | |||||
| BLI_addtail(&act->curves, BKE_fcurve_copy(fcu)); | |||||
| } | |||||
| } | |||||
| static int sequencer_paste_exec(bContext *C, wmOperator *op) | static int sequencer_paste_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); /* Create if needed. */ | Editing *ed = SEQ_editing_ensure(scene); /* Create if needed. */ | ||||
| ListBase nseqbase = {NULL, NULL}; | ListBase nseqbase = {NULL, NULL}; | ||||
| int ofs; | int ofs; | ||||
| Sequence *iseq, *iseq_first; | Sequence *iseq, *iseq_first; | ||||
| Show All 14 Lines | LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) { | ||||
| min_seq_startdisp = seq->startdisp; | min_seq_startdisp = seq->startdisp; | ||||
| } | } | ||||
| } | } | ||||
| /* Paste strips relative to the current-frame. */ | /* Paste strips relative to the current-frame. */ | ||||
| ofs = scene->r.cfra - min_seq_startdisp; | ofs = scene->r.cfra - min_seq_startdisp; | ||||
| } | } | ||||
| /* Paste animation. | /* Paste animation. | ||||
| * First backup original curves from scene and duplicate strip curves from backup into scene. | * Note: Only fcurves are copied. Drivers and NLA action strips are not copied. | ||||
| * This way, when pasted strips are renamed, curves are renamed with them. Finally, restore | * First backup original curves from scene and move curves from clipboard into scene. This way, | ||||
| * original curves from backup. | * when pasted strips are renamed, pasted fcurves are renamed with them. Finally restore original | ||||
| * curves from backup. | |||||
| */ | */ | ||||
| ListBase fcurves_original_backup = {NULL, NULL}; | ListBase fcurves_original_backup = {NULL, NULL}; | ||||
| sequencer_backup_original_animation(scene, &fcurves_original_backup); | sequencer_backup_original_animation(scene, &fcurves_original_backup); | ||||
| sequencer_paste_animation(C); | |||||
| /* Copy strips, temporarily restoring pointers to actual data-blocks. This | /* Copy strips, temporarily restoring pointers to actual data-blocks. This | ||||
| * must happen on the clipboard itself, so that copying does user counting | * must happen on the clipboard itself, so that copying does user counting | ||||
| * on the actual data-blocks. */ | * on the actual data-blocks. */ | ||||
| SEQ_clipboard_pointers_restore(&seqbase_clipboard, bmain); | SEQ_clipboard_pointers_restore(&seqbase_clipboard, bmain); | ||||
| SEQ_sequence_base_dupli_recursive(scene, scene, &nseqbase, &seqbase_clipboard, 0, 0); | SEQ_sequence_base_dupli_recursive(scene, scene, &nseqbase, &seqbase_clipboard, 0, 0); | ||||
| SEQ_clipboard_pointers_store(bmain, &seqbase_clipboard); | SEQ_clipboard_pointers_store(bmain, &seqbase_clipboard); | ||||
| iseq_first = nseqbase.first; | iseq_first = nseqbase.first; | ||||
| /* NOTE: SEQ_sequence_base_dupli_recursive() takes care of generating new UUIDs for sequences | /* NOTE: SEQ_sequence_base_dupli_recursive() takes care of generating new UUIDs for sequences | ||||
| * in the new list. */ | * in the new list. */ | ||||
| BLI_movelisttolist(ed->seqbasep, &nseqbase); | BLI_movelisttolist(ed->seqbasep, &nseqbase); | ||||
| for (iseq = iseq_first; iseq; iseq = iseq->next) { | for (iseq = iseq_first; iseq; iseq = iseq->next) { | ||||
| if (SEQ_clipboard_pasted_seq_was_active(iseq)) { | if (SEQ_clipboard_pasted_seq_was_active(iseq)) { | ||||
| SEQ_select_active_set(scene, iseq); | SEQ_select_active_set(scene, iseq); | ||||
| } | } | ||||
| sequencer_duplicate_animation(scene, iseq, &fcurves_original_backup); | |||||
| /* Make sure, that pasted strips have unique names. */ | /* Make sure, that pasted strips have unique names. */ | ||||
| SEQ_ensure_unique_name(iseq, scene); | SEQ_ensure_unique_name(iseq, scene); | ||||
| /* Translate after name has been changed, otherwise this will affect animdata of original | /* Translate after name has been changed, otherwise this will affect animdata of original | ||||
| * strip. */ | * strip. */ | ||||
| SEQ_transform_translate_sequence(scene, iseq, ofs); | SEQ_transform_translate_sequence(scene, iseq, ofs); | ||||
| /* Ensure, that pasted strips don't overlap. */ | /* Ensure, that pasted strips don't overlap. */ | ||||
| if (SEQ_transform_test_overlap(ed->seqbasep, iseq)) { | if (SEQ_transform_test_overlap(ed->seqbasep, iseq)) { | ||||
| SEQ_transform_seqbase_shuffle(ed->seqbasep, iseq, scene); | SEQ_transform_seqbase_shuffle(ed->seqbasep, iseq, scene); | ||||
| ▲ Show 20 Lines • Show All 904 Lines • Show Last 20 Lines | |||||