diff options
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 238 |
1 files changed, 75 insertions, 163 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 278fb9fb683..049f3d76b53 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -51,8 +51,7 @@ #include "RNA_define.h" #include "RNA_enum_types.h" -/* for menu/popup icons etc etc*/ - +/* For menu, popup, icons, etc. */ #include "ED_screen.h" #include "ED_sequencer.h" @@ -67,16 +66,16 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" -/* own include */ +/* Own include. */ #include "sequencer_intern.h" typedef struct SequencerAddData { ImageFormatData im_format; } SequencerAddData; -/* Generic functions, reused by add strip operators */ +/* Generic functions, reused by add strip operators. */ -/* avoid passing multiple args and be more verbose */ +/* Avoid passing multiple args and be more verbose. */ #define SEQPROP_STARTFRAME (1 << 0) #define SEQPROP_ENDFRAME (1 << 1) #define SEQPROP_NOPATHS (1 << 2) @@ -101,7 +100,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) } if (flag & SEQPROP_ENDFRAME) { - /* not usual since most strips have a fixed length */ + /* Not usual since most strips have a fixed length. */ RNA_def_int(ot->srna, "frame_end", 0, @@ -119,7 +118,7 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_boolean( ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection"); - /* only for python scripts which import strips and place them after */ + /* Only for python scripts which import strips and place them after. */ prop = RNA_def_boolean( ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips"); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -175,7 +174,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i int cfra = (int)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) { RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type)); } @@ -203,18 +202,17 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato memset(seq_load, 0, sizeof(SeqLoadInfo)); seq_load->start_frame = RNA_int_get(op->ptr, "frame_start"); - seq_load->end_frame = seq_load->start_frame; /* un-set */ - + seq_load->end_frame = seq_load->start_frame; seq_load->channel = RNA_int_get(op->ptr, "channel"); - seq_load->len = 1; // images only, if endframe isn't set! + seq_load->len = 1; if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { - /* full path, file is set by the caller */ + /* Full path, file is set by the caller. */ RNA_property_string_get(op->ptr, prop, seq_load->path); is_file = 1; } else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { - /* full path, file is set by the caller */ + /* Full path, file is set by the caller. */ RNA_property_string_get(op->ptr, prop, seq_load->path); is_file = 0; } @@ -252,15 +250,13 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato seq_load->flag |= SEQ_LOAD_SYNC_FPS; } - /* always use this for ops */ + /* Create consecutive array of strips. */ seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE; if (is_file == 1) { BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name)); } else if ((prop = RNA_struct_find_property(op->ptr, "files"))) { - /* used for image strip */ - /* best guess, first images name */ RNA_PROP_BEGIN (op->ptr, itemptr, prop) { char *name = RNA_string_get_alloc(&itemptr, "name", NULL, 0); BLI_strncpy(seq_load->name, name, sizeof(seq_load->name)); @@ -278,9 +274,6 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato seq_load->views_format = imf->views_format; seq_load->flag |= SEQ_USE_VIEWS; - - /* operator custom data is always released after the SeqLoadInfo, - * no need to handle the memory here */ seq_load->stereo3d_format = &imf->stereo3d_format; } } @@ -332,22 +325,17 @@ static bool seq_effect_add_properties_poll(const bContext *UNUSED(C), return true; } -/* add scene operator */ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - Scene *sce_seq; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - sce_seq = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); if (sce_seq == NULL) { @@ -356,11 +344,8 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) } seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_SCENE); - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ - + seq->blend_mode = SEQ_TYPE_CROSS; seq->scene = sce_seq; - - /* basic defaults */ seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2); @@ -388,26 +373,23 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const w sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE); return sequencer_add_scene_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Scene Strip"; ot->idname = "SEQUENCER_OT_scene_strip_add"; ot->description = "Add a strip to the sequencer using a blender scene as a source"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_scene_strip_invoke; ot->exec = sequencer_add_scene_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -417,22 +399,17 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) ot->prop = prop; } -/* add movieclip operator */ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - MovieClip *clip; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - clip = BLI_findlink(&bmain->movieclips, RNA_enum_get(op->ptr, "clip")); if (clip == NULL) { @@ -443,12 +420,10 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MOVIECLIP); seq->blend_mode = SEQ_TYPE_CROSS; seq->clip = clip; + seq->len = BKE_movieclip_get_duration(clip); id_us_ensure_real(&seq->clip->id); - /* basic defaults */ - seq->len = BKE_movieclip_get_duration(clip); - BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); @@ -473,26 +448,23 @@ static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, con sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP); return sequencer_add_movieclip_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add MovieClip Strip"; ot->idname = "SEQUENCER_OT_movieclip_strip_add"; ot->description = "Add a movieclip strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_movieclip_strip_invoke; ot->exec = sequencer_add_movieclip_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -508,16 +480,12 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - Mask *mask; + Sequence *seq; - Sequence *seq; /* generic strip vars */ - - int start_frame, channel; /* operator props */ - + int start_frame, channel; start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - mask = BLI_findlink(&bmain->masks, RNA_enum_get(op->ptr, "mask")); if (mask == NULL) { @@ -528,12 +496,10 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, SEQ_TYPE_MASK); seq->blend_mode = SEQ_TYPE_CROSS; seq->mask = mask; + seq->len = BKE_mask_get_duration(mask); id_us_ensure_real(&seq->mask->id); - /* basic defaults */ - seq->len = BKE_mask_get_duration(mask); - BLI_strncpy(seq->name + 2, mask->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); @@ -558,26 +524,23 @@ static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wm sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK); return sequencer_add_mask_strip_exec(C, op); - // needs a menu - // return WM_menu_invoke(C, op, event); } void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Mask Strip"; ot->idname = "SEQUENCER_OT_mask_strip_add"; ot->description = "Add a mask strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_mask_strip_invoke; ot->exec = sequencer_add_mask_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); @@ -589,7 +552,7 @@ void SEQUENCER_OT_mask_strip_add(struct wmOperatorType *ot) static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFn seq_load_fn) { - Scene *scene = CTX_data_scene(C); /* only for sound */ + Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); SeqLoadInfo seq_load; int tot_files; @@ -603,7 +566,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); if (tot_files > 1) { - /* multiple files */ char dir_only[FILE_MAX]; char file_only[FILE_MAX]; @@ -614,7 +576,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad RNA_string_get(&itemptr, "name", file_only); BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only); - /* Set seq_load.name, else all video/audio files get the same name! ugly! */ + /* Set seq_load.name, otherwise all video/audio files get the same name. */ BLI_strncpy(seq_load.name, file_only, sizeof(seq_load.name)); seq = seq_load_fn(C, ed->seqbasep, &seq_load); @@ -627,11 +589,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } RNA_END; } - else { + else { /* Single file./ */ Sequence *seq; - - /* single file */ seq = seq_load_fn(C, ed->seqbasep, &seq_load); + if (seq) { sequencer_add_apply_overlap(C, op, seq); if (seq_load.seq_sound) { @@ -658,7 +619,6 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad return OPERATOR_FINISHED; } -/* add sequencer operators */ static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op) { op->customdata = MEM_callocN(sizeof(SequencerAddData), __func__); @@ -673,8 +633,8 @@ static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op) } static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr), - PropertyRNA *prop, - void *UNUSED(user_data)) + PropertyRNA *prop, + void *UNUSED(user_data)) { const char *prop_id = RNA_property_identifier(prop); @@ -682,7 +642,6 @@ static bool sequencer_add_draw_check_fn(PointerRNA *UNUSED(ptr), STREQ(prop_id, "filename")); } -/* add movie operator */ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) { return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_movie_strip); @@ -696,20 +655,12 @@ static int sequencer_add_movie_strip_invoke(bContext *C, Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); - /* only enable "use_framerate" if there aren't any existing strips - * - When there are no strips yet, there is no harm in enabling this, - * and it makes the single-strip case really nice for casual users - * - When there are strips, it's best we don't touch the framerate, - * as all hell may break loose (e.g. audio strips start overlapping - * and can't be restored) - * - These initial guesses can still be manually overridden by users - * from the modal options panel - */ + /* Only enable "use_framerate" if there aren't any existing strips, unless overriden by user. */ if (ed && ed->seqbasep && ed->seqbasep->first) { RNA_boolean_set(op->ptr, "use_framerate", false); } - /* This is for drag and drop */ + /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); @@ -717,17 +668,14 @@ static int sequencer_add_movie_strip_invoke(bContext *C, } sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE); - sequencer_add_init(C, op); - /* show multiview save options only if scene has multiviews */ + /* Show multiview save options only if scene use multiview. */ prop = RNA_struct_find_property(op->ptr, "show_multiview"); RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - // return sequencer_add_movie_strip_exec(C, op); } static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) @@ -737,15 +685,15 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) ImageFormatData *imf = &sad->im_format; PointerRNA imf_ptr, ptr; - /* main draw call */ + /* Main draw call. */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); uiDefAutoButsRNA( layout, &ptr, sequencer_add_draw_check_fn, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false); - /* image template */ + /* Image template. */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); - /* multiview template */ + /* Multiview template. */ if (RNA_boolean_get(op->ptr, "show_multiview")) { uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); } @@ -754,20 +702,19 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Movie Strip"; ot->idname = "SEQUENCER_OT_movie_strip_add"; ot->description = "Add a movie strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_movie_strip_invoke; ot->exec = sequencer_add_movie_strip_exec; ot->cancel = sequencer_add_cancel; ot->ui = sequencer_add_draw; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -787,8 +734,6 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) "Use framerate from the movie to keep sound and video in sync"); } -/* add sound operator */ - static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) { return sequencer_add_generic_strip_exec(C, op, BKE_sequencer_add_sound_strip); @@ -798,7 +743,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - /* This is for drag and drop */ + /* This is for drag and drop. */ if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); @@ -809,25 +754,22 @@ static int sequencer_add_sound_strip_invoke(bContext *C, WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - - // return sequencer_add_sound_strip_exec(C, op); } void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Sound Strip"; ot->idname = "SEQUENCER_OT_sound_strip_add"; ot->description = "Add a sound strip to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_sound_strip_invoke; ot->exec = sequencer_add_sound_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -854,7 +796,6 @@ int sequencer_image_seq_get_minmax_frame(wmOperator *op, RNA_BEGIN (op->ptr, itemptr, "files") { char *filename; int frame; - /* just get the first filename */ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); if (filename) { @@ -885,7 +826,6 @@ void sequencer_image_seq_reserve_frames( int i; char *filename = NULL; RNA_BEGIN (op->ptr, itemptr, "files") { - /* just get the first filename */ filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); break; } @@ -894,7 +834,7 @@ void sequencer_image_seq_reserve_frames( if (filename) { char ext[PATH_MAX]; char filename_stripped[PATH_MAX]; - /* strip the frame from filename and substitute with # */ + /* Strip the frame from filename and substitute with `#`. */ BLI_path_frame_strip(filename, ext); for (i = 0; i < len; i++, se++) { @@ -907,23 +847,20 @@ void sequencer_image_seq_reserve_frames( } } -/* add image operator */ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) { int minframe, numdigits; - /* cant use the generic function for this */ - Scene *scene = CTX_data_scene(C); /* only for sound */ + Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); SeqLoadInfo seq_load; Sequence *seq; - Strip *strip; StripElem *se; const bool use_placeholders = RNA_boolean_get(op->ptr, "use_placeholders"); seq_load_operator_info(&seq_load, C, op); - /* images are unique in how they handle this - 1 per strip elem */ + /* Images are unique in how they handle this - 1 per strip elem. */ if (use_placeholders) { seq_load.len = sequencer_image_seq_get_minmax_frame( op, seq_load.start_frame, &minframe, &numdigits); @@ -941,11 +878,10 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) ED_sequencer_deselect_all(scene); } - /* main adding function */ + /* Main adding function. */ seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load); strip = seq->strip; se = strip->stripdata; - seq->blend_mode = SEQ_TYPE_ALPHAOVER; if (use_placeholders) { @@ -968,21 +904,18 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } BKE_sequence_init_colorspace(seq); - BKE_sequence_calc_disp(scene, seq); - BKE_sequencer_sort(scene); - /* last active name */ + /* Last active name. */ BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir)); - sequencer_add_apply_overlap(C, op, seq); if (op->customdata) { MEM_freeN(op->customdata); } - BKE_sequence_invalidate_cache_composite(scene, seq); + BKE_sequence_invalidate_cache_composite(scene, seq); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -996,7 +929,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, PropertyRNA *prop; Scene *scene = CTX_data_scene(C); - /* drag drop has set the names */ + /* Name set already by drag and drop. */ if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { sequencer_generic_invoke_xy__internal( C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); @@ -1004,10 +937,9 @@ static int sequencer_add_image_strip_invoke(bContext *C, } sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE); - sequencer_add_init(C, op); - /* show multiview save options only if scene has multiviews */ + /* Show multiview save options only if scene use multiview. */ prop = RNA_struct_find_property(op->ptr, "show_multiview"); RNA_property_boolean_set(op->ptr, prop, (scene->r.scemode & R_MULTIVIEW) != 0); @@ -1018,20 +950,19 @@ static int sequencer_add_image_strip_invoke(bContext *C, void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) { - /* identifiers */ + /* Identifiers. */ ot->name = "Add Image Strip"; ot->idname = "SEQUENCER_OT_image_strip_add"; ot->description = "Add an image or image sequence to the sequencer"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_image_strip_invoke; ot->exec = sequencer_add_image_strip_exec; ot->cancel = sequencer_add_cancel; ot->ui = sequencer_add_draw; - ot->poll = ED_operator_sequencer_active_editable; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_filesel(ot, @@ -1051,65 +982,54 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) "Use placeholders for missing frames of the strip"); } -/* add_effect_strip operator */ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - - Sequence *seq; /* generic strip vars */ + Sequence *seq; struct SeqEffectHandle sh; - - int start_frame, end_frame, channel, type; /* operator props */ - Sequence *seq1, *seq2, *seq3; const char *error_msg; + int start_frame, end_frame, channel, type; start_frame = RNA_int_get(op->ptr, "frame_start"); end_frame = RNA_int_get(op->ptr, "frame_end"); channel = RNA_int_get(op->ptr, "channel"); - type = RNA_enum_get(op->ptr, "type"); - // XXX move to invoke if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } - /* If seq1 is NULL and no error was raised it means the seq is standalone - * (like color strips) and we need to check its start and end frames are valid */ + /* Check its start and end frames are valid. */ if (seq1 == NULL && end_frame <= start_frame) { end_frame = start_frame + 1; RNA_int_set(op->ptr, "frame_end", end_frame); } seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel, type); - BLI_strncpy(seq->name + 2, BKE_sequence_give_name(seq), sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); sh = BKE_sequence_get_effect(seq); - + sh.init(seq); seq->seq1 = seq1; seq->seq2 = seq2; seq->seq3 = seq3; - sh.init(seq); - - if (!seq1) { /* effect has no deps */ - seq->len = 1; + if (!seq1) { + seq->len = 1; /* Effect is generator, set non zero length. */ BKE_sequence_tx_set_final_right(seq, end_frame); } seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; - BKE_sequence_calc(scene, seq); if (seq->type == SEQ_TYPE_COLOR) { SolidColorVars *colvars = (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); - seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ + seq->blend_mode = SEQ_TYPE_CROSS; } else if (seq->type == SEQ_TYPE_ADJUSTMENT) { seq->blend_mode = SEQ_TYPE_CROSS; @@ -1118,8 +1038,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->blend_mode = SEQ_TYPE_ALPHAOVER; } - /* an unset channel is a special case where we automatically go above - * the other strips. */ + /* Set channel.*/ if (!RNA_struct_property_is_set(op->ptr, "channel")) { if (seq->seq1) { int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0, @@ -1134,20 +1053,16 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); - BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* runs BKE_sequence_calc */ - - /* not sure if this is needed with update_changed_seq_and_deps. - * it was NOT called in blender 2.4x, but wont hurt */ + BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); /* Runs BKE_sequence_calc. */ BKE_sequencer_sort(scene); - BKE_sequence_invalidate_cache_composite(scene, seq); + BKE_sequence_invalidate_cache_composite(scene, seq); DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; } -/* add color */ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -1159,10 +1074,8 @@ static int sequencer_add_effect_strip_invoke(bContext *C, if (is_type_set) { type = RNA_enum_get(op->ptr, "type"); - /* when invoking an effect strip which uses inputs, - * skip initializing the channel from the mouse. - * Instead leave the property unset so exec() initializes it to be - * above the strips its applied to. */ + /* When invoking an effect strip which uses inputs, skip initializing the channel from the + * mouse. */ if (BKE_sequence_effect_get_num_inputs(type) != 0) { prop_flag |= SEQPROP_NOCHAN; } @@ -1177,19 +1090,18 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - /* identifiers */ + /* Identifiers. */ ot->name = "Add Effect Strip"; ot->idname = "SEQUENCER_OT_effect_strip_add"; ot->description = "Add an effect to the sequencer, most are applied on top of existing strips"; - /* api callbacks */ + /* Api callbacks. */ ot->invoke = sequencer_add_effect_strip_invoke; ot->exec = sequencer_add_effect_strip_exec; - ot->poll = ED_operator_sequencer_active_editable; ot->poll_property = seq_effect_add_properties_poll; - /* flags */ + /* Flags. */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, |