Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c117
1 files changed, 82 insertions, 35 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 1a56cb6d683..36ae475e64b 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -86,8 +86,6 @@
static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
{
- RNA_def_string(ot->srna, "name", "", MAX_ID_NAME-2, "Name", "Name of the new sequence strip");
-
if(flag & SEQPROP_STARTFRAME)
RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX);
@@ -102,6 +100,20 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
}
+static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier)
+{
+ if(RNA_struct_find_property(op->ptr, identifier)) {
+ Scene *scene= CTX_data_scene(C);
+ Sequence *last_seq= seq_active_get(scene);
+ if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
+ char path[sizeof(last_seq->strip->dir)];
+ BLI_strncpy(path, last_seq->strip->dir, sizeof(path));
+ BLI_path_abs(path, G.sce);
+ RNA_string_set(op->ptr, identifier, path);
+ }
+ }
+}
+
static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, wmEvent *event, int flag)
{
ARegion *ar= CTX_wm_region(C);
@@ -121,11 +133,14 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w
if ((flag & SEQPROP_ENDFRAME) && RNA_property_is_set(op->ptr, "frame_end")==0)
RNA_int_set(op->ptr, "frame_end", (int)mval_v2d[0] + 25); // XXX arbitary but ok for now.
-
+
+ sequencer_generic_invoke_path__internal(C, op, "filepath");
+ sequencer_generic_invoke_path__internal(C, op, "directory");
}
static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
{
+ int is_file= -1;
memset(seq_load, 0, sizeof(SeqLoadInfo));
seq_load->start_frame= RNA_int_get(op->ptr, "frame_start");
@@ -134,9 +149,13 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
seq_load->channel= RNA_int_get(op->ptr, "channel");
seq_load->len= 1; // images only, if endframe isnt set!
- RNA_string_get(op->ptr, "name", seq_load->name+2);
-
- RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */
+ if(RNA_struct_find_property(op->ptr, "filepath")) {
+ RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */
+ is_file= 1;
+ } else if (RNA_struct_find_property(op->ptr, "directory")) {
+ RNA_string_get(op->ptr, "directory", seq_load->path); /* full path, file is set by the caller */
+ is_file= 0;
+ }
if (RNA_struct_find_property(op->ptr, "frame_end")) {
seq_load->end_frame = RNA_int_get(op->ptr, "frame_end");
@@ -153,6 +172,20 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
/* always use this for ops */
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(RNA_struct_find_property(op->ptr, "files")) {
+ /* used for image strip */
+ /* best guess, first images name */
+ RNA_BEGIN(op->ptr, itemptr, "files") {
+ RNA_string_get(&itemptr, "name", seq_load->name);
+ break;
+ }
+ RNA_END;
+ }
}
/* add scene operator */
@@ -180,8 +213,9 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
}
seq = alloc_sequence(ed->seqbasep, start_frame, channel);
-
seq->type= SEQ_SCENE;
+ seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */
+
seq->scene= sce_seq;
seq->sfra= sce_seq->r.sfra;
@@ -192,11 +226,9 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
- if(RNA_property_is_set(op->ptr, "name"))
- RNA_string_get(op->ptr, "name", seq->name+2);
- else
- strcpy(seq->name+2, sce_seq->id.name+2);
-
+ strcpy(seq->name+2, sce_seq->id.name+2);
+ seqbase_unique_name_recursive(&ed->seqbase, seq);
+
seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + strip->len, 0);
calc_sequence_disp(scene, seq);
@@ -318,7 +350,10 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
sequencer_generic_invoke_xy__internal(C, op, event, 0);
- return WM_operator_filesel(C, op, event);
+
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+
//return sequencer_add_movie_strip_exec(C, op);
}
@@ -340,7 +375,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie");
}
@@ -363,7 +398,10 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
sequencer_generic_invoke_xy__internal(C, op, event, 0);
- return WM_operator_filesel(C, op, event);
+
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+
//return sequencer_add_sound_strip_exec(C, op);
}
@@ -385,7 +423,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
}
@@ -409,26 +447,24 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op)
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;
+ return OPERATOR_CANCELLED;
if(seq_load.flag & SEQ_LOAD_REPLACE_SEL)
deselect_all_seq(scene);
-
+
/* main adding function */
seq= sequencer_add_image_strip(C, ed->seqbasep, &seq_load);
strip= seq->strip;
se= strip->stripdata;
- if(seq_load.len > 1) {
- RNA_BEGIN(op->ptr, itemptr, "files") {
- RNA_string_get(&itemptr, "name", se->name);
- se++;
- }
- RNA_END;
+ RNA_BEGIN(op->ptr, itemptr, "files") {
+ RNA_string_get(&itemptr, "name", se->name);
+ se++;
}
- else {
- BLI_strncpy(se->name, BLI_path_basename(seq_load.path), sizeof(se->name));
+ RNA_END;
+
+ if(seq_load.len == 1) {
if(seq_load.start_frame < seq_load.end_frame) {
seq->endstill= seq_load.end_frame - seq_load.start_frame;
}
@@ -457,7 +493,10 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME);
- return WM_operator_filesel(C, op, event);
+
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
+
//return sequencer_add_image_strip_exec(C, op);
}
@@ -479,7 +518,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+ WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES);
}
@@ -506,7 +545,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
type= RNA_enum_get(op->ptr, "type");
- // XXX We need unique names and move to invoke
+ // 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;
@@ -522,11 +561,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
seq = alloc_sequence(ed->seqbasep, start_frame, channel);
seq->type= type;
- if(RNA_property_is_set(op->ptr, "name"))
- RNA_string_get(op->ptr, "name", seq->name+2);
- else
- strcpy(seq->name+2, give_seqname(seq));
-
+ BLI_strncpy(seq->name+2, give_seqname(seq), sizeof(seq->name)-2);
seqbase_unique_name_recursive(&ed->seqbase, seq);
sh = get_sequence_effect(seq);
@@ -569,6 +604,18 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op)
else if (seq->type==SEQ_COLOR) {
SolidColorVars *colvars= (SolidColorVars *)seq->effectdata;
RNA_float_get_array(op->ptr, "color", colvars->col);
+ seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */
+
+ }
+
+ // XXX, this conflicts with giving a channel with invoke, perhaps we should have an active channel
+ // but for now this is much more usable
+ if(seq->seq1 || seq->seq2 || seq->seq3) {
+ int chan= MAX3( seq->seq1 ? seq->seq1->machine : 0,
+ seq->seq2 ? seq->seq2->machine : 0,
+ seq->seq3 ? seq->seq3->machine : 0);
+ if(chan < MAXSEQ)
+ seq->machine= chan;
}
if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene);
@@ -631,7 +678,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME);
RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type");
RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f);