sequencer support for loading multiple movie and sounds at once.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 14 Nov 2009 19:26:58 +0000 (19:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 14 Nov 2009 19:26:58 +0000 (19:26 +0000)
- more api like functions for adding movie, sound & images (easier to use from pyrna api)
- operators share more settings
- renamed get_last_seq() to active_seq_get() - same for set.

source/blender/blenkernel/BKE_sequence.h
source/blender/blenkernel/intern/sequence.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/sequencer_select.c

index 05129c73b035ffab0b9efc8740196334e27d8b3c..713d2dcad439110742d290fdfa5721cec67971c9 100644 (file)
@@ -189,4 +189,36 @@ void seq_update_sound(struct Sequence *seq);
 
 void clear_scene_in_allseqs(struct Scene *sce);
 
+struct Sequence *active_seq_get(struct Scene *scene);
+void active_seq_set(struct Scene *scene, struct Sequence *seq);
+
+/* api for adding new sequence strips */
+typedef struct SeqLoadInfo {
+       int start_frame;
+       int channel;
+       int flag;       /* use sound, replace sel */
+       int type;
+       int tot_success;
+       int tot_error;
+       int len;                /* only for image strips */
+       char path[512];
+       char name[32];
+} SeqLoadInfo;
+
+/* SeqLoadInfo.flag */
+#define SEQ_LOAD_REPLACE_SEL   1<<0
+#define SEQ_LOAD_FRAME_ADVANCE 1<<1
+#define SEQ_LOAD_MOVIE_SOUND   1<<2
+#define SEQ_LOAD_SOUND_CACHE   1<<3
+
+/* use as an api function */
+typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *);
+
+struct Sequence *alloc_sequence(ListBase *lb, int cfra, int machine);
+
+void seq_load_apply(struct Scene *scene, struct Sequence *seq, struct SeqLoadInfo *seq_load);
+
+struct Sequence *sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
+struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
+struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
 
index fd28123c5d8196a91a794196c115fb4474cb6602..f892c7b0057a1b32cbf2ebe89ab9d9a504eef8c7 100644 (file)
@@ -3510,3 +3510,193 @@ void seq_update_sound(struct Sequence *seq)
                seq->sound_handle->changed = -1;
        }
 }
