Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_sequencer_api.c
| Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | static Sequence *rna_Sequences_new_image(ID *id, | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); | WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); | ||||
| return seq; | return seq; | ||||
| } | } | ||||
| static Sequence *rna_Sequences_new_movie(ID *id, | static Sequence *rna_Sequences_new_movie( | ||||
| Editing *ed, | ID *id, Editing *ed, const char *name, const char *file, int channel, int frame_start) | ||||
| ReportList *reports, | |||||
| const char *name, | |||||
| const char *file, | |||||
| int channel, | |||||
| int frame_start) | |||||
| { | { | ||||
| Scene *scene = (Scene *)id; | Scene *scene = (Scene *)id; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| StripAnim *sanim; | StripAnim *sanim; | ||||
| struct anim *an = openanim(file, IB_rect, 0, NULL); | seq = alloc_generic_sequence(ed, name, frame_start, channel, SEQ_TYPE_MOVIE, file); | ||||
| struct anim *an = openanim(file, IB_rect, 0, NULL); | |||||
| if (an == NULL) { | if (an == NULL) { | ||||
| BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file"); | /* Without anim, the strip gets duration 0, which makes it impossible to select in the UI. */ | ||||
| return NULL; | seq->len = 1; | ||||
| } | } | ||||
| else { | |||||
| seq = alloc_generic_sequence(ed, name, frame_start, channel, SEQ_TYPE_MOVIE, file); | |||||
| sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim"); | sanim = MEM_mallocN(sizeof(StripAnim), "Strip Anim"); | ||||
| BLI_addtail(&seq->anims, sanim); | BLI_addtail(&seq->anims, sanim); | ||||
| sanim->anim = an; | sanim->anim = an; | ||||
ISS: I don't think using `openanim_attempt_load` is best approach. You really need it only to set… | |||||
| seq->anim_preseek = IMB_anim_get_preseek(an); | seq->anim_preseek = IMB_anim_get_preseek(an); | ||||
| seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); | seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); | ||||
| } | |||||
| BKE_sequence_calc_disp(scene, seq); | BKE_sequence_calc_disp(scene, seq); | ||||
| BKE_sequence_invalidate_cache_composite(scene, seq); | BKE_sequence_invalidate_cache_composite(scene, seq); | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS); | ||||
| WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); | WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); | ||||
| return seq; | return seq; | ||||
| ▲ Show 20 Lines • Show All 419 Lines • ▼ Show 20 Lines | parm = RNA_def_int(func, | ||||
| -MAXFRAME, | -MAXFRAME, | ||||
| MAXFRAME); | MAXFRAME); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| /* return type */ | /* return type */ | ||||
| parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); | parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie"); | func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); | RNA_def_function_flag(func, FUNC_USE_SELF_ID); | ||||
| RNA_def_function_ui_description(func, "Add a new movie sequence"); | RNA_def_function_ui_description(func, "Add a new movie sequence"); | ||||
| parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); | parm = RNA_def_string(func, "name", "Name", 0, "", "Name for the new sequence"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); | parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| parm = RNA_def_int( | parm = RNA_def_int( | ||||
| func, "channel", 0, 1, MAXSEQ, "Channel", "The channel for the new sequence", 1, MAXSEQ); | func, "channel", 0, 1, MAXSEQ, "Channel", "The channel for the new sequence", 1, MAXSEQ); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| ▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines | |||||
I don't think using openanim_attempt_load is best approach. You really need it only to set preseek and length. Instead you should do this in rna_MovieSequence_reload_if_needed and skip this part of initialization if anim is NULL.