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:
authorAndrea Weikert <elubie@gmx.net>2009-10-30 23:40:41 +0300
committerAndrea Weikert <elubie@gmx.net>2009-10-30 23:40:41 +0300
commit0cf1d391edba39f211ee122314631adfb76272b8 (patch)
treedf0b89e4ea01e13f0f4a036ef06863ca36f9c49a /source/blender/editors/space_sequencer/sequencer_edit.c
parent93173a6dd4eaf1955516e35335009494a92f300b (diff)
2.5 Sequencer
Swap active sequence with the sequence on the right (CTRL+R) or left (CTRL+L). was small Durian wish. Note: in find_next_prev removed the code to find selected only if sel was != 0 I believe it should be possible to pass -1 in the case I want to find the next strip regardless of selection state.
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c112
1 files changed, 110 insertions, 2 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 339ba55bfd1..7557d5420bd 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -298,8 +298,6 @@ Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel)
if(ed==NULL) return NULL;
- if (sel) sel = SELECT;
-
seq= ed->seqbasep->first;
while(seq) {
if( (seq!=test) &&
@@ -2560,4 +2558,114 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
+}
+
+static void swap_sequence(Sequence* seqa, Sequence* seqb)
+{
+ int gap = seqb->startdisp - seqa->enddisp;
+ seqb->start = seqa->start;
+ calc_sequence(seqb);
+ seqa->start = seqb->enddisp + gap;
+ calc_sequence(seqa);
+}
+
+static Sequence* sequence_find_parent(Scene* scene, Sequence* child)
+{
+ Editing *ed= seq_give_editing(scene, FALSE);
+ Sequence *parent= NULL;
+ Sequence *seq;
+
+ if(ed==NULL) return NULL;
+
+ for(seq= ed->seqbasep->first; seq; seq= seq->next) {
+ if ( (seq != child) && seq_is_parent(seq, child) ) {
+ parent = seq;
+ break;
+ }
+ }
+ return parent;
+
+}
+
+static int sequencer_swap_internal_exec(bContext *C, int side)
+{
+ Scene *scene= CTX_data_scene(C);
+ Editing *ed= seq_give_editing(scene, FALSE);
+ Sequence *active_seq = get_last_seq(scene);
+ Sequence *seq;
+
+ if(ed==NULL) return OPERATOR_CANCELLED;
+ if(active_seq==NULL) return OPERATOR_CANCELLED;
+
+ seq = find_next_prev_sequence(scene, active_seq, side, -1);
+
+ if(seq) {
+
+ /* disallow effect strips */
+ if (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)
+ return OPERATOR_CANCELLED;
+ if (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)
+ return OPERATOR_CANCELLED;
+
+ /* disallow if parent strip (effect strip) is attached */
+ if ( sequence_find_parent(scene, active_seq)) {
+ return OPERATOR_CANCELLED;
+ }
+
+ switch (side) {
+ case SEQ_SIDE_LEFT:
+ swap_sequence(seq, active_seq);
+ break;
+ case SEQ_SIDE_RIGHT:
+ swap_sequence(active_seq, seq);
+ break;
+ }
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+static int sequencer_swap_right_exec(bContext *C, wmOperator *op)
+{
+ return sequencer_swap_internal_exec(C, SEQ_SIDE_RIGHT);
+}
+
+void SEQUENCER_OT_swap_right(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Swap Strip Right";
+ ot->idname= "SEQUENCER_OT_swap_right";
+ ot->description="Swap active strip with strip to the right.";
+
+ /* api callbacks */
+ ot->exec= sequencer_swap_right_exec;
+ ot->poll= ED_operator_sequencer_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+}
+
+static int sequencer_swap_left_exec(bContext *C, wmOperator *op)
+{
+ return sequencer_swap_internal_exec(C, SEQ_SIDE_LEFT);
+}
+
+void SEQUENCER_OT_swap_left(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Swap Strip Left";
+ ot->idname= "SEQUENCER_OT_swap_left";
+ ot->description="Swap active strip with strip to the left.";
+
+ /* api callbacks */
+ ot->exec= sequencer_swap_left_exec;
+ ot->poll= ED_operator_sequencer_active;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
} \ No newline at end of file