+
+Sequence *active_seq_get(Scene *scene)
+{
+       Editing *ed= seq_give_editing(scene, FALSE);
+       if(ed==NULL) return NULL;
+       return ed->act_seq;
+}
+
+void active_seq_set(Scene *scene, Sequence *seq)
+{
+       Editing *ed= seq_give_editing(scene, FALSE);
+       if(ed==NULL) return;
+
+       ed->act_seq= seq;
+}
+
+/* api like funcs for adding */
+
+void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
+{
+       if(seq) {
+               strcpy(seq->name, seq_load->name);
+
+               if(seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
+                       seq_load->start_frame += (seq->enddisp - seq->startdisp);
+               }
+
+               if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) {
+                       seq_load->flag |= 1; /* SELECT */
+                       active_seq_set(scene, seq);
+               }
+
+               if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) {
+                       if(seq->sound)
+                               sound_cache(seq->sound, 0);
+               }
+
+               seq_load->tot_success++;
+       }
+       else {
+               seq_load->tot_error++;
+       }
+}
+
+Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
+{
+       Sequence *seq;
+
+       seq= MEM_callocN( sizeof(Sequence), "addseq");
+       BLI_addtail(lb, seq);
+
+       *( (short *)seq->name )= ID_SEQ;
+       seq->name[2]= 0;
+
+       seq->flag= 1; /* SELECT */
+       seq->start= cfra;
+       seq->machine= machine;
+       seq->mul= 1.0;
+       seq->blend_opacity = 100.0;
+
+       return seq;
+}
+
+/* NOTE: this function doesn't fill in iamge names */
+Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+       Scene *scene= CTX_data_scene(C); /* only for active seq */
+       Sequence *seq;
+       Strip *strip;
+       StripElem *se;
+
+       seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
+       seq->type= SEQ_IMAGE;
+
+       /* basic defaults */
+       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+
+       strip->len = seq->len = seq_load->len ? seq_load->len : 1;
+       strip->us= 1;
+       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+
+       seq_load_apply(scene, seq, seq_load);
+
+       return seq;
+}
+
+Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+       Scene *scene= CTX_data_scene(C); /* only for sound */
+       Editing *ed= seq_give_editing(scene, TRUE);
+       bSound *sound;
+
+       Sequence *seq;  /* generic strip vars */
+       Strip *strip;
+       StripElem *se;
+
+       AUD_SoundInfo info;
+
+       sound = sound_new_file(CTX_data_main(C), seq_load->path);
+
+       if (sound==NULL || sound->handle == NULL) {
+               //if(op)
+               //      BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
+               return NULL;
+       }
+
+       info = AUD_getInfo(sound->handle);
+
+       if (info.specs.format == AUD_FORMAT_INVALID) {
+               sound_delete(C, sound);
+               //if(op)
+               //      BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
+               return NULL;
+       }
+
+       seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
+
+       seq->type= SEQ_SOUND;
+       seq->sound= sound;
+
+       /* basic defaults */
+       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+       strip->len = seq->len = (int) (info.length * FPS);
+       strip->us= 1;
+
+       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+
+       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+
+       seq->sound_handle = sound_new_handle(scene, sound, seq_load->start_frame, seq_load->start_frame + strip->len, 0);
+
+       calc_sequence_disp(seq);
+
+       /* last active name */
+       strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
+
+       seq_load_apply(scene, seq, seq_load);
+
+       return seq;
+}
+
+Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+       Scene *scene= CTX_data_scene(C); /* only for sound */
+
+       Sequence *seq, *soundseq;       /* generic strip vars */
+       Strip *strip;
+       StripElem *se;
+
+       struct anim *an;
+
+       an = openanim(seq_load->path, IB_rect);
+
+       if(an==NULL)
+               return NULL;
+
+       seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel);
+
+       seq->type= SEQ_MOVIE;
+       seq->anim= an;
+       seq->anim_preseek = IMB_anim_get_preseek(an);
+
+       /* basic defaults */
+       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
+       strip->len = seq->len = IMB_anim_get_duration( an );
+       strip->us= 1;
+
+       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+
+       BLI_split_dirfile_basic(seq_load->path, strip->dir, se->name);
+
+       calc_sequence_disp(seq);
+
+
+       if(seq_load->flag & SEQ_LOAD_MOVIE_SOUND) {
+               int start_frame_back= seq_load->start_frame;
+               seq_load->channel++;
+
+               soundseq = sequencer_add_sound_strip(C, seqbasep, seq_load);
+
+               seq_load->start_frame= start_frame_back;
+               seq_load->channel--;
+       }
+
+       /* can be NULL */
+       seq_load_apply(scene, seq, seq_load);
+
+       return seq;
+}
index 824dbd1caa851cd4ff3bfabb860fde2f4863d2f2..9aaf205f5d93ffc1c22e84e496de1f0a5a089402 100644 (file)
 /* avoid passing multiple args and be more verbose */
 #define SEQPROP_STARTFRAME     1<<0
 #define SEQPROP_ENDFRAME       1<<1
+#define SEQPROP_FILES          1<<2
 
 static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
 {
@@ -114,6 +115,9 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
        RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ);
        
        RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection");
+
+       if(flag & SEQPROP_FILES)
+               RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
 }
 
 static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, wmEvent *event, int flag)
@@ -138,6 +142,31 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w
        
 }
 
+static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
+{
+       memset(seq_load, 0, sizeof(SeqLoadInfo));
+
+       seq_load->start_frame=  RNA_int_get(op->ptr, "start_frame");
+       seq_load->channel=              RNA_int_get(op->ptr, "channel");
+       seq_load->len=                  1; // images only!
+
+       RNA_string_get(op->ptr, "name", seq_load->name);
+
+       RNA_string_get(op->ptr, "path", seq_load->path); /* full path, file is set by the caller */
+
+       if (RNA_struct_find_property(op->ptr, "replace_sel") && RNA_boolean_get(op->ptr, "replace_sel"))
+               seq_load->flag |= SEQ_LOAD_REPLACE_SEL;
+
+       if (RNA_struct_find_property(op->ptr, "cache") && RNA_boolean_get(op->ptr, "cache"))
+               seq_load->flag |= SEQ_LOAD_SOUND_CACHE;
+
+       if (RNA_struct_find_property(op->ptr, "sound") && RNA_boolean_get(op->ptr, "sound"))
+               seq_load->flag |= SEQ_LOAD_MOVIE_SOUND;
+
+       /* always use this for ops */
+       seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE;
+}
+
 /* add scene operator */
 static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
 {
@@ -185,7 +214,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
        
        if (RNA_boolean_get(op->ptr, "replace_sel")) {
                deselect_all_seq(scene);
-               set_last_seq(scene, seq);
+               active_seq_set(scene, seq);
                seq->flag |= SELECT;
        }
        
@@ -227,127 +256,57 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
        RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip");
 }
 
