* rna attributes for sequence strips - seq.start_frame_final & seq.end_frame_final

these expose the final start and end after offsets are applied. when set this is like grabbing the handle and moving it.
* made swapping strips shuffle effects and check for overlap.
This commit is contained in:
Campbell Barton 2009-12-15 11:27:46 +00:00
parent 18b9385c53
commit 8aa8efb327
8 changed files with 84 additions and 36 deletions

View File

@ -178,8 +178,8 @@ void seq_tx_set_final_left(struct Sequence *seq, int val);
void seq_tx_set_final_right(struct Sequence *seq, int val);
void seq_tx_handle_xlimits(struct Sequence *seq, int leftflag, int rightflag);
int seq_tx_test(struct Sequence * seq);
int check_single_seq(struct Sequence *seq);
void fix_single_seq(struct Sequence *seq);
int seq_single_check(struct Sequence *seq);
void seq_single_fix(struct Sequence *seq);
int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test);
void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs);
int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test);

View File

@ -3259,7 +3259,7 @@ void seq_tx_set_final_right(Sequence *seq, int val)
/* used so we can do a quick check for single image seq
since they work a bit differently to normal image seq's (during transform) */
int check_single_seq(Sequence *seq)
int seq_single_check(Sequence *seq)
{
if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR))
return 1;
@ -3276,7 +3276,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
seq_tx_set_final_left(seq, seq_tx_get_final_right(seq, 0)-1);
}
if (check_single_seq(seq)==0) {
if (seq_single_check(seq)==0) {
if (seq_tx_get_final_left(seq, 0) >= seq_tx_get_end(seq)) {
seq_tx_set_final_left(seq, seq_tx_get_end(seq)-1);
}
@ -3298,7 +3298,7 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
seq_tx_set_final_right(seq, seq_tx_get_final_left(seq, 0)+1);
}
if (check_single_seq(seq)==0) {
if (seq_single_check(seq)==0) {
if (seq_tx_get_final_right(seq, 0) <= seq_tx_get_start(seq)) {
seq_tx_set_final_right(seq, seq_tx_get_start(seq)+1);
}
@ -3312,10 +3312,10 @@ void seq_tx_handle_xlimits(Sequence *seq, int leftflag, int rightflag)
}
}
void fix_single_seq(Sequence *seq)
void seq_single_fix(Sequence *seq)
{
int left, start, offset;
if (!check_single_seq(seq))
if (!seq_single_check(seq))
return;
/* make sure the image is always at the start since there is only one,

View File

@ -525,7 +525,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *
char col[3], background_col[3], is_single_image;
/* we need to know if this is a single image/color or not for drawing */
is_single_image = (char)check_single_seq(seq);
is_single_image = (char)seq_single_check(seq);
/* body */
if(seq->startstill) x1= seq->start;

View File

@ -2652,10 +2652,25 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op)
// XXX - should be a generic function
for(iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) {
if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq)))
if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
calc_sequence(iseq);
}
}
/* do this in a new loop since both effects need to be calculated first */
for(iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) {
if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) {
/* this may now overlap */
if( seq_test_overlap(ed->seqbasep, iseq) ) {
shuffle_seq(ed->seqbasep, iseq);
}
}
}
sort_seq(scene);
WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene);
return OPERATOR_FINISHED;

View File

@ -54,7 +54,7 @@ void seq_reset_imageofs(struct SpaceSeq *sseq);
/* sequencer_edit.c */
struct View2D;
int check_single_seq(struct Sequence *seq);
int seq_single_check(struct Sequence *seq);
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);

View File

