Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_edit.c
| Show First 20 Lines • Show All 1,580 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Duplicate Strips Operator | /** \name Duplicate Strips Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int apply_unique_name_fn(Sequence *seq, void *arg_pt) | |||||
| { | |||||
| Scene *scene = (Scene *)arg_pt; | |||||
| char name[sizeof(seq->name) - 2]; | |||||
| BLI_strncpy_utf8(name, seq->name + 2, sizeof(name)); | |||||
| SEQ_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq); | |||||
| SEQ_dupe_animdata(scene, name, seq->name + 2); | |||||
| return 1; | |||||
| } | |||||
| static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) | static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = SEQ_editing_get(scene, false); | Editing *ed = SEQ_editing_get(scene, false); | ||||
| ListBase nseqbase = {NULL, NULL}; | ListBase nseqbase = {NULL, NULL}; | ||||
| if (ed == NULL) { | if (ed == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| SEQ_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0); | SEQ_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0); | ||||
| if (nseqbase.first) { | if (nseqbase.first) { | ||||
| Sequence *seq = nseqbase.first; | Sequence *seq = nseqbase.first; | ||||
| /* Rely on the nseqbase list being added at the end. | /* Rely on the nseqbase list being added at the end. | ||||
| * Their UUIDs has been re-generated by the SEQ_sequence_base_dupli_recursive(), */ | * Their UUIDs has been re-generated by the SEQ_sequence_base_dupli_recursive(), */ | ||||
| BLI_movelisttolist(ed->seqbasep, &nseqbase); | BLI_movelisttolist(ed->seqbasep, &nseqbase); | ||||
| for (; seq; seq = seq->next) { | for (; seq; seq = seq->next) { | ||||
| SEQ_iterator_recursive_apply(seq, apply_unique_name_fn, scene); | SEQ_iterator_recursive_apply(seq, SEQ_iterator_apply_unique_name_fn, scene); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 963 Lines • ▼ Show 20 Lines | static int sequencer_paste_exec(bContext *C, wmOperator *op) | ||||
| 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) { | ||||
| /* Make sure, that pasted strips have unique names. */ | /* Make sure, that pasted strips have unique names. */ | ||||
| SEQ_iterator_recursive_apply(iseq, apply_unique_name_fn, scene); | SEQ_iterator_recursive_apply(iseq, SEQ_iterator_apply_unique_name_fn, 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 761 Lines • Show Last 20 Lines | |||||