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:
authorCampbell Barton <ideasman42@gmail.com>2010-07-03 00:09:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-03 00:09:42 +0400
commit15be7b215f0ea53e68e114430267823e2b3fd37d (patch)
tree86b8ce182305c977bc5f5d78096572a15f913ea8 /source/blender/editors/space_sequencer/sequencer_add.c
parent213a45bed83bcb8afdc8ada8fd69b229a4a522f9 (diff)
- changes to the sequencer so new strips use the data name.
- removed the name option for the sequence operators.
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c87
1 files changed, 49 insertions, 38 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 508521c972e..cfcc3b6e81d 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);
@@ -122,21 +134,13 @@ 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.
- if(RNA_struct_find_property(op->ptr, "filepath")) {
- Scene *scene= CTX_data_scene(C);
- Sequence *last_seq= seq_active_get(scene);
- if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) {
- RNA_string_set(op->ptr, "filepath", last_seq->strip->dir);
- }
- // // TODO
- // else {
- // RNA_string_set(op->ptr, "filepath", ed->act_imagedir);
- // }
- }
+ 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");
@@ -145,12 +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);
-
- if(RNA_struct_find_property(op->ptr, "filepath"))
+ 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 */
- else if (RNA_struct_find_property(op->ptr, "filepath"))
+ 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");
@@ -167,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 */
@@ -206,11 +225,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);
@@ -429,26 +446,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;
}
@@ -502,7 +517,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, WM_FILESEL_FILEPATH|WM_FILESEL_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);
}
@@ -545,11 +560,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);