@ -269,7 +269,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
{
ScrArea *sa= CTX_wm_area(C);
// ScrArea *sa= CTX_wm_area(C);
/* NLE - strip editing timeline interface */
draw_timeline_seq(C, ar);

View File

@ -2390,12 +2390,12 @@ void flushTransSeq(TransInfo *t)
case SEQ_LEFTSEL: /* no vertical transform */
seq_tx_set_final_left(seq, new_frame);
seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
fix_single_seq(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
break;
case SEQ_RIGHTSEL: /* no vertical transform */
seq_tx_set_final_right(seq, new_frame);
seq_tx_handle_xlimits(seq, tdsq->flag&SEQ_LEFTSEL, tdsq->flag&SEQ_RIGHTSEL);
fix_single_seq(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
seq_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */
break;
}

View File

@ -56,8 +56,8 @@ static void meta_tmp_ref(Sequence *seq_par, Sequence *seq)
static void rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Scene *sce= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(sce, FALSE);
Scene *scene= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
meta_tmp_ref(NULL, ed->seqbase.first);
@ -88,34 +88,55 @@ static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *it
iter->valid= (internal->link != NULL);
}
static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value)
/* internal use */
static void rna_Sequence_frame_change_update(Scene *scene, Sequence *seq)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *sce= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(sce, FALSE);
seq->start= value;
Editing *ed= seq_give_editing(scene, FALSE);
calc_sequence_disp(seq);
if( seq_test_overlap(ed->seqbasep, seq) ) {
shuffle_seq(ed->seqbasep, seq);
}
sort_seq(sce);
sort_seq(scene);
}
static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *scene= (Scene*)ptr->id.data;
seq->start= value;
rna_Sequence_frame_change_update(scene, seq);
}
static void rna_Sequence_start_frame_final_set(PointerRNA *ptr, int value)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *scene= (Scene*)ptr->id.data;
seq_tx_set_final_left(seq, value);
seq_single_fix(seq);
rna_Sequence_frame_change_update(scene, seq);
}
static void rna_Sequence_end_frame_final_set(PointerRNA *ptr, int value)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *scene= (Scene*)ptr->id.data;
seq_tx_set_final_right(seq, value);
seq_single_fix(seq);
rna_Sequence_frame_change_update(scene, seq);
}
static void rna_Sequence_length_set(PointerRNA *ptr, int value)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *sce= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(sce, FALSE);
Scene *scene= (Scene*)ptr->id.data;
seq_tx_set_final_right(seq, seq->start+value);
calc_sequence_disp(seq);
if( seq_test_overlap(ed->seqbasep, seq) ) {
shuffle_seq(ed->seqbasep, seq);
}
sort_seq(sce);
rna_Sequence_frame_change_update(scene, seq);
}
static int rna_Sequence_length_get(PointerRNA *ptr)
@ -127,15 +148,15 @@ static int rna_Sequence_length_get(PointerRNA *ptr)
static void rna_Sequence_channel_set(PointerRNA *ptr, int value)
{
Sequence *seq= (Sequence*)ptr->data;
Scene *sce= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(sce, FALSE);
Scene *scene= (Scene*)ptr->id.data;
Editing *ed= seq_give_editing(scene, FALSE);
seq->machine= value;
if( seq_test_overlap(ed->seqbasep, seq) ) {
shuffle_seq(ed->seqbasep, seq);
}
sort_seq(sce);
sort_seq(scene);
}
/* properties that need to allocate structs */
@ -212,10 +233,10 @@ static int rna_Sequence_name_length(PointerRNA *ptr)
static void rna_Sequence_name_set(PointerRNA *ptr, const char *value)
{
Scene *sce= (Scene*)ptr->id.data;
Scene *scene= (Scene*)ptr->id.data;
Sequence *seq= (Sequence*)ptr->data;
BLI_strncpy(seq->name+2, value, sizeof(seq->name)-2);
seqUniqueName(&sce->ed->seqbase, seq);
seqUniqueName(&scene->ed->seqbase, seq);
}
static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr)
@ -573,6 +594,18 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_set",NULL); // overlap tests and calc_seq_disp
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
prop= RNA_def_property(srna, "start_frame_final", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "startdisp");
RNA_def_property_ui_text(prop, "Start Frame", "Start frame displayed in the sequence editor after offsets are applied, setting this is equivilent to moving the handle, not the actual start frame.");
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_final_set", NULL); // overlap tests and calc_seq_disp
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
prop= RNA_def_property(srna, "end_frame_final", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "enddisp");
RNA_def_property_ui_text(prop, "End Frame", "End frame displayed in the sequence editor after offsets are applied.");
RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_end_frame_final_set", NULL); // overlap tests and calc_seq_disp
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "startofs");
RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests