forked from bartvdbraak/blender
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.
This commit is contained in:
parent
93173a6dd4
commit
0cf1d391ed
@ -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) &&
|
||||
@ -2561,3 +2559,113 @@ void SEQUENCER_OT_previous_edit(wmOperatorType *ot)
|
||||
|
||||
/* 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 */
|
||||
}
|
@ -93,6 +93,8 @@ void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot);
|
||||
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_right(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_swap_left(struct wmOperatorType *ot);
|
||||
|
||||
void SEQUENCER_OT_view_all(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
|
||||
|
@ -79,6 +79,8 @@ void sequencer_operatortypes(void)
|
||||
WM_operatortype_append(SEQUENCER_OT_snap);
|
||||
WM_operatortype_append(SEQUENCER_OT_next_edit);
|
||||
WM_operatortype_append(SEQUENCER_OT_previous_edit);
|
||||
WM_operatortype_append(SEQUENCER_OT_swap_right);
|
||||
WM_operatortype_append(SEQUENCER_OT_swap_left);
|
||||
|
||||
WM_operatortype_append(SEQUENCER_OT_view_all);
|
||||
WM_operatortype_append(SEQUENCER_OT_view_selected);
|
||||
@ -147,6 +149,8 @@ void sequencer_keymap(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_right", RKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_left", LKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* Mouse selection, a bit verbose :/ */
|
||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user