-static Sequence* sequencer_add_sound_strip(bContext *C, wmOperator *op, int start_frame, int channel, char* filename)
+static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func)
 {
-       Scene *scene= CTX_data_scene(C);
+       Scene *scene= CTX_data_scene(C); /* only for sound */
        Editing *ed= seq_give_editing(scene, TRUE);
+       SeqLoadInfo seq_load;
+       Sequence *seq;
+       int tot_files;
 
-       bSound *sound;
+       seq_load_operator_info(&seq_load, op);
 
-       Sequence *seq;  /* generic strip vars */
-       Strip *strip;
-       StripElem *se;
+       if (seq_load.flag & SEQ_LOAD_REPLACE_SEL)
+               deselect_all_seq(scene);
 
-       AUD_SoundInfo info;
+       tot_files= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
 
-       sound = sound_new_file(CTX_data_main(C), filename);
+       if(tot_files) {
+               /* multiple files */
+               char dir_only[FILE_MAX];
+               char file_only[FILE_MAX];
 
-       if (sound==NULL || sound->handle == NULL) {
-               if(op)
-                       BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
-               return NULL;
-       }
+               BLI_split_dirfile_basic(seq_load.path, dir_only, NULL);
 
-       info = AUD_getInfo(sound->handle);
+               RNA_BEGIN(op->ptr, itemptr, "files") {
+                       RNA_string_get(&itemptr, "name", file_only);
+                       BLI_join_dirfile(seq_load.path, dir_only, file_only);
 
-       if (info.specs.format == AUD_FORMAT_INVALID) {
-               sound_delete(C, sound);
-               if(op)
-                       BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
-               return NULL;
+                       seq= seq_load_func(C, ed->seqbasep, &seq_load);
+               }
+               RNA_END;
+       }
+       else {
+               /* single file */
+               seq= seq_load_func(C, ed->seqbasep, &seq_load);
        }
 
-       seq = alloc_sequence(ed->seqbasep, start_frame, channel);
-
-       seq->type= SEQ_SOUND;
-       seq->sound= sound;
-
-       /* basic defaults */
-       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
-       strip->len = seq->len = (int) (info.length * FPS);
-       strip->us= 1;
-
-       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-
-       BLI_split_dirfile_basic(filename, strip->dir, se->name);
-
-       seq->sound_handle = sound_new_handle(scene, sound, start_frame, start_frame + strip->len, 0);
+       if (seq_load.tot_success==0) {
+               BKE_reportf(op->reports, RPT_ERROR, "File \"%s\" could not be loaded", seq_load.path);
+               return OPERATOR_CANCELLED;
+       }
 
-       calc_sequence_disp(seq);
        sort_seq(scene);
 
-       /* last active name */
-       strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
+       ED_area_tag_redraw(CTX_wm_area(C));
 
-       return seq;
+       return OPERATOR_FINISHED;
 }
 
 /* add movie operator */
 static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
-       Editing *ed= seq_give_editing(scene, TRUE);
-
-       struct anim *an;
-       char path[FILE_MAX];
-
-       Sequence *seq, *soundseq=NULL;  /* generic strip vars */
-       Strip *strip;
-       StripElem *se;
-
-       int start_frame, channel, sound; /* operator props */
-
-       start_frame= RNA_int_get(op->ptr, "start_frame");
-       channel= RNA_int_get(op->ptr, "channel");
-       sound = RNA_boolean_get(op->ptr, "sound");
-
-       RNA_string_get(op->ptr, "path", path);
-       
-       an = openanim(path, IB_rect);
-
-       if (an==NULL) {
-               BKE_reportf(op->reports, RPT_ERROR, "File \"%s\" could not be loaded as a movie", path);
-               return OPERATOR_CANCELLED;
-       }
-       
-       seq = alloc_sequence(ed->seqbasep, start_frame, channel);
-       
-       seq->type= SEQ_MOVIE;
-       seq->anim= an;
-       seq->anim_preseek = IMB_anim_get_preseek(an);
-       
-       /* basic defaults */
-       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
-       strip->len = seq->len = IMB_anim_get_duration( an ); 
-       strip->us= 1;
-       
-       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-       
-       BLI_split_dirfile_basic(path, strip->dir, se->name);
-
-       RNA_string_get(op->ptr, "name", seq->name);
-       
-       calc_sequence_disp(seq);
-       sort_seq(scene);
-
-       if(sound)
-       {
-               soundseq = sequencer_add_sound_strip(C, NULL, start_frame, channel+1, path);
-               if(soundseq != NULL)
-                       RNA_string_get(op->ptr, "name", soundseq->name);
-       }
-
-       if (RNA_boolean_get(op->ptr, "replace_sel")) {
-               deselect_all_seq(scene);
-               set_last_seq(scene, seq);
-               seq->flag |= SELECT;
-               if(soundseq)
-                       soundseq->flag |= SELECT;
-       }
-       
-       ED_area_tag_redraw(CTX_wm_area(C));
-       
-       return OPERATOR_FINISHED;
+       return sequencer_add_generic_strip_exec(C, op, sequencer_add_movie_strip);
 }
 
 
