Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_add.c
| Show All 17 Lines | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "DNA_mask_types.h" | #include "DNA_mask_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_sound_types.h" | #include "DNA_sound_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_video_edit_types.h" | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_movieclip.h" | #include "BKE_movieclip.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) | ||||
| } | } | ||||
| } | } | ||||
| static void sequencer_generic_invoke_path__internal(bContext *C, | static void sequencer_generic_invoke_path__internal(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const char *identifier) | const char *identifier) | ||||
| { | { | ||||
| if (RNA_struct_find_property(op->ptr, identifier)) { | if (RNA_struct_find_property(op->ptr, identifier)) { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *last_seq = SEQ_select_active_get(scene); | Sequence *last_seq = SEQ_select_active_get(video_edit); | ||||
| if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { | if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| char path[FILE_MAX]; | char path[FILE_MAX]; | ||||
| BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); | BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); | ||||
| BLI_path_abs(path, BKE_main_blendfile_path(bmain)); | BLI_path_abs(path, BKE_main_blendfile_path(bmain)); | ||||
| RNA_string_set(op->ptr, identifier, path); | RNA_string_set(op->ptr, identifier, path); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) | static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) | ||||
| { | { | ||||
| Sequence *tgt = NULL; | Sequence *tgt = NULL; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); | int timeline_frame = (int)video_edit->r.cfra; | ||||
| int timeline_frame = (int)scene->r.cfra; | |||||
| int proximity = INT_MAX; | int proximity = INT_MAX; | ||||
| if (!ed || !ed->seqbasep) { | if (!video_edit->seqbasep) { | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| for (seq = ed->seqbasep->first; seq; seq = seq->next) { | for (seq = video_edit->seqbasep->first; seq; seq = seq->next) { | ||||
| const int strip_end = SEQ_time_right_handle_frame_get(scene, seq); | const int strip_end = SEQ_time_right_handle_frame_get(video_edit, seq); | ||||
| if (ELEM(type, -1, seq->type) && (strip_end < timeline_frame) && | if (ELEM(type, -1, seq->type) && (strip_end < timeline_frame) && | ||||
| (timeline_frame - strip_end < proximity)) { | (timeline_frame - strip_end < proximity)) { | ||||
| tgt = seq; | tgt = seq; | ||||
| proximity = timeline_frame - strip_end; | proximity = timeline_frame - strip_end; | ||||
| } | } | ||||
| } | } | ||||
| if (tgt) { | if (tgt) { | ||||
| return tgt->machine + 1; | return tgt->machine + 1; | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type) | static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| int timeline_frame = (int)scene->r.cfra; | int timeline_frame = (int)video_edit->r.cfra; | ||||
| /* Effect strips don't need a channel initialized from the mouse. */ | /* Effect strips don't need a channel initialized from the mouse. */ | ||||
| if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) { | if (!(flag & SEQPROP_NOCHAN) && RNA_struct_property_is_set(op->ptr, "channel") == 0) { | ||||
| RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type)); | RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type)); | ||||
| } | } | ||||
| if (!RNA_struct_property_is_set(op->ptr, "frame_start")) { | if (!RNA_struct_property_is_set(op->ptr, "frame_start")) { | ||||
| RNA_int_set(op->ptr, "frame_start", timeline_frame); | RNA_int_set(op->ptr, "frame_start", timeline_frame); | ||||
| Show All 21 Lines | static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wmOperator *op) | ||||
| load_data->start_frame = RNA_int_get(op->ptr, "frame_start"); | load_data->start_frame = RNA_int_get(op->ptr, "frame_start"); | ||||
| load_data->channel = RNA_int_get(op->ptr, "channel"); | load_data->channel = RNA_int_get(op->ptr, "channel"); | ||||
| load_data->image.end_frame = load_data->start_frame; | load_data->image.end_frame = load_data->start_frame; | ||||
| load_data->image.len = 1; | load_data->image.len = 1; | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "fit_method"))) { | if ((prop = RNA_struct_find_property(op->ptr, "fit_method"))) { | ||||
| load_data->fit_method = RNA_enum_get(op->ptr, "fit_method"); | load_data->fit_method = RNA_enum_get(op->ptr, "fit_method"); | ||||
| SEQ_tool_settings_fit_method_set(CTX_data_scene(C), load_data->fit_method); | SEQ_tool_settings_fit_method_set(CTX_data_video_edit(C), load_data->fit_method); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "adjust_playback_rate"))) { | if ((prop = RNA_struct_find_property(op->ptr, "adjust_playback_rate"))) { | ||||
| load_data->adjust_playback_rate = RNA_boolean_get(op->ptr, "adjust_playback_rate"); | load_data->adjust_playback_rate = RNA_boolean_get(op->ptr, "adjust_playback_rate"); | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { | if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { | ||||
| RNA_property_string_get(op->ptr, prop, load_data->path); | RNA_property_string_get(op->ptr, prop, load_data->path); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (op->customdata) { | ||||
| load_data->views_format = imf->views_format; | load_data->views_format = imf->views_format; | ||||
| load_data->stereo3d_format = &imf->stereo3d_format; | load_data->stereo3d_format = &imf->stereo3d_format; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void seq_load_apply_generic_options(bContext *C, wmOperator *op, Sequence *seq) | static void seq_load_apply_generic_options(bContext *C, wmOperator *op, Sequence *seq) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| if (seq == NULL) { | if (seq == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| seq->flag |= SELECT; | seq->flag |= SELECT; | ||||
| SEQ_select_active_set(scene, seq); | SEQ_select_active_set(video_edit, seq); | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "overlap") == true || | if (RNA_boolean_get(op->ptr, "overlap") == true || | ||||
| !SEQ_transform_test_overlap(scene, ed->seqbasep, seq)) { | !SEQ_transform_test_overlap(video_edit, video_edit->seqbasep, seq)) { | ||||
| /* No overlap should be handled or the strip is not overlapping, exit early. */ | /* No overlap should be handled or the strip is not overlapping, exit early. */ | ||||
| return; | return; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "overlap_shuffle_override")) { | if (RNA_boolean_get(op->ptr, "overlap_shuffle_override")) { | ||||
| /* Use set overlap_mode to fix overlaps. */ | /* Use set overlap_mode to fix overlaps. */ | ||||
| SeqCollection *strip_col = SEQ_collection_create(__func__); | SeqCollection *strip_col = SEQ_collection_create(__func__); | ||||
| SEQ_collection_append_strip(seq, strip_col); | SEQ_collection_append_strip(seq, strip_col); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & SEQ_MARKER_TRANS) != | const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & SEQ_MARKER_TRANS) != | ||||
| 0; | 0; | ||||
| SEQ_transform_handle_overlap(scene, ed->seqbasep, strip_col, NULL, use_sync_markers); | SEQ_transform_handle_overlap( | ||||
| video_edit, video_edit->seqbasep, strip_col, NULL, use_sync_markers); | |||||
| SEQ_collection_free(strip_col); | SEQ_collection_free(strip_col); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Shuffle strip channel to fix overlaps. */ | /* Shuffle strip channel to fix overlaps. */ | ||||
| SEQ_transform_seqbase_shuffle(ed->seqbasep, seq, scene); | SEQ_transform_seqbase_shuffle(video_edit, video_edit->seqbasep, seq); | ||||
| } | } | ||||
| } | } | ||||
| /* In this alternative version we only check for overlap, but do not do anything about them. */ | /* In this alternative version we only check for overlap, but do not do anything about them. */ | ||||
| static bool seq_load_apply_generic_options_only_test_overlap(bContext *C, | static bool seq_load_apply_generic_options_only_test_overlap(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| SeqCollection *strip_col) | SeqCollection *strip_col) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_get(scene); | |||||
| if (seq == NULL) { | if (seq == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| seq->flag |= SELECT; | seq->flag |= SELECT; | ||||
| SEQ_select_active_set(scene, seq); | SEQ_select_active_set(video_edit, seq); | ||||
| } | } | ||||
| SEQ_collection_append_strip(seq, strip_col); | SEQ_collection_append_strip(seq, strip_col); | ||||
| return SEQ_transform_test_overlap(scene, ed->seqbasep, seq); | return SEQ_transform_test_overlap(video_edit, video_edit->seqbasep, seq); | ||||
| } | } | ||||
| static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), | static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const PropertyRNA *prop) | const PropertyRNA *prop) | ||||
| { | { | ||||
| const char *prop_id = RNA_property_identifier(prop); | const char *prop_id = RNA_property_identifier(prop); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| Show All 9 Lines | static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| Scene *sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); | Scene *sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); | ||||
| if (sce_seq == NULL) { | if (sce_seq == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Scene not found"); | BKE_report(op->reports, RPT_ERROR, "Scene not found"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| load_data.scene = sce_seq; | load_data.scene = sce_seq; | ||||
| Sequence *seq = SEQ_add_scene_strip(scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_scene_strip(video_edit, video_edit->seqbasep, &load_data); | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static void sequencer_disable_one_time_properties(bContext *C, wmOperator *op) | static void sequencer_disable_one_time_properties(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Editing *ed = SEQ_editing_get(CTX_data_scene(C)); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| /* Disable following properties if there are any existing strips, unless overridden by user. */ | /* Disable following properties if there are any existing strips, unless overridden by user. */ | ||||
| if (ed && ed->seqbasep && ed->seqbasep->first) { | if (video_edit->seqbasep && video_edit->seqbasep->first) { | ||||
| if (RNA_struct_find_property(op->ptr, "use_framerate")) { | if (RNA_struct_find_property(op->ptr, "use_framerate")) { | ||||
| RNA_boolean_set(op->ptr, "use_framerate", false); | RNA_boolean_set(op->ptr, "use_framerate", false); | ||||
| } | } | ||||
| if (RNA_struct_find_property(op->ptr, "set_view_transform")) { | if (RNA_struct_find_property(op->ptr, "set_view_transform")) { | ||||
| RNA_boolean_set(op->ptr, "set_view_transform", false); | RNA_boolean_set(op->ptr, "set_view_transform", false); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | static EnumPropertyItem strip_new_scene_items[] = { | ||||
| "Full Copy", | "Full Copy", | ||||
| "Add a Strip and make a full copy of the current scene"}, | "Add a Strip and make a full copy of the current scene"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static int sequencer_add_scene_strip_new_exec(bContext *C, wmOperator *op) | static int sequencer_add_scene_strip_new_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| Scene *scene_new = ED_scene_sequencer_add(bmain, C, type, false); | Scene *scene_new = ED_scene_sequencer_add(bmain, C, type, false); | ||||
| if (scene_new == NULL) { | if (scene_new == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| load_data.scene = scene_new; | load_data.scene = scene_new; | ||||
| Sequence *seq = SEQ_add_scene_strip(scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_scene_strip(video_edit, video_edit->seqbasep, &load_data); | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_scene_strip_new_invoke(bContext *C, | static int sequencer_add_scene_strip_new_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| Show All 15 Lines | static const EnumPropertyItem *strip_new_sequencer_enum_itemf(bContext *C, | ||||
| RNA_enum_item_add(&item, &totitem, &strip_new_scene_items[item_index]); | RNA_enum_item_add(&item, &totitem, &strip_new_scene_items[item_index]); | ||||
| bool has_scene_or_no_context = false; | bool has_scene_or_no_context = false; | ||||
| if (C == NULL) { | if (C == NULL) { | ||||
| /* For documentation generation. */ | /* For documentation generation. */ | ||||
| has_scene_or_no_context = true; | has_scene_or_no_context = true; | ||||
| } | } | ||||
| else { | else { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Sequence *seq = SEQ_select_active_get(scene); | Sequence *seq = SEQ_select_active_get(video_edit); | ||||
| if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != NULL)) { | if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != NULL)) { | ||||
| has_scene_or_no_context = true; | has_scene_or_no_context = true; | ||||
| } | } | ||||
| } | } | ||||
| if (has_scene_or_no_context) { | if (has_scene_or_no_context) { | ||||
| int values[] = {SCE_COPY_EMPTY, SCE_COPY_LINK_COLLECTION, SCE_COPY_FULL}; | int values[] = {SCE_COPY_EMPTY, SCE_COPY_LINK_COLLECTION, SCE_COPY_FULL}; | ||||
| for (int i = 0; i < ARRAY_SIZE(values); i++) { | for (int i = 0; i < ARRAY_SIZE(values); i++) { | ||||
| Show All 27 Lines | void SEQUENCER_OT_scene_strip_add_new(struct wmOperatorType *ot) | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", strip_new_scene_items, SCE_COPY_NEW, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", strip_new_scene_items, SCE_COPY_NEW, "Type", ""); | ||||
| RNA_def_enum_funcs(ot->prop, strip_new_sequencer_enum_itemf); | RNA_def_enum_funcs(ot->prop, strip_new_sequencer_enum_itemf); | ||||
| RNA_def_property_flag(ot->prop, PROP_ENUM_NO_TRANSLATE); | RNA_def_property_flag(ot->prop, PROP_ENUM_NO_TRANSLATE); | ||||
| } | } | ||||
| static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| MovieClip *clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip")); | MovieClip *clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip")); | ||||
| if (clip == NULL) { | if (clip == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Movie clip not found"); | BKE_report(op->reports, RPT_ERROR, "Movie clip not found"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| load_data.clip = clip; | load_data.clip = clip; | ||||
| Sequence *seq = SEQ_add_movieclip_strip(scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_movieclip_strip(video_edit, video_edit->seqbasep, &load_data); | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| if (!RNA_struct_property_is_set(op->ptr, "clip")) { | if (!RNA_struct_property_is_set(op->ptr, "clip")) { | ||||
| return WM_enum_search_invoke(C, op, event); | return WM_enum_search_invoke(C, op, event); | ||||
| Show All 26 Lines | void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) | ||||
| RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); | RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP); | ||||
| RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); | ||||
| ot->prop = prop; | ot->prop = prop; | ||||
| } | } | ||||
| static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| Mask *mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask")); | Mask *mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask")); | ||||
| if (mask == NULL) { | if (mask == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Mask not found"); | BKE_report(op->reports, RPT_ERROR, "Mask not found"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| load_data.mask = mask; | load_data.mask = mask; | ||||
| Sequence *seq = SEQ_add_mask_strip(scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_mask_strip(video_edit, video_edit->seqbasep, &load_data); | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| if (!RNA_struct_property_is_set(op->ptr, "mask")) { | if (!RNA_struct_property_is_set(op->ptr, "mask")) { | ||||
| return WM_enum_search_invoke(C, op, event); | return WM_enum_search_invoke(C, op, event); | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | static void seq_build_proxy(bContext *C, SeqCollection *movie_strips) | ||||
| ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job); | ProxyJob *pj = ED_seq_proxy_job_get(C, wm_job); | ||||
| Sequence *seq; | Sequence *seq; | ||||
| SEQ_ITERATOR_FOREACH (seq, movie_strips) { | SEQ_ITERATOR_FOREACH (seq, movie_strips) { | ||||
| /* Enable and set proxy size. */ | /* Enable and set proxy size. */ | ||||
| SEQ_proxy_set(seq, true); | SEQ_proxy_set(seq, true); | ||||
| seq->strip->proxy->build_size_flags = seq_get_proxy_size_flags(C); | seq->strip->proxy->build_size_flags = seq_get_proxy_size_flags(C); | ||||
| seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING; | seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING; | ||||
| SEQ_proxy_rebuild_context(pj->main, pj->depsgraph, pj->scene, seq, NULL, &pj->queue, true); | SEQ_proxy_rebuild_context( | ||||
| pj->main, pj->depsgraph, pj->video_edit, seq, NULL, &pj->queue, true); | |||||
| } | } | ||||
| if (!WM_jobs_is_running(wm_job)) { | if (!WM_jobs_is_running(wm_job)) { | ||||
| G.is_break = false; | G.is_break = false; | ||||
| WM_jobs_start(CTX_wm_manager(C), wm_job); | WM_jobs_start(CTX_wm_manager(C), wm_job); | ||||
| } | } | ||||
| ED_area_tag_redraw(CTX_wm_area(C)); | ED_area_tag_redraw(CTX_wm_area(C)); | ||||
| } | } | ||||
| static void sequencer_add_movie_clamp_sound_strip_length(Scene *scene, | static void sequencer_add_movie_clamp_sound_strip_length(VideoEdit *video_edit, | ||||
| Sequence *seq_movie, | Sequence *seq_movie, | ||||
| Sequence *seq_sound) | Sequence *seq_sound) | ||||
| { | { | ||||
| if (ELEM(NULL, seq_movie, seq_sound)) { | if (ELEM(NULL, seq_movie, seq_sound)) { | ||||
| return; | return; | ||||
| } | } | ||||
| SEQ_time_right_handle_frame_set( | SEQ_time_right_handle_frame_set( | ||||
| scene, seq_sound, SEQ_time_right_handle_frame_get(scene, seq_movie)); | video_edit, seq_sound, SEQ_time_right_handle_frame_get(video_edit, seq_movie)); | ||||
| SEQ_time_left_handle_frame_set( | SEQ_time_left_handle_frame_set( | ||||
| scene, seq_sound, SEQ_time_left_handle_frame_get(scene, seq_movie)); | video_edit, seq_sound, SEQ_time_left_handle_frame_get(video_edit, seq_movie)); | ||||
| } | } | ||||
| static void sequencer_add_movie_multiple_strips(bContext *C, | static void sequencer_add_movie_multiple_strips(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| SeqLoadData *load_data, | SeqLoadData *load_data, | ||||
| SeqCollection *r_movie_strips) | SeqCollection *r_movie_strips) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| bool overlap_shuffle_override = RNA_boolean_get(op->ptr, "overlap") == false && | bool overlap_shuffle_override = RNA_boolean_get(op->ptr, "overlap") == false && | ||||
| RNA_boolean_get(op->ptr, "overlap_shuffle_override"); | RNA_boolean_get(op->ptr, "overlap_shuffle_override"); | ||||
| bool has_seq_overlap = false; | bool has_seq_overlap = false; | ||||
| SeqCollection *strip_col = NULL; | SeqCollection *strip_col = NULL; | ||||
| if (overlap_shuffle_override) { | if (overlap_shuffle_override) { | ||||
| strip_col = SEQ_collection_create(__func__); | strip_col = SEQ_collection_create(__func__); | ||||
| } | } | ||||
| RNA_BEGIN (op->ptr, itemptr, "files") { | RNA_BEGIN (op->ptr, itemptr, "files") { | ||||
| char dir_only[FILE_MAX]; | char dir_only[FILE_MAX]; | ||||
| char file_only[FILE_MAX]; | char file_only[FILE_MAX]; | ||||
| RNA_string_get(op->ptr, "directory", dir_only); | RNA_string_get(op->ptr, "directory", dir_only); | ||||
| RNA_string_get(&itemptr, "name", file_only); | RNA_string_get(&itemptr, "name", file_only); | ||||
| BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); | BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); | ||||
| BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); | BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); | ||||
| Sequence *seq_movie = NULL; | Sequence *seq_movie = NULL; | ||||
| Sequence *seq_sound = NULL; | Sequence *seq_sound = NULL; | ||||
| seq_movie = SEQ_add_movie_strip(bmain, scene, ed->seqbasep, load_data); | seq_movie = SEQ_add_movie_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| if (seq_movie == NULL) { | if (seq_movie == NULL) { | ||||
| BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | ||||
| } | } | ||||
| else { | else { | ||||
| if (RNA_boolean_get(op->ptr, "sound")) { | if (RNA_boolean_get(op->ptr, "sound")) { | ||||
| seq_sound = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data); | seq_sound = SEQ_add_sound_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| sequencer_add_movie_clamp_sound_strip_length(scene, seq_movie, seq_sound); | sequencer_add_movie_clamp_sound_strip_length(video_edit, seq_movie, seq_sound); | ||||
| if (seq_sound) { | if (seq_sound) { | ||||
| /* The video has sound, shift the video strip up a channel to make room for the sound | /* The video has sound, shift the video strip up a channel to make room for the sound | ||||
| * strip. */ | * strip. */ | ||||
| seq_movie->machine++; | seq_movie->machine++; | ||||
| } | } | ||||
| } | } | ||||
| load_data->start_frame += SEQ_time_right_handle_frame_get(scene, seq_movie) - | load_data->start_frame += SEQ_time_right_handle_frame_get(video_edit, seq_movie) - | ||||
| SEQ_time_left_handle_frame_get(scene, seq_movie); | SEQ_time_left_handle_frame_get(video_edit, seq_movie); | ||||
| if (overlap_shuffle_override) { | if (overlap_shuffle_override) { | ||||
| has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | ||||
| C, op, seq_sound, strip_col); | C, op, seq_sound, strip_col); | ||||
| has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | ||||
| C, op, seq_movie, strip_col); | C, op, seq_movie, strip_col); | ||||
| } | } | ||||
| else { | else { | ||||
| seq_load_apply_generic_options(C, op, seq_sound); | seq_load_apply_generic_options(C, op, seq_sound); | ||||
| seq_load_apply_generic_options(C, op, seq_movie); | seq_load_apply_generic_options(C, op, seq_movie); | ||||
| } | } | ||||
| SEQ_collection_append_strip(seq_movie, r_movie_strips); | SEQ_collection_append_strip(seq_movie, r_movie_strips); | ||||
| } | } | ||||
| } | } | ||||
| RNA_END; | RNA_END; | ||||
| if (overlap_shuffle_override) { | if (overlap_shuffle_override) { | ||||
| if (has_seq_overlap) { | if (has_seq_overlap) { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & | const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & | ||||
| SEQ_MARKER_TRANS) != 0; | SEQ_MARKER_TRANS) != 0; | ||||
| SEQ_transform_handle_overlap(scene, ed->seqbasep, strip_col, NULL, use_sync_markers); | SEQ_transform_handle_overlap( | ||||
| video_edit, video_edit->seqbasep, strip_col, NULL, use_sync_markers); | |||||
| } | } | ||||
| SEQ_collection_free(strip_col); | SEQ_collection_free(strip_col); | ||||
| } | } | ||||
| } | } | ||||
| static bool sequencer_add_movie_single_strip(bContext *C, | static bool sequencer_add_movie_single_strip(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| SeqLoadData *load_data, | SeqLoadData *load_data, | ||||
| SeqCollection *r_movie_strips) | SeqCollection *r_movie_strips) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| const Editing *ed = SEQ_editing_ensure(scene); | |||||
| Sequence *seq_movie = NULL; | Sequence *seq_movie = NULL; | ||||
| Sequence *seq_sound = NULL; | Sequence *seq_sound = NULL; | ||||
| seq_movie = SEQ_add_movie_strip(bmain, scene, ed->seqbasep, load_data); | seq_movie = SEQ_add_movie_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| if (seq_movie == NULL) { | if (seq_movie == NULL) { | ||||
| BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "sound")) { | if (RNA_boolean_get(op->ptr, "sound")) { | ||||
| seq_sound = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data); | seq_sound = SEQ_add_sound_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| sequencer_add_movie_clamp_sound_strip_length(scene, seq_movie, seq_sound); | sequencer_add_movie_clamp_sound_strip_length(video_edit, seq_movie, seq_sound); | ||||
| if (seq_sound) { | if (seq_sound) { | ||||
| /* The video has sound, shift the video strip up a channel to make room for the sound | /* The video has sound, shift the video strip up a channel to make room for the sound | ||||
| * strip. */ | * strip. */ | ||||
| seq_movie->machine++; | seq_movie->machine++; | ||||
| } | } | ||||
| } | } | ||||
| bool overlap_shuffle_override = RNA_boolean_get(op->ptr, "overlap") == false && | bool overlap_shuffle_override = RNA_boolean_get(op->ptr, "overlap") == false && | ||||
| RNA_boolean_get(op->ptr, "overlap_shuffle_override"); | RNA_boolean_get(op->ptr, "overlap_shuffle_override"); | ||||
| if (overlap_shuffle_override) { | if (overlap_shuffle_override) { | ||||
| SeqCollection *strip_col = SEQ_collection_create(__func__); | SeqCollection *strip_col = SEQ_collection_create(__func__); | ||||
| bool has_seq_overlap = false; | bool has_seq_overlap = false; | ||||
| has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | ||||
| C, op, seq_sound, strip_col); | C, op, seq_sound, strip_col); | ||||
| has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | has_seq_overlap |= seq_load_apply_generic_options_only_test_overlap( | ||||
| C, op, seq_movie, strip_col); | C, op, seq_movie, strip_col); | ||||
| if (has_seq_overlap) { | if (has_seq_overlap) { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & | const bool use_sync_markers = (((SpaceSeq *)area->spacedata.first)->flag & | ||||
| SEQ_MARKER_TRANS) != 0; | SEQ_MARKER_TRANS) != 0; | ||||
| SEQ_transform_handle_overlap(scene, ed->seqbasep, strip_col, NULL, use_sync_markers); | SEQ_transform_handle_overlap( | ||||
| video_edit, video_edit->seqbasep, strip_col, NULL, use_sync_markers); | |||||
| } | } | ||||
| SEQ_collection_free(strip_col); | SEQ_collection_free(strip_col); | ||||
| } | } | ||||
| else { | else { | ||||
| seq_load_apply_generic_options(C, op, seq_sound); | seq_load_apply_generic_options(C, op, seq_sound); | ||||
| seq_load_apply_generic_options(C, op, seq_movie); | seq_load_apply_generic_options(C, op, seq_movie); | ||||
| } | } | ||||
| SEQ_collection_append_strip(seq_movie, r_movie_strips); | SEQ_collection_append_strip(seq_movie, r_movie_strips); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| SeqCollection *movie_strips = SEQ_collection_create(__func__); | SeqCollection *movie_strips = SEQ_collection_create(__func__); | ||||
| const int tot_files = RNA_property_collection_length(op->ptr, | const int tot_files = RNA_property_collection_length(op->ptr, | ||||
| RNA_struct_find_property(op->ptr, "files")); | RNA_struct_find_property(op->ptr, "files")); | ||||
| if (tot_files > 1) { | if (tot_files > 1) { | ||||
| sequencer_add_movie_multiple_strips(C, op, &load_data, movie_strips); | sequencer_add_movie_multiple_strips(C, op, &load_data, movie_strips); | ||||
| } | } | ||||
| else { | else { | ||||
| sequencer_add_movie_single_strip(C, op, &load_data, movie_strips); | sequencer_add_movie_single_strip(C, op, &load_data, movie_strips); | ||||
| } | } | ||||
| if (SEQ_collection_len(movie_strips) == 0) { | if (SEQ_collection_len(movie_strips) == 0) { | ||||
| SEQ_collection_free(movie_strips); | SEQ_collection_free(movie_strips); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| seq_build_proxy(C, movie_strips); | seq_build_proxy(C, movie_strips); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| /* Free custom data. */ | /* Free custom data. */ | ||||
| sequencer_add_cancel(C, op); | sequencer_add_cancel(C, op); | ||||
| SEQ_collection_free(movie_strips); | SEQ_collection_free(movie_strips); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_movie_strip_invoke(bContext *C, | static int sequencer_add_movie_strip_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| sequencer_disable_one_time_properties(C, op); | sequencer_disable_one_time_properties(C, op); | ||||
| RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); | RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(video_edit)); | ||||
| RNA_boolean_set(op->ptr, "adjust_playback_rate", true); | RNA_boolean_set(op->ptr, "adjust_playback_rate", true); | ||||
| /* This is for drag and drop. */ | /* This is for drag and drop. */ | ||||
| if ((RNA_struct_property_is_set(op->ptr, "files") && | if ((RNA_struct_property_is_set(op->ptr, "files") && | ||||
| !RNA_collection_is_empty(op->ptr, "files")) || | !RNA_collection_is_empty(op->ptr, "files")) || | ||||
| RNA_struct_property_is_set(op->ptr, "filepath")) { | RNA_struct_property_is_set(op->ptr, "filepath")) { | ||||
| sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); | sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); | ||||
| return sequencer_add_movie_strip_exec(C, op); | return sequencer_add_movie_strip_exec(C, op); | ||||
| } | } | ||||
| sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE); | sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE); | ||||
| sequencer_add_init(C, op); | sequencer_add_init(C, op); | ||||
| /* Show multiview save options only if scene use multiview. */ | /* Show multiview save options only if video_edit use multiview. */ | ||||
| prop = RNA_struct_find_property(op->ptr, "show_multiview"); | prop = RNA_struct_find_property(op->ptr, "show_multiview"); | ||||
| RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); | RNA_property_boolean_set(op->ptr, prop, (video_edit->r.scemode & R_MULTIVIEW) != 0); | ||||
| WM_event_add_fileselect(C, op); | WM_event_add_fileselect(C, op); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) | static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) | ||||
| { | { | ||||
| uiLayout *layout = op->layout; | uiLayout *layout = op->layout; | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | RNA_def_boolean(ot->srna, | ||||
| "Use framerate from the movie to keep sound and video in sync"); | "Use framerate from the movie to keep sound and video in sync"); | ||||
| } | } | ||||
| static void sequencer_add_sound_multiple_strips(bContext *C, | static void sequencer_add_sound_multiple_strips(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| SeqLoadData *load_data) | SeqLoadData *load_data) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); | |||||
| RNA_BEGIN (op->ptr, itemptr, "files") { | RNA_BEGIN (op->ptr, itemptr, "files") { | ||||
| char dir_only[FILE_MAX]; | char dir_only[FILE_MAX]; | ||||
| char file_only[FILE_MAX]; | char file_only[FILE_MAX]; | ||||
| RNA_string_get(op->ptr, "directory", dir_only); | RNA_string_get(op->ptr, "directory", dir_only); | ||||
| RNA_string_get(&itemptr, "name", file_only); | RNA_string_get(&itemptr, "name", file_only); | ||||
| BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); | BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); | ||||
| BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); | BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); | ||||
| Sequence *seq = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data); | Sequence *seq = SEQ_add_sound_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| if (seq == NULL) { | if (seq == NULL) { | ||||
| BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | ||||
| } | } | ||||
| else { | else { | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| load_data->start_frame += SEQ_time_right_handle_frame_get(scene, seq) - | load_data->start_frame += SEQ_time_right_handle_frame_get(video_edit, seq) - | ||||
| SEQ_time_left_handle_frame_get(scene, seq); | SEQ_time_left_handle_frame_get(video_edit, seq); | ||||
| } | } | ||||
| } | } | ||||
| RNA_END; | RNA_END; | ||||
| } | } | ||||
| static bool sequencer_add_sound_single_strip(bContext *C, wmOperator *op, SeqLoadData *load_data) | static bool sequencer_add_sound_single_strip(bContext *C, wmOperator *op, SeqLoadData *load_data) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); | |||||
| Sequence *seq = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data); | Sequence *seq = SEQ_add_sound_strip(bmain, video_edit, video_edit->seqbasep, load_data); | ||||
| if (seq == NULL) { | if (seq == NULL) { | ||||
| BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); | ||||
| return false; | return false; | ||||
| } | } | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| const int tot_files = RNA_property_collection_length(op->ptr, | const int tot_files = RNA_property_collection_length(op->ptr, | ||||
| RNA_struct_find_property(op->ptr, "files")); | RNA_struct_find_property(op->ptr, "files")); | ||||
| if (tot_files > 1) { | if (tot_files > 1) { | ||||
| sequencer_add_sound_multiple_strips(C, op, &load_data); | sequencer_add_sound_multiple_strips(C, op, &load_data); | ||||
| } | } | ||||
| else { | else { | ||||
| if (!sequencer_add_sound_single_strip(C, op, &load_data)) { | if (!sequencer_add_sound_single_strip(C, op, &load_data)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| if (op->customdata) { | if (op->customdata) { | ||||
| MEM_freeN(op->customdata); | MEM_freeN(op->customdata); | ||||
| } | } | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_sound_strip_invoke(bContext *C, | static int sequencer_add_sound_strip_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | static int sequencer_add_image_strip_calculate_length(wmOperator *op, | ||||
| if (use_placeholders) { | if (use_placeholders) { | ||||
| return sequencer_image_seq_get_minmax_frame(op, start_frame, minframe, numdigits); | return sequencer_image_seq_get_minmax_frame(op, start_frame, minframe, numdigits); | ||||
| } | } | ||||
| return RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); | return RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); | ||||
| } | } | ||||
| static void sequencer_add_image_strip_load_files(wmOperator *op, | static void sequencer_add_image_strip_load_files(wmOperator *op, | ||||
| Scene *scene, | VideoEdit *video_edit, | ||||
| Sequence *seq, | Sequence *seq, | ||||
| SeqLoadData *load_data, | SeqLoadData *load_data, | ||||
| const int minframe, | const int minframe, | ||||
| const int numdigits) | const int numdigits) | ||||
| { | { | ||||
| const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); | const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); | ||||
| /* size of Strip->dir. */ | /* size of Strip->dir. */ | ||||
| char directory[768]; | char directory[768]; | ||||
| BLI_split_dir_part(load_data->path, directory, sizeof(directory)); | BLI_split_dir_part(load_data->path, directory, sizeof(directory)); | ||||
| SEQ_add_image_set_directory(seq, directory); | SEQ_add_image_set_directory(seq, directory); | ||||
| if (use_placeholders) { | if (use_placeholders) { | ||||
| sequencer_image_seq_reserve_frames( | sequencer_image_seq_reserve_frames( | ||||
| op, seq->strip->stripdata, load_data->image.len, minframe, numdigits); | op, seq->strip->stripdata, load_data->image.len, minframe, numdigits); | ||||
| } | } | ||||
| else { | else { | ||||
| size_t strip_frame = 0; | size_t strip_frame = 0; | ||||
| RNA_BEGIN (op->ptr, itemptr, "files") { | RNA_BEGIN (op->ptr, itemptr, "files") { | ||||
| char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL); | char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL); | ||||
| SEQ_add_image_load_file(scene, seq, strip_frame, filename); | SEQ_add_image_load_file(video_edit, seq, strip_frame, filename); | ||||
| MEM_freeN(filename); | MEM_freeN(filename); | ||||
| strip_frame++; | strip_frame++; | ||||
| } | } | ||||
| RNA_END; | RNA_END; | ||||
| } | } | ||||
| } | } | ||||
| static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); | |||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| int minframe, numdigits; | int minframe, numdigits; | ||||
| load_data.image.len = sequencer_add_image_strip_calculate_length( | load_data.image.len = sequencer_add_image_strip_calculate_length( | ||||
| op, load_data.start_frame, &minframe, &numdigits); | op, load_data.start_frame, &minframe, &numdigits); | ||||
| if (load_data.image.len == 0) { | if (load_data.image.len == 0) { | ||||
| sequencer_add_cancel(C, op); | sequencer_add_cancel(C, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| Sequence *seq = SEQ_add_image_strip(CTX_data_main(C), scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_image_strip( | ||||
| sequencer_add_image_strip_load_files(op, scene, seq, &load_data, minframe, numdigits); | CTX_data_main(C), video_edit, video_edit->seqbasep, &load_data); | ||||
| sequencer_add_image_strip_load_files(op, video_edit, seq, &load_data, minframe, numdigits); | |||||
| SEQ_add_image_init_alpha_mode(seq); | SEQ_add_image_init_alpha_mode(seq); | ||||
| /* Adjust length. */ | /* Adjust length. */ | ||||
| if (load_data.image.len == 1) { | if (load_data.image.len == 1) { | ||||
| SEQ_time_right_handle_frame_set(scene, seq, load_data.image.end_frame); | SEQ_time_right_handle_frame_set(video_edit, seq, load_data.image.end_frame); | ||||
| } | } | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| /* Free custom data. */ | /* Free custom data. */ | ||||
| sequencer_add_cancel(C, op); | sequencer_add_cancel(C, op); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_image_strip_invoke(bContext *C, | static int sequencer_add_image_strip_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| sequencer_disable_one_time_properties(C, op); | sequencer_disable_one_time_properties(C, op); | ||||
| RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(scene)); | RNA_enum_set(op->ptr, "fit_method", SEQ_tool_settings_fit_method_get(video_edit)); | ||||
| /* Name set already by drag and drop. */ | /* Name set already by drag and drop. */ | ||||
| if (RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) { | if (RNA_struct_property_is_set(op->ptr, "files") && !RNA_collection_is_empty(op->ptr, "files")) { | ||||
| sequencer_generic_invoke_xy__internal( | sequencer_generic_invoke_xy__internal( | ||||
| C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); | C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); | ||||
| return sequencer_add_image_strip_exec(C, op); | return sequencer_add_image_strip_exec(C, op); | ||||
| } | } | ||||
| sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE); | sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE); | ||||
| sequencer_add_init(C, op); | sequencer_add_init(C, op); | ||||
| /* Show multiview save options only if scene use multiview. */ | /* Show multiview save options only if video_edit use multiview. */ | ||||
| prop = RNA_struct_find_property(op->ptr, "show_multiview"); | prop = RNA_struct_find_property(op->ptr, "show_multiview"); | ||||
| RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); | RNA_property_boolean_set(op->ptr, prop, (video_edit->r.scemode & R_MULTIVIEW) != 0); | ||||
| WM_event_add_fileselect(C, op); | WM_event_add_fileselect(C, op); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) | void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 27 Lines | RNA_def_boolean(ot->srna, | ||||
| "use_placeholders", | "use_placeholders", | ||||
| false, | false, | ||||
| "Use Placeholders", | "Use Placeholders", | ||||
| "Use placeholders for missing frames of the strip"); | "Use placeholders for missing frames of the strip"); | ||||
| } | } | ||||
| static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) | static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | VideoEdit *video_edit = CTX_data_video_edit(C); | ||||
| Editing *ed = SEQ_editing_ensure(scene); | |||||
| const char *error_msg; | const char *error_msg; | ||||
| SeqLoadData load_data; | SeqLoadData load_data; | ||||
| load_data_init_from_operator(&load_data, C, op); | load_data_init_from_operator(&load_data, C, op); | ||||
| load_data.effect.type = RNA_enum_get(op->ptr, "type"); | load_data.effect.type = RNA_enum_get(op->ptr, "type"); | ||||
| Sequence *seq1, *seq2, *seq3; | Sequence *seq1, *seq2, *seq3; | ||||
| if (!seq_effect_find_selected( | if (!seq_effect_find_selected( | ||||
| scene, NULL, load_data.effect.type, &seq1, &seq2, &seq3, &error_msg)) { | video_edit, NULL, load_data.effect.type, &seq1, &seq2, &seq3, &error_msg)) { | ||||
| BKE_report(op->reports, RPT_ERROR, error_msg); | BKE_report(op->reports, RPT_ERROR, error_msg); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (RNA_boolean_get(op->ptr, "replace_sel")) { | if (RNA_boolean_get(op->ptr, "replace_sel")) { | ||||
| ED_sequencer_deselect_all(scene); | ED_sequencer_deselect_all(video_edit); | ||||
| } | } | ||||
| load_data.effect.seq1 = seq1; | load_data.effect.seq1 = seq1; | ||||
| load_data.effect.seq2 = seq2; | load_data.effect.seq2 = seq2; | ||||
| load_data.effect.seq3 = seq3; | load_data.effect.seq3 = seq3; | ||||
| /* Set channel. If unset, use lowest free one above strips. */ | /* Set channel. If unset, use lowest free one above strips. */ | ||||
| if (!RNA_struct_property_is_set(op->ptr, "channel")) { | if (!RNA_struct_property_is_set(op->ptr, "channel")) { | ||||
| if (seq1 != NULL) { | if (seq1 != NULL) { | ||||
| int chan = max_iii( | int chan = max_iii( | ||||
| seq1 ? seq1->machine : 0, seq2 ? seq2->machine : 0, seq3 ? seq3->machine : 0); | seq1 ? seq1->machine : 0, seq2 ? seq2->machine : 0, seq3 ? seq3->machine : 0); | ||||
| if (chan < MAXSEQ) { | if (chan < MAXSEQ) { | ||||
| load_data.channel = chan; | load_data.channel = chan; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Sequence *seq = SEQ_add_effect_strip(scene, ed->seqbasep, &load_data); | Sequence *seq = SEQ_add_effect_strip(video_edit, video_edit->seqbasep, &load_data); | ||||
| seq_load_apply_generic_options(C, op, seq); | seq_load_apply_generic_options(C, op, seq); | ||||
| if (seq->type == SEQ_TYPE_COLOR) { | if (seq->type == SEQ_TYPE_COLOR) { | ||||
| SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; | ||||
| RNA_float_get_array(op->ptr, "color", colvars->col); | RNA_float_get_array(op->ptr, "color", colvars->col); | ||||
| } | } | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&video_edit->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); | WM_event_add_notifier(C, NC_VIDEO_EDIT | ND_SEQUENCER, video_edit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int sequencer_add_effect_strip_invoke(bContext *C, | static int sequencer_add_effect_strip_invoke(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||