Sequencer unique names for duplicates & metas and name new strips when the operator doesnt set them.

This commit is contained in:
Campbell Barton 2009-12-13 03:20:29 +00:00
parent b6bf852670
commit a224803fb7
2 changed files with 31 additions and 17 deletions

@ -73,6 +73,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
/* for menu/popup icons etc etc*/
#include "UI_interface.h"
@ -150,7 +151,7 @@ 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!
RNA_string_get(op->ptr, "name", seq_load->name);
RNA_string_get(op->ptr, "name", seq_load->name+2);
RNA_string_get(op->ptr, "path", seq_load->path); /* full path, file is set by the caller */
@ -174,8 +175,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
Editing *ed= seq_give_editing(scene, TRUE);
Scene *sce_seq;
char sce_name[MAX_ID_NAME-2];
Sequence *seq; /* generic strip vars */
Strip *strip;
StripElem *se;
@ -185,12 +185,10 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
start_frame= RNA_int_get(op->ptr, "start_frame");
channel= RNA_int_get(op->ptr, "channel");
RNA_string_get(op->ptr, "scene", sce_name);
sce_seq= (Scene *)find_id("SC", sce_name);
sce_seq= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "type"));
if (sce_seq==NULL) {
BKE_reportf(op->reports, RPT_ERROR, "Scene \"%s\" not found", sce_name);
BKE_report(op->reports, RPT_ERROR, "Scene not found");
return OPERATOR_CANCELLED;
}
@ -206,8 +204,10 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
RNA_string_get(op->ptr, "name", seq->name);
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);
calc_sequence_disp(seq);
sort_seq(scene);
@ -227,16 +227,15 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op)
static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
sequencer_generic_invoke_xy__internal(C, op, event, 0);
/* scene can be left default */
RNA_string_set(op->ptr, "scene", "Scene"); // XXX should popup a menu but ton says 2.5 will have some better feature for this
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 */
ot->name= "Add Scene Strip";
@ -253,7 +252,8 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene Name", "Scene name to add as a strip");
prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Type", "");
RNA_def_enum_funcs(prop, RNA_scene_itemf);
}
static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func)
@ -499,6 +499,11 @@ 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));
seqUniqueName(ed->seqbasep, seq);
sh = get_sequence_effect(seq);

@ -925,7 +925,9 @@ static Sequence *dupli_seq(struct Scene *scene, Sequence *seq)
"handled in duplicate!\nExpect a crash"
" now...\n");
}
seqUniqueName(scene->ed->seqbasep, seqn);
return seqn;
}
@ -1963,6 +1965,8 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
shuffle_seq(ed->seqbasep, seq_new);
}
seqUniqueName(scene->ed->seqbasep, seq_new);
cfra++;
start_ofs += step;
}
@ -2085,7 +2089,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
Sequence *seq, *seqm, *next;
int tot;
int tot, channel_max= 1;
if(ed==NULL)
return OPERATOR_CANCELLED;
@ -2106,6 +2110,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
seq= ed->seqbasep->first;
while(seq) {
if(seq->flag & SELECT) {
channel_max= MAX2(seq->machine, channel_max);
if(seq->type & SEQ_EFFECT) {
if(seq->seq1 &&
(seq->seq1->flag & SELECT)==0) tot= 0;
@ -2134,7 +2139,8 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
/* remove all selected from main list, and put in meta */
seqm= alloc_sequence(ed->seqbasep, 1, 1);
seqm= alloc_sequence(ed->seqbasep, 1, channel_max);
strcpy(seqm->name+2, "MetaStrip");
seqm->type= SEQ_META;
seqm->flag= SELECT;
@ -2158,6 +2164,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm);
seq_update_muting(ed);
seqUniqueName(scene->ed->seqbasep, seqm);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;