@@ -377,46 +336,17 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL);
-       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
        RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie");
 }
 
 /* add sound operator */
+
 static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op)
 {
-       char path[FILE_MAX];
-       Scene *scene= CTX_data_scene(C);
-       Sequence *seq;  /* generic strip vars */
-       int start_frame, channel; /* operator props */
-       
-       start_frame= RNA_int_get(op->ptr, "start_frame");
-       channel= RNA_int_get(op->ptr, "channel");
-       
-       RNA_string_get(op->ptr, "path", path);
-
-       seq = sequencer_add_sound_strip(C, op, start_frame, channel, path);
-
-       if(seq == NULL)
-               return OPERATOR_CANCELLED;
-
-       RNA_string_get(op->ptr, "name", seq->name);
-
-       if (RNA_boolean_get(op->ptr, "cache")) {
-               sound_cache(seq->sound, 0);
-       }
-
-       if (RNA_boolean_get(op->ptr, "replace_sel")) {
-               deselect_all_seq(scene);
-               set_last_seq(scene, seq);
-               seq->flag |= SELECT;
-       }
-
-       ED_area_tag_redraw(CTX_wm_area(C));
-       
-       return OPERATOR_FINISHED;
+       return sequencer_add_generic_strip_exec(C, op, sequencer_add_sound_strip);
 }
 
-
 static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {      
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
@@ -443,46 +373,40 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL);
-       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
+       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
        RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
 }
 
 /* add image operator */
 static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
-       Editing *ed= seq_give_editing(scene, TRUE);
+       /* cant use the generic function for this */
 
-       int tot_images;
-
-       char path[FILE_MAX];
+       Scene *scene= CTX_data_scene(C); /* only for sound */
+       Editing *ed= seq_give_editing(scene, TRUE);
+       SeqLoadInfo seq_load;
+       Sequence *seq;
 
-       Sequence *seq;  /* generic strip vars */
        Strip *strip;
        StripElem *se;
-       
-       int start_frame, channel; /* operator props */
-       
-       start_frame= RNA_int_get(op->ptr, "start_frame");
-       channel= RNA_int_get(op->ptr, "channel");
-       
-       RNA_string_get(op->ptr, "path", path);
 
-       seq = alloc_sequence(ed->seqbasep, start_frame, channel);       
-       seq->type= SEQ_IMAGE;
-       
-       /* basic defaults */
-       seq->strip= strip= MEM_callocN(sizeof(Strip), "strip");
-       BLI_split_dirfile_basic(path, strip->dir, NULL);
-       
-       tot_images= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
-       
-       strip->len = seq->len = tot_images?tot_images:1;
-       strip->us= 1;
-       
-       strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+       seq_load_operator_info(&seq_load, op);
+
+       /* images are unique in how they handle this - 1 per strip elem */
+       seq_load.len= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files"));
+
+       if(seq_load.len==0)
+               seq_load.len= 1;
+
+       if(seq_load.flag & SEQ_LOAD_REPLACE_SEL)
+               deselect_all_seq(scene);
+
        
-       if(tot_images) {
+       /* main adding function */
+       seq= sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
+       se= seq->strip->stripdata;
+
+       if(seq_load.len > 1) {
                RNA_BEGIN(op->ptr, itemptr, "files") {
                        RNA_string_get(&itemptr, "name", se->name);
                        se++;
@@ -490,29 +414,21 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
                RNA_END;
        }
        else {
-               BLI_split_dirfile_basic(path, NULL, se->name);
+               BLI_split_dirfile_basic(seq_load.path, NULL, se->name);
        }
-
-       RNA_string_get(op->ptr, "name", seq->name);
        
        calc_sequence_disp(seq);
+
        sort_seq(scene);
-       
+
        /* last active name */
        strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR-1);
        
-       if (RNA_boolean_get(op->ptr, "replace_sel")) {
-               deselect_all_seq(scene);
-               set_last_seq(scene, seq);
-               seq->flag |= SELECT;
-       }
-
        ED_area_tag_redraw(CTX_wm_area(C));
-       
+
        return OPERATOR_FINISHED;
 }
 
-
 static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
@@ -539,9 +455,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL);
-       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
-       
-       RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
+       sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
 }
 
 
@@ -634,7 +548,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
 
        if (RNA_boolean_get(op->ptr, "replace_sel")) {
                deselect_all_seq(scene);
-               set_last_seq(scene, seq);
+               active_seq_set(scene, seq);
                seq->flag |= SELECT;
        }
 
index ff9edeaeb4b65951b8bb6a318c76365829b55f8c..88be1d61ff622cf909e2e4863d474a1c1fe8d673 100644 (file)
@@ -940,7 +940,7 @@ void drawseqspace(const bContext *C, ARegion *ar)
 
        /* sequences: first deselect */
        if(ed) {
-               Sequence *last_seq = get_last_seq(scene);
+               Sequence *last_seq = active_seq_get(scene);
                int sel = 0, j;
                int outline_tint;
                float pixelx = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin);
index 1cf44d97c93b8f95e89c96d65d65692d6dec0d59..a83d779fe80df418783b67216f5d45756cd7971d 100644 (file)
@@ -140,21 +140,6 @@ typedef struct TransSeq {
        int len;
 } TransSeq;
 
