diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-21 21:37:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-21 21:37:50 +0400 |
commit | 72d21c35adcea937bbf2e2423472c9ca5ed315c6 (patch) | |
tree | db996aab43585032910c0e1a96885926e342111f /source | |
parent | 3f4121cea5d10b76fac30f4fc60390f0d5e8ad20 (diff) |
sequencer swap data operator.
needed for durian so we can swap out preview AVI's for EXR sequences.
Diffstat (limited to 'source')
9 files changed, 134 insertions, 36 deletions
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 354638013ec..9b96363dd23 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -191,6 +191,7 @@ int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene); int seqbase_isolated_sel_check(struct ListBase *seqbase); void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage); +int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b); void seq_update_sound(struct Scene* scene, struct Sequence *seq); void seq_update_muting(struct Scene* scene, struct Editing *ed); @@ -200,8 +201,9 @@ void clear_scene_in_allseqs(struct Scene *sce); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); -struct Sequence *active_seq_get(struct Scene *scene); -void active_seq_set(struct Scene *scene, struct Sequence *seq); +struct Sequence *seq_active_get(struct Scene *scene); +void seq_active_set(struct Scene *scene, struct Sequence *seq); +int seq_active_pair_get(struct Scene *scene, struct Sequence **seq_act, struct Sequence **seq_other); /* api for adding new sequence strips */ typedef struct SeqLoadInfo { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d1ab63ca65e..51428f56dc9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3790,6 +3790,33 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq) return NULL; } +int seq_swap(Sequence *seq_a, Sequence *seq_b) +{ + if(seq_a->len != seq_b->len) + return 0; + + /* type checking, could be more advanced but disalow sound vs non-sound copy */ + if(seq_a->type != seq_b->type) { + if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) { + return 0; + } + } + + SWAP(Sequence, *seq_a, *seq_b); + SWAP(void *, seq_a->prev, seq_b->prev); + SWAP(void *, seq_a->next, seq_b->next); + + SWAP(int, seq_a->start, seq_b->start); + SWAP(int, seq_a->startofs, seq_b->startofs); + SWAP(int, seq_a->endofs, seq_b->endofs); + SWAP(int, seq_a->startstill, seq_b->startstill); + SWAP(int, seq_a->endstill, seq_b->endstill); + SWAP(int, seq_a->machine, seq_b->machine); + SWAP(int, seq_a->startdisp, seq_b->enddisp); + + return 1; +} + /* XXX - hackish function needed for transforming strips! TODO - have some better solution */ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) { @@ -3832,14 +3859,14 @@ Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive) } -Sequence *active_seq_get(Scene *scene) +Sequence *seq_active_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) +void seq_active_set(Scene *scene, Sequence *seq) { Editing *ed= seq_give_editing(scene, FALSE); if(ed==NULL) return; @@ -3847,6 +3874,35 @@ void active_seq_set(Scene *scene, Sequence *seq) ed->act_seq= seq; } +int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other) +{ + Editing *ed= seq_give_editing(scene, FALSE); + + *seq_act= seq_active_get(scene); + + if(*seq_act == NULL) { + return 0; + } + else { + Sequence *seq; + + *seq_other= NULL; + + for(seq= ed->seqbasep->first; seq; seq= seq->next) { + if(seq->flag & SELECT && (seq != (*seq_act))) { + if(*seq_other) { + return 0; + } + else { + *seq_other= seq; + } + } + } + + return (*seq_other != NULL); + } +} + /* api like funcs for adding */ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) @@ -3861,7 +3917,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) if(seq_load->flag & SEQ_LOAD_REPLACE_SEL) { seq_load->flag |= SELECT; - active_seq_set(scene, seq); + seq_active_set(scene, seq); } if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) { diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index b34a5d4ef3e..154851bd248 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4361,7 +4361,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) PointerRNA logic_ptr, settings_ptr; - uiLayout *layout, *row, *split, *subsplit, *box, *col; + uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; char name[32]; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 06c7725984a..2c7082ed3f6 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -203,7 +203,7 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); seq->flag |= SELECT; } @@ -572,7 +572,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); seq->flag |= SELECT; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 4f8ded4e315..bf7f053ad71 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -900,7 +900,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) Scene *scene= CTX_data_scene(C); SpaceSeq *sseq= CTX_wm_space_seq(C); View2D *v2d= &ar->v2d; - Sequence *last_seq = active_seq_get(scene); + Sequence *last_seq = seq_active_get(scene); int sel = 0, j; float pixelx = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index dedde7e10c3..635fceedcd2 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -75,10 +75,6 @@ /* own include */ #include "sequencer_intern.h" -/* XXX */ -//static Sequence *_last_seq=0; -//static int _last_seq_init=0; -/* XXX */ static void error(const char *dummy) {} static void waitcursor(int val) {} static void activate_fileselect(int d1, char *d2, char *d3, void *d4) {} @@ -167,7 +163,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= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); if(last_seq && last_seq->type != SEQ_PLUGIN) return; @@ -441,7 +437,7 @@ static void reload_sound_strip(Scene *scene, char *name) Editing *ed; Sequence *seq, *seqact; SpaceFile *sfile; - Sequence *last_seq= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); ed= scene->ed; @@ -483,7 +479,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= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); @@ -519,7 +515,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= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); Scene *sce; short event; @@ -621,7 +617,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen *error_str= NULL; if (!activeseq) - seq2= active_seq_get(scene); + seq2= seq_active_get(scene); for(seq=ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SELECT) { @@ -684,7 +680,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 = active_seq_get(scene); + Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene); char *error_msg; if(last_seq==0 || !(last_seq->type & SEQ_EFFECT)) return; @@ -753,7 +749,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 = active_seq_get(scene); + Sequence *last_seq = seq_active_get(scene); seq= lb->first; while(seq) { @@ -763,7 +759,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) active_seq_set(scene, NULL); + if(seq==last_seq) seq_active_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); @@ -873,7 +869,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new, int do_ { Sequence *seq; Sequence *seqn = 0; - Sequence *last_seq = active_seq_get(scene); + Sequence *last_seq = seq_active_get(scene); for(seq= old->first; seq; seq= seq->next) { seq->tmp= NULL; @@ -891,7 +887,7 @@ static void recurs_dupli_seq(Scene *scene, ListBase *old, ListBase *new, int do_ if(do_context) { if (seq == last_seq) { - active_seq_set(scene, seqn); + seq_active_set(scene, seqn); } } } @@ -1190,7 +1186,7 @@ void set_filter_seq(Scene *scene) void seq_remap_paths(Scene *scene) { - Sequence *seq, *last_seq = active_seq_get(scene); + Sequence *seq, *last_seq = seq_active_get(scene); Editing *ed= seq_give_editing(scene, FALSE); char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; @@ -1751,7 +1747,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *op) MetaStack *ms; int nothingSelected = TRUE; - seq=active_seq_get(scene); + seq=seq_active_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; } else { @@ -1918,7 +1914,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= active_seq_get(scene); + Sequence *last_seq= seq_active_get(scene); MetaStack *ms; if(last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) { @@ -1930,7 +1926,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) ed->seqbasep= &last_seq->seqbase; - active_seq_set(scene, NULL); + seq_active_set(scene, NULL); } else { @@ -1950,7 +1946,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *op) for(seq= ed->seqbasep->first; seq; seq= seq->next) calc_sequence(scene, seq); - active_seq_set(scene, ms->parseq); + seq_active_set(scene, ms->parseq); ms->parseq->flag |= SELECT; recurs_sel_seq(ms->parseq); @@ -2020,7 +2016,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->strip->len= seqm->len; seqm->strip->us= 1; - active_seq_set(scene, seqm); + seq_active_set(scene, seqm); if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); @@ -2065,7 +2061,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 = active_seq_get(scene); /* last_seq checks ed==NULL */ + Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */ if(last_seq==NULL || last_seq->type!=SEQ_META) return OPERATOR_CANCELLED; @@ -2521,7 +2517,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - Sequence *active_seq = active_seq_get(scene); + Sequence *active_seq = seq_active_get(scene); Sequence *seq, *iseq; int side= RNA_enum_get(op->ptr, "side"); @@ -2597,7 +2593,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *op) { int retval = OPERATOR_CANCELLED; Scene *scene= CTX_data_scene(C); - Sequence *active_seq = active_seq_get(scene); + Sequence *active_seq = seq_active_get(scene); if(active_seq==NULL) return OPERATOR_CANCELLED; @@ -2756,3 +2752,45 @@ void SEQUENCER_OT_paste(wmOperatorType *ot) /* properties */ } + +static int sequencer_swap_data_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Sequence *seq_act; + Sequence *seq_other; + + if(seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { + BKE_report(op->reports, RPT_ERROR, "Must select 2 strips"); + return OPERATOR_CANCELLED; + } + + if(seq_swap(seq_act, seq_other) == 0) { + BKE_report(op->reports, RPT_ERROR, "Strips were not compatible"); + return OPERATOR_CANCELLED; + } + + calc_sequence(scene, seq_act); + calc_sequence(scene, seq_other); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_swap_data(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Sequencer Swap Data"; + ot->idname= "SEQUENCER_OT_swap_data"; + ot->description="Swap 2 sequencer strips"; + + /* api callbacks */ + ot->exec= sequencer_swap_data_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ +} + diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index fd4ee70e258..12cc4219ecb 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -95,6 +95,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot); void SEQUENCER_OT_previous_edit(struct wmOperatorType *ot); void SEQUENCER_OT_next_edit(struct wmOperatorType *ot); void SEQUENCER_OT_swap(struct wmOperatorType *ot); +void SEQUENCER_OT_swap_data(struct wmOperatorType *ot); void SEQUENCER_OT_rendersize(struct wmOperatorType *ot); void SEQUENCER_OT_view_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 559a090a2ee..69457e5c6e8 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -73,6 +73,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_next_edit); WM_operatortype_append(SEQUENCER_OT_previous_edit); WM_operatortype_append(SEQUENCER_OT_swap); + WM_operatortype_append(SEQUENCER_OT_swap_data); WM_operatortype_append(SEQUENCER_OT_rendersize); WM_operatortype_append(SEQUENCER_OT_view_all); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 170b9fbda80..355b6c1f67b 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -166,7 +166,7 @@ void select_single_seq(Scene *scene, Sequence *seq, int deselect_all) /* BRING B if(deselect_all) deselect_all_seq(scene); - active_seq_set(scene, seq); + seq_active_set(scene, seq); if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) { if(seq->strip) @@ -185,7 +185,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= active_seq_get(scene); + Sequence *seq= seq_active_get(scene); Sequence *neighbor; int change = 0; if (seq) { @@ -392,7 +392,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) deselect_all_seq(scene); if(seq) { - active_seq_set(scene, seq); + seq_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if(seq->strip) { @@ -794,7 +794,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= active_seq_get(scene); + Sequence *seq_act= seq_active_get(scene); if (ed==NULL || seq_act==NULL) return OPERATOR_CANCELLED; |