Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/strip_edit.c
| Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| #include "SEQ_edit.h" | #include "SEQ_edit.h" | ||||
| #include "SEQ_effects.h" | #include "SEQ_effects.h" | ||||
| #include "SEQ_relations.h" | #include "SEQ_relations.h" | ||||
| #include "SEQ_sequencer.h" | #include "SEQ_sequencer.h" | ||||
| #include "SEQ_time.h" | #include "SEQ_time.h" | ||||
| #include "SEQ_transform.h" | #include "SEQ_transform.h" | ||||
| #include "SEQ_utils.h" | #include "SEQ_utils.h" | ||||
| int SEQ_edit_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) | int SEQ_edit_sequence_swap(Scene *scene, Sequence *seq_a, Sequence *seq_b, const char **error_str) | ||||
| { | { | ||||
| char name[sizeof(seq_a->name)]; | char name[sizeof(seq_a->name)]; | ||||
| if (seq_a->len != seq_b->len) { | if (SEQ_time_strip_length_get(scene, seq_a) != SEQ_time_strip_length_get(scene, seq_b)) { | ||||
| *error_str = N_("Strips must be the same length"); | *error_str = N_("Strips must be the same length"); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* type checking, could be more advanced but disallow sound vs non-sound copy */ | /* type checking, could be more advanced but disallow sound vs non-sound copy */ | ||||
| if (seq_a->type != seq_b->type) { | if (seq_a->type != seq_b->type) { | ||||
| if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) { | if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) { | ||||
| *error_str = N_("Strips were not compatible"); | *error_str = N_("Strips were not compatible"); | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | bool SEQ_edit_move_strip_to_meta(Scene *scene, | ||||
| SEQ_time_update_sequence(scene, dst_seqm); | SEQ_time_update_sequence(scene, dst_seqm); | ||||
| if (SEQ_transform_test_overlap(&dst_seqm->seqbase, src_seq)) { | if (SEQ_transform_test_overlap(&dst_seqm->seqbase, src_seq)) { | ||||
| SEQ_transform_seqbase_shuffle(&dst_seqm->seqbase, src_seq, scene); | SEQ_transform_seqbase_shuffle(&dst_seqm->seqbase, src_seq, scene); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void seq_split_set_left_hold_offset(Sequence *seq, int timeline_frame) | static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) | ||||
| { | { | ||||
| /* Adjust within range of extended stillframes before strip. */ | /* Adjust within range of extended stillframes before strip. */ | ||||
| if (timeline_frame < seq->start) { | if (timeline_frame < seq->start) { | ||||
| seq->start = timeline_frame - 1; | seq->start = timeline_frame - 1; | ||||
| seq->anim_endofs += seq->len - 1; | seq->anim_endofs += SEQ_time_strip_length_get(scene, seq) - 1; | ||||
| seq->startstill = timeline_frame - seq->startdisp - 1; | seq->startstill = timeline_frame - seq->startdisp - 1; | ||||
| seq->endstill = 0; | seq->endstill = 0; | ||||
| } | } | ||||
| /* Adjust within range of strip contents. */ | /* Adjust within range of strip contents. */ | ||||
| else if ((timeline_frame >= seq->start) && (timeline_frame <= (seq->start + seq->len))) { | else if ((timeline_frame >= seq->start) && | ||||
| (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) { | |||||
| seq->endofs = 0; | seq->endofs = 0; | ||||
| seq->endstill = 0; | seq->endstill = 0; | ||||
| seq->anim_endofs += (seq->start + seq->len) - timeline_frame; | seq->anim_endofs += (seq->start + SEQ_time_strip_length_get(scene, seq)) - timeline_frame; | ||||
| } | } | ||||
| /* Adjust within range of extended stillframes after strip. */ | /* Adjust within range of extended stillframes after strip. */ | ||||
| else if ((seq->start + seq->len) < timeline_frame) { | else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { | ||||
| seq->endstill = timeline_frame - seq->start - seq->len; | seq->endstill = timeline_frame - seq->start - SEQ_time_strip_length_get(scene, seq); | ||||
| } | } | ||||
| } | } | ||||
| static void seq_split_set_right_hold_offset(Sequence *seq, int timeline_frame) | static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame) | ||||
| { | { | ||||
| /* Adjust within range of extended stillframes before strip. */ | /* Adjust within range of extended stillframes before strip. */ | ||||
| if (timeline_frame < seq->start) { | if (timeline_frame < seq->start) { | ||||
| seq->startstill = seq->start - timeline_frame; | seq->startstill = seq->start - timeline_frame; | ||||
| } | } | ||||
| /* Adjust within range of strip contents. */ | /* Adjust within range of strip contents. */ | ||||
| else if ((timeline_frame >= seq->start) && (timeline_frame <= (seq->start + seq->len))) { | else if ((timeline_frame >= seq->start) && | ||||
| (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) { | |||||
| seq->anim_startofs += timeline_frame - seq->start; | seq->anim_startofs += timeline_frame - seq->start; | ||||
| seq->start = timeline_frame; | seq->start = timeline_frame; | ||||
| seq->startstill = 0; | seq->startstill = 0; | ||||
| seq->startofs = 0; | seq->startofs = 0; | ||||
| } | } | ||||
| /* Adjust within range of extended stillframes after strip. */ | /* Adjust within range of extended stillframes after strip. */ | ||||
| else if ((seq->start + seq->len) < timeline_frame) { | else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { | ||||
| seq->start = timeline_frame; | seq->start = timeline_frame; | ||||
| seq->startofs = 0; | seq->startofs = 0; | ||||
| seq->anim_startofs += seq->len - 1; | seq->anim_startofs += SEQ_time_strip_length_get(scene, seq) - 1; | ||||
| seq->endstill = seq->enddisp - timeline_frame - 1; | seq->endstill = seq->enddisp - timeline_frame - 1; | ||||
| seq->startstill = 0; | seq->startstill = 0; | ||||
| } | } | ||||
| } | } | ||||
| static void seq_split_set_right_offset(Sequence *seq, int timeline_frame) | static void seq_split_set_right_offset(Scene *scene, Sequence *seq, int timeline_frame) | ||||
| { | { | ||||
| /* Adjust within range of extended stillframes before strip. */ | /* Adjust within range of extended stillframes before strip. */ | ||||
| if (timeline_frame < seq->start) { | if (timeline_frame < seq->start) { | ||||
| seq->start = timeline_frame - 1; | seq->start = timeline_frame - 1; | ||||
| seq->startstill = timeline_frame - seq->startdisp - 1; | seq->startstill = timeline_frame - seq->startdisp - 1; | ||||
| seq->endofs = seq->len - 1; | seq->endofs = SEQ_time_strip_length_get(scene, seq) - 1; | ||||
| } | } | ||||
| /* Adjust within range of extended stillframes after strip. */ | /* Adjust within range of extended stillframes after strip. */ | ||||
| else if ((seq->start + seq->len) < timeline_frame) { | else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { | ||||
| seq->endstill -= seq->enddisp - timeline_frame; | seq->endstill -= seq->enddisp - timeline_frame; | ||||
| } | } | ||||
| SEQ_transform_set_right_handle_frame(seq, timeline_frame); | SEQ_transform_set_right_handle_frame(scene, seq, timeline_frame); | ||||
| } | } | ||||
| static void seq_split_set_left_offset(Sequence *seq, int timeline_frame) | static void seq_split_set_left_offset(Scene *scene, Sequence *seq, int timeline_frame) | ||||
| { | { | ||||
| /* Adjust within range of extended stillframes before strip. */ | /* Adjust within range of extended stillframes before strip. */ | ||||
| if (timeline_frame < seq->start) { | if (timeline_frame < seq->start) { | ||||
| seq->startstill = seq->start - timeline_frame; | seq->startstill = seq->start - timeline_frame; | ||||
| } | } | ||||
| /* Adjust within range of extended stillframes after strip. */ | /* Adjust within range of extended stillframes after strip. */ | ||||
| if ((seq->start + seq->len) < timeline_frame) { | if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) { | ||||
| seq->start = timeline_frame - seq->len + 1; | seq->start = timeline_frame - SEQ_time_strip_length_get(scene, seq) + 1; | ||||
| seq->endstill = seq->enddisp - timeline_frame - 1; | seq->endstill = seq->enddisp - timeline_frame - 1; | ||||
| } | } | ||||
| SEQ_transform_set_left_handle_frame(seq, timeline_frame); | SEQ_transform_set_left_handle_frame(scene, seq, timeline_frame); | ||||
| } | } | ||||
| /** | /** | ||||
| * Split Sequence at timeline_frame in two. | * Split Sequence at timeline_frame in two. | ||||
| * | * | ||||
| * \param bmain: Main in which Sequence is located | * \param bmain: Main in which Sequence is located | ||||
| * \param scene: Scene in which Sequence is located | * \param scene: Scene in which Sequence is located | ||||
| * \param seqbase: ListBase in which Sequence is located | * \param seqbase: ListBase in which Sequence is located | ||||
| Show All 22 Lines | Sequence *SEQ_edit_strip_split(Main *bmain, | ||||
| } | } | ||||
| Sequence *left_seq = seq; | Sequence *left_seq = seq; | ||||
| Sequence *right_seq = SEQ_sequence_dupli_recursive( | Sequence *right_seq = SEQ_sequence_dupli_recursive( | ||||
| scene, scene, seqbase, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); | scene, scene, seqbase, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); | ||||
| switch (method) { | switch (method) { | ||||
| case SEQ_SPLIT_SOFT: | case SEQ_SPLIT_SOFT: | ||||
| seq_split_set_left_offset(right_seq, timeline_frame); | seq_split_set_left_offset(scene, right_seq, timeline_frame); | ||||
| seq_split_set_right_offset(left_seq, timeline_frame); | seq_split_set_right_offset(scene, left_seq, timeline_frame); | ||||
| break; | break; | ||||
| case SEQ_SPLIT_HARD: | case SEQ_SPLIT_HARD: | ||||
| seq_split_set_right_hold_offset(left_seq, timeline_frame); | seq_split_set_right_hold_offset(scene, left_seq, timeline_frame); | ||||
| seq_split_set_left_hold_offset(right_seq, timeline_frame); | seq_split_set_left_hold_offset(scene, right_seq, timeline_frame); | ||||
| SEQ_add_reload_new_file(bmain, scene, left_seq, false); | SEQ_add_reload_new_file(bmain, scene, left_seq, false); | ||||
| SEQ_add_reload_new_file(bmain, scene, right_seq, false); | SEQ_add_reload_new_file(bmain, scene, right_seq, false); | ||||
| break; | break; | ||||
| } | } | ||||
| SEQ_time_update_sequence(scene, left_seq); | SEQ_time_update_sequence(scene, left_seq); | ||||
| SEQ_time_update_sequence(scene, right_seq); | SEQ_time_update_sequence(scene, right_seq); | ||||
| return right_seq; | return right_seq; | ||||
| } | } | ||||
| Show All 35 Lines | |||||