-Sequence *get_last_seq(Scene *scene)
-{
-       Editing *ed= seq_give_editing(scene, FALSE);
-       if(ed==NULL) return NULL;
-       return ed->act_seq;
-}
-
-void set_last_seq(Scene *scene, Sequence *seq)
-{
-       Editing *ed= seq_give_editing(scene, FALSE);
-       if(ed==NULL) return;
-       
-       ed->act_seq= seq;
-}
-
 Sequence *get_foreground_frame_seq(Scene *scene, int frame)
 {
        Editing *ed= seq_give_editing(scene, FALSE);
@@ -191,7 +176,7 @@ static void change_plugin_seq(Scene *scene, char *str)      /* called from fileselect
 {
        Editing *ed= seq_give_editing(scene, FALSE);
        struct SeqEffectHandle sh;
-       Sequence *last_seq= get_last_seq(scene);
+       Sequence *last_seq= active_seq_get(scene);
 
        if(last_seq && last_seq->type != SEQ_PLUGIN) return;
 
@@ -489,29 +474,6 @@ void recurs_sel_seq(Sequence *seqm)
        }
 }
 
-Sequence *alloc_sequence(ListBase *lb, int cfra, int machine)
-{
-       Sequence *seq;
-
-       /*ed= scene->ed;*/
-
-       seq= MEM_callocN( sizeof(Sequence), "addseq");
-       BLI_addtail(lb, seq);
-
-       //set_last_seq(scene, seq); // Probably not a great idea at such a low level anyway - Campbell
-
-       *( (short *)seq->name )= ID_SEQ;
-       seq->name[2]= 0;
-
-       seq->flag= SELECT;
-       seq->start= cfra;
-       seq->machine= machine;
-       seq->mul= 1.0;
-       seq->blend_opacity = 100.0;
-       
-       return seq;
-}
-
 int event_to_efftype(int event)
 {
        if(event==2) return SEQ_CROSS;
@@ -537,7 +499,7 @@ static void reload_sound_strip(Scene *scene, char *name)
        Editing *ed;
        Sequence *seq, *seqact;
        SpaceFile *sfile;
-       Sequence *last_seq= get_last_seq(scene);
+       Sequence *last_seq= active_seq_get(scene);
 
        ed= scene->ed;
 
@@ -579,7 +541,7 @@ static void reload_image_strip(Scene *scene, char *name)
        Editing *ed= seq_give_editing(scene, FALSE);
        Sequence *seq=NULL, *seqact;
        SpaceFile *sfile=NULL;
-       Sequence *last_seq= get_last_seq(scene);
+       Sequence *last_seq= active_seq_get(scene);
 
 
 
@@ -615,7 +577,7 @@ static void reload_image_strip(Scene *scene, char *name)
 void change_sequence(Scene *scene)
 {
        Editing *ed= seq_give_editing(scene, FALSE);
-       Sequence *last_seq= get_last_seq(scene);
+       Sequence *last_seq= active_seq_get(scene);
        Scene *sce;
        short event;
 
@@ -717,7 +679,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
        *error_str= NULL;
 
        if (!activeseq)
-               seq2= get_last_seq(scene);
+               seq2= active_seq_get(scene);
 
        for(seq=ed->seqbasep->first; seq; seq=seq->next) {
                if(seq->flag & SELECT) {
@@ -780,7 +742,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen
 void reassign_inputs_seq_effect(Scene *scene)
 {
        Editing *ed= seq_give_editing(scene, FALSE);
-       Sequence *seq1, *seq2, *seq3, *last_seq = get_last_seq(scene);
+       Sequence *seq1, *seq2, *seq3, *last_seq = active_seq_get(scene);
        char *error_msg;
 
        if(last_seq==0 || !(last_seq->type & SEQ_EFFECT)) return;
@@ -849,7 +811,7 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq)
 static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall)
 {
        Sequence *seq, *seqn;
-       Sequence *last_seq = get_last_seq(scene);
+       Sequence *last_seq = active_seq_get(scene);
 
        seq= lb->first;
        while(seq) {
@@ -859,7 +821,7 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
                                seq->sound->id.us--;
 
                        BLI_remlink(lb, seq);
-                       if(seq==last_seq) set_last_seq(scene, NULL);
+                       if(seq==last_seq) active_seq_set(scene, NULL);
                        if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
                        if(seq->ipo) seq->ipo->id.us--;
                        seq_free_sequence(scene, seq);
@@ -987,7 +949,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new)
 {
        Sequence *seq;
        Sequence *seqn = 0;
-       Sequence *last_seq = get_last_seq(scene);
+       Sequence *last_seq = active_seq_get(scene);
 
        for(seq= old->first; seq; seq= seq->next) {
                seq->tmp= NULL;
@@ -1002,7 +964,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new)
                                        recurs_dupli_seq(scene, &seq->seqbase,&seqn->seqbase);
                                
                                if (seq == last_seq) {
-                                       set_last_seq(scene, seqn);
+                                       active_seq_set(scene, seqn);
                                }
                        }
                }
@@ -1299,7 +1261,7 @@ void set_filter_seq(Scene *scene)
 
 void seq_remap_paths(Scene *scene)
 {
-       Sequence *seq, *last_seq = get_last_seq(scene);
+       Sequence *seq, *last_seq = active_seq_get(scene);
        Editing *ed= seq_give_editing(scene, FALSE);
        char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX];
        
@@ -1889,7 +1851,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op)
        if(ed==NULL)
                return OPERATOR_CANCELLED;
 
-       seq=get_last_seq(scene);
+       seq=active_seq_get(scene);
        if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */
                nothingSelected = FALSE;
        } else {
@@ -2057,7 +2019,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Editing *ed= seq_give_editing(scene, FALSE);
-       Sequence *last_seq= get_last_seq(scene);
+       Sequence *last_seq= active_seq_get(scene);
        MetaStack *ms;
 
        if(ed==NULL)
@@ -2072,7 +2034,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op)
 
                ed->seqbasep= &last_seq->seqbase;
 
-               set_last_seq(scene, NULL);
+               active_seq_set(scene, NULL);
 
        }
        else {
@@ -2092,7 +2054,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op)
                for(seq= ed->seqbasep->first; seq; seq= seq->next)
                        calc_sequence(seq);
 
