Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_edit.c
| Show First 20 Lines • Show All 812 Lines • ▼ Show 20 Lines | case EVT_SPACEKEY: { | ||||
| } | } | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| 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; | ||||
| } | } | ||||
| case EVT_ESCKEY: | case EVT_ESCKEY: | ||||
| case RIGHTMOUSE: { | case RIGHTMOUSE: { | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| for (int i = 0; i < data->num_seq; i++) { | for (int i = 0; i < data->num_seq; i++) { | ||||
| transseq_restore(data->ts + i, data->seq_array[i]); | transseq_restore(data->ts + i, data->seq_array[i]); | ||||
| } | } | ||||
| for (int i = 0; i < data->num_seq; i++) { | for (int i = 0; i < data->num_seq; i++) { | ||||
| Sequence *seq = data->seq_array[i]; | Sequence *seq = data->seq_array[i]; | ||||
| SEQ_add_reload_new_file(bmain, scene, seq, false); | SEQ_add_reload_new_file(bmain, scene, seq, false); | ||||
| ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ||||
| SEQ_time_update_sequence(scene, seqbase, seq); | SEQ_time_update_sequence(scene, seqbase, seq); | ||||
| } | } | ||||
| MEM_freeN(data->seq_array); | MEM_freeN(data->seq_array); | ||||
| MEM_freeN(data->ts); | MEM_freeN(data->ts); | ||||
| MEM_freeN(data->trim); | MEM_freeN(data->trim); | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| op->customdata = NULL; | op->customdata = NULL; | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | ||||
| SEQ_relations_free_imbuf(scene, &ed->seqbase, false); | |||||
| if (area) { | if (area) { | ||||
| ED_area_status_text(area, NULL); | ED_area_status_text(area, NULL); | ||||
| } | } | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| case EVT_RIGHTSHIFTKEY: | case EVT_RIGHTSHIFTKEY: | ||||
| ▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | static int sequencer_reload_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); | ||||
| Sequence *seq; | Sequence *seq; | ||||
| const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length"); | const bool adjust_length = RNA_boolean_get(op->ptr, "adjust_length"); | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | for (seq = ed->seqbasep->first; seq; seq = seq->next) { | ||||
| if (seq->flag & SELECT) { | if (seq->flag & SELECT) { | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, seq, 0, 1); | |||||
| SEQ_add_reload_new_file(bmain, scene, seq, !adjust_length); | SEQ_add_reload_new_file(bmain, scene, seq, !adjust_length); | ||||
| if (adjust_length) { | if (adjust_length) { | ||||
| if (SEQ_transform_test_overlap(ed->seqbasep, seq)) { | if (SEQ_transform_test_overlap(ed->seqbasep, seq)) { | ||||
| SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene); | SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | if (SEQ_relations_render_loop_check(seq1, last_seq) || | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| last_seq->seq1 = seq1; | last_seq->seq1 = seq1; | ||||
| last_seq->seq2 = seq2; | last_seq->seq2 = seq2; | ||||
| last_seq->seq3 = seq3; | last_seq->seq3 = seq3; | ||||
| int old_start = last_seq->start; | int old_start = last_seq->start; | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, last_seq, 1, 1); | SEQ_time_update_recursive(scene, last_seq); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, last_seq); | |||||
| SEQ_offset_animdata(scene, last_seq, (last_seq->start - old_start)); | SEQ_offset_animdata(scene, last_seq, (last_seq->start - old_start)); | ||||
| 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; | ||||
| } | } | ||||
| static bool sequencer_effect_poll(bContext *C) | static bool sequencer_effect_poll(bContext *C) | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap"); | BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| seq = last_seq->seq1; | seq = last_seq->seq1; | ||||
| last_seq->seq1 = last_seq->seq2; | last_seq->seq1 = last_seq->seq2; | ||||
| last_seq->seq2 = seq; | last_seq->seq2 = seq; | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, last_seq, 1, 1); | SEQ_relations_invalidate_cache_preprocessed(scene, last_seq); | ||||
| 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; | ||||
| } | } | ||||
| void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot) | void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot) | ||||
| { | { | ||||
| /* Identifiers. */ | /* Identifiers. */ | ||||
| ▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Lines | for (seq = ed->seqbasep->first; seq; seq = seq->next) { | ||||
| } | } | ||||
| } | } | ||||
| /* Update lengths, etc. */ | /* Update lengths, etc. */ | ||||
| seq = ed->seqbasep->first; | seq = ed->seqbasep->first; | ||||
| while (seq) { | while (seq) { | ||||
| ListBase *seqbase = SEQ_active_seqbase_get(ed); | ListBase *seqbase = SEQ_active_seqbase_get(ed); | ||||
| SEQ_time_update_sequence(scene, seqbase, seq); | SEQ_time_update_sequence(scene, seqbase, seq); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seq); | |||||
| seq = seq->next; | seq = seq->next; | ||||
| } | } | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | for (seq = ed->seqbasep->first; seq; seq = seq->next) { | ||||
| if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) { | if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) { | ||||
| if (SEQ_transform_test_overlap(ed->seqbasep, seq)) { | if (SEQ_transform_test_overlap(ed->seqbasep, seq)) { | ||||
| SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene); | SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 395 Lines • ▼ Show 20 Lines | static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) | ||||
| ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ||||
| int gap = seqb->startdisp - seqa->enddisp; | int gap = seqb->startdisp - seqa->enddisp; | ||||
| int seq_a_start; | int seq_a_start; | ||||
| int seq_b_start; | int seq_b_start; | ||||
| seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp; | seq_b_start = (seqb->start - seqb->startdisp) + seqa->startdisp; | ||||
| SEQ_transform_translate_sequence(scene, seqb, seq_b_start - seqb->start); | SEQ_transform_translate_sequence(scene, seqb, seq_b_start - seqb->start); | ||||
| SEQ_time_update_sequence(scene, seqbase, seqb); | SEQ_time_update_sequence(scene, seqbase, seqb); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seqb); | |||||
| seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap; | seq_a_start = (seqa->start - seqa->startdisp) + seqb->enddisp + gap; | ||||
| SEQ_transform_translate_sequence(scene, seqa, seq_a_start - seqa->start); | SEQ_transform_translate_sequence(scene, seqa, seq_a_start - seqa->start); | ||||
| SEQ_time_update_sequence(scene, seqbase, seqa); | SEQ_time_update_sequence(scene, seqbase, seqa); | ||||
| SEQ_relations_invalidate_cache_preprocessed(scene, seqa); | |||||
| } | } | ||||
| static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel) | static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel) | ||||
| { | { | ||||
| /* sel: 0==unselected, 1==selected, -1==don't care. */ | /* sel: 0==unselected, 1==selected, -1==don't care. */ | ||||
| Sequence *seq, *best_seq = NULL; | Sequence *seq, *best_seq = NULL; | ||||
| Editing *ed = SEQ_editing_get(scene); | Editing *ed = SEQ_editing_get(scene); | ||||
| ▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | static const EnumPropertyItem prop_change_effect_input_types[] = { | ||||
| {1, "B_C", 0, "B -> C", ""}, | {1, "B_C", 0, "B -> C", ""}, | ||||
| {2, "A_C", 0, "A -> C", ""}, | {2, "A_C", 0, "A -> C", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) | static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(scene); | ||||
| Sequence **seq_1, **seq_2; | Sequence **seq_1, **seq_2; | ||||
| switch (RNA_enum_get(op->ptr, "swap")) { | switch (RNA_enum_get(op->ptr, "swap")) { | ||||
| case 0: | case 0: | ||||
| seq_1 = &seq->seq1; | seq_1 = &seq->seq1; | ||||
| seq_2 = &seq->seq2; | seq_2 = &seq->seq2; | ||||
| Show All 10 Lines | static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) | ||||
| if (*seq_1 == NULL || *seq_2 == NULL) { | if (*seq_1 == NULL || *seq_2 == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap"); | BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| SWAP(Sequence *, *seq_1, *seq_2); | SWAP(Sequence *, *seq_1, *seq_2); | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, seq, 0, 1); | SEQ_relations_invalidate_cache_preprocessed(scene, seq); | ||||
| /* Invalidate cache. */ | |||||
| SEQ_relations_free_imbuf(scene, &ed->seqbase, false); | |||||
| 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; | ||||
| } | } | ||||
| void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) | void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) | ||||
| { | { | ||||
| /* Identifiers. */ | /* Identifiers. */ | ||||
| Show All 37 Lines | EnumPropertyItem sequencer_prop_effect_types[] = { | ||||
| {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""}, | {SEQ_TYPE_TEXT, "TEXT", 0, "Text", ""}, | ||||
| {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""}, | {SEQ_TYPE_COLORMIX, "COLORMIX", 0, "Color Mix", ""}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) | static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(scene); | ||||
| const int new_type = RNA_enum_get(op->ptr, "type"); | const int new_type = RNA_enum_get(op->ptr, "type"); | ||||
| /* Free previous effect and init new effect. */ | /* Free previous effect and init new effect. */ | ||||
| struct SeqEffectHandle sh; | struct SeqEffectHandle sh; | ||||
| if ((seq->type & SEQ_TYPE_EFFECT) == 0) { | if ((seq->type & SEQ_TYPE_EFFECT) == 0) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| Show All 9 Lines | static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) | ||||
| sh = SEQ_effect_handle_get(seq); | sh = SEQ_effect_handle_get(seq); | ||||
| sh.free(seq, true); | sh.free(seq, true); | ||||
| seq->type = new_type; | seq->type = new_type; | ||||
| sh = SEQ_effect_handle_get(seq); | sh = SEQ_effect_handle_get(seq); | ||||
| sh.init(seq); | sh.init(seq); | ||||
| SEQ_relations_update_changed_seq_and_deps(scene, seq, 0, 1); | SEQ_relations_invalidate_cache_preprocessed(scene, seq); | ||||
| /* Invalidate cache. */ | |||||
| SEQ_relations_free_imbuf(scene, &ed->seqbase, false); | |||||
| 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; | ||||
| } | } | ||||
| void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) | void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) | ||||
| { | { | ||||
| /* Identifiers. */ | /* Identifiers. */ | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (seq->type == SEQ_TYPE_IMAGE) { | ||||
| seq->anim_startofs = seq->anim_endofs = 0; | seq->anim_startofs = seq->anim_endofs = 0; | ||||
| /* Correct start/end frames so we don't move. | /* Correct start/end frames so we don't move. | ||||
| * Important not to set seq->len = len; allow the function to handle it. */ | * Important not to set seq->len = len; allow the function to handle it. */ | ||||
| SEQ_add_reload_new_file(bmain, scene, seq, true); | SEQ_add_reload_new_file(bmain, scene, seq, true); | ||||
| ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(scene)); | ||||
| SEQ_time_update_sequence(scene, seqbase, seq); | SEQ_time_update_sequence(scene, seqbase, seq); | ||||
| /* Invalidate cache. */ | |||||
| SEQ_relations_free_imbuf(scene, seqbase, false); | |||||
| } | } | ||||
| else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { | else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SOUND_HD)) { | ||||
| bSound *sound = seq->sound; | bSound *sound = seq->sound; | ||||
| if (sound == NULL) { | if (sound == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| RNA_string_get(op->ptr, "filepath", filepath); | RNA_string_get(op->ptr, "filepath", filepath); | ||||
| BLI_strncpy(sound->filepath, filepath, sizeof(sound->filepath)); | BLI_strncpy(sound->filepath, filepath, sizeof(sound->filepath)); | ||||
| BKE_sound_load(bmain, sound); | BKE_sound_load(bmain, sound); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Lame, set rna filepath. */ | /* Lame, set rna filepath. */ | ||||
| PointerRNA seq_ptr; | PointerRNA seq_ptr; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr); | RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr); | ||||
| RNA_string_get(op->ptr, "filepath", filepath); | RNA_string_get(op->ptr, "filepath", filepath); | ||||
| prop = RNA_struct_find_property(&seq_ptr, "filepath"); | prop = RNA_struct_find_property(&seq_ptr, "filepath"); | ||||
| RNA_property_string_set(&seq_ptr, prop, filepath); | RNA_property_string_set(&seq_ptr, prop, filepath); | ||||
| RNA_property_update(C, &seq_ptr, prop); | RNA_property_update(C, &seq_ptr, prop); | ||||
| SEQ_relations_sequence_free_anim(seq); | |||||
| } | } | ||||
| SEQ_relations_invalidate_cache_raw(scene, seq); | |||||
| 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; | ||||
| } | } | ||||
| static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int sequencer_change_path_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ▲ Show 20 Lines • Show All 549 Lines • Show Last 20 Lines | |||||