-               set_last_seq(scene, ms->parseq);
+               active_seq_set(scene, ms->parseq);
 
                ms->parseq->flag |= SELECT;
                recurs_sel_seq(ms->parseq);
@@ -2202,7 +2164,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
        seqm->strip->len= seqm->len;
        seqm->strip->us= 1;
        
-       set_last_seq(scene, seqm);
+       active_seq_set(scene, seqm);
 
        if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm);
 
@@ -2243,7 +2205,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Editing *ed= seq_give_editing(scene, FALSE);
 
-       Sequence *seq, *last_seq = get_last_seq(scene); /* last_seq checks ed==NULL */
+       Sequence *seq, *last_seq = active_seq_get(scene); /* last_seq checks ed==NULL */
 
        if(last_seq==NULL || last_seq->type!=SEQ_META)
                return OPERATOR_CANCELLED;
@@ -2591,7 +2553,7 @@ static int sequencer_swap_internal_exec(bContext *C, int side)
 {
        Scene *scene= CTX_data_scene(C);
        Editing *ed= seq_give_editing(scene, FALSE);
-       Sequence *active_seq = get_last_seq(scene);
+       Sequence *active_seq = active_seq_get(scene);
        Sequence *seq;
 
        if(ed==NULL) return OPERATOR_CANCELLED;
@@ -2674,7 +2636,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *op)
 {
        int retval = OPERATOR_CANCELLED;
        Scene *scene= CTX_data_scene(C);
-       Sequence *active_seq = get_last_seq(scene);
+       Sequence *active_seq = active_seq_get(scene);
 
        if(active_seq==NULL) return OPERATOR_CANCELLED;
 
index 82b24deae63de9c0a16701e117546f7890be9056..a87f7f64ee9ed4fdca1299794cbc9fa9fa252902 100644 (file)
@@ -59,13 +59,11 @@ int seq_tx_get_final_left(struct Sequence *seq, int metaclip);
 int seq_tx_get_final_right(struct Sequence *seq, int metaclip);
 void seq_rectf(struct Sequence *seq, struct rctf *rectf);
 void boundbox_seq(struct Scene *scene, struct rctf *rect);
-struct Sequence *get_last_seq(struct Scene *scene);
 struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, short mval[2]);
 struct Sequence *find_neighboring_sequence(struct Scene *scene, struct Sequence *test, int lr, int sel);
 void deselect_all_seq(struct Scene *scene);
 void recurs_sel_seq(struct Sequence *seqm);
 int event_to_efftype(int event);
-void set_last_seq(struct Scene *scene, struct Sequence *seq);
 int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, int type, struct Sequence **selseq1, struct Sequence **selseq2, struct Sequence **selseq3, char **error_str);
 struct Sequence *alloc_sequence(struct ListBase *lb, int cfra, int machine);
 
index 2ead426c18a5a5de37841c26db92c2612ea4dbac..47a1197746af15f91b29d26bf5459a6abf5eac6d 100644 (file)
@@ -147,7 +147,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B
        
        if(deselect_all)
                deselect_all_seq(scene);
-       set_last_seq(scene, seq);
+       active_seq_set(scene, seq);
 
        if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) {
                if(seq->strip)
@@ -166,7 +166,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B
 
 void select_neighbor_from_last(Scene *scene, int lr)
 {
-       Sequence *seq=get_last_seq(scene);
+       Sequence *seq= active_seq_get(scene);
        Sequence *neighbor;
        int change = 0;
        if (seq) {
@@ -354,7 +354,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        deselect_all_seq(scene);
        
                if(seq) {
-                       set_last_seq(scene, seq);
+                       active_seq_set(scene, seq);
        
                        if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) {
                                if(seq->strip) {
@@ -750,7 +750,7 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Editing *ed= seq_give_editing(scene, 0);
-       Sequence *seq_act=get_last_seq(scene);
+       Sequence *seq_act= active_seq_get(scene);
 
        if (ed==NULL || seq_act==NULL)
                return OPERATOR_CANCELLED;