diff options
Diffstat (limited to 'source')
3 files changed, 44 insertions, 13 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 9c3191c93d6..20ad1b61981 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1388,13 +1388,20 @@ static int seq_get_snaplimit(View2D *v2d) } #endif -void seq_snap(Scene *scene, short event) +/* Operator functions */ + +/* snap operator*/ +static int sequencer_snap_exec(bContext *C, wmOperator *op) { + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - + int snap_frame; - if(ed==NULL) return; + if(ed==NULL) return OPERATOR_CANCELLED; + + snap_frame= RNA_int_get(op->ptr, "frame"); /* problem: contents of meta's are all shifted to the same position... */ @@ -1403,12 +1410,12 @@ void seq_snap(Scene *scene, short event) if (seq->flag & SELECT && !(seq->depth==0 && seq->flag & SEQ_LOCK) && seq_tx_test(seq)) { if((seq->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0) { - seq->start= CFRA-seq->startofs+seq->startstill; + seq->start= snap_frame-seq->startofs+seq->startstill; } else { if(seq->flag & SEQ_LEFTSEL) { - seq_tx_set_final_left(seq, CFRA); + seq_tx_set_final_left(seq, snap_frame); } else { /* SEQ_RIGHTSEL */ - seq_tx_set_final_right(seq, CFRA); + seq_tx_set_final_right(seq, snap_frame); } seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL); } @@ -1438,21 +1445,43 @@ void seq_snap(Scene *scene, short event) /* as last: */ sort_seq(scene); - + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; } -void seq_snap_menu(Scene *scene) +static int sequencer_snap_invoke(bContext *C, wmOperator *op, wmEvent *event) { - short event; + Scene *scene = CTX_data_scene(C); - event= pupmenu("Snap %t|To Current Frame%x1"); - if(event < 1) return; + int snap_frame; - seq_snap(scene, event); + snap_frame= CFRA; + + RNA_int_set(op->ptr, "frame", snap_frame); + return sequencer_snap_exec(C, op); } -/* Operator functions */ +void SEQUENCER_OT_snap(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Snap strips"; + ot->idname= "SEQUENCER_OT_snap"; + + /* api callbacks */ + ot->invoke= sequencer_snap_invoke; + ot->exec= sequencer_snap_exec; + + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will snaped", INT_MIN, INT_MAX); +} +/* mute operator */ static int sequencer_mute_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 1f78c4d5199..6d61f743917 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -89,6 +89,7 @@ void SEQUENCER_OT_images_separate(struct wmOperatorType *ot); void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot); +void SEQUENCER_OT_snap(struct wmOperatorType *ot); void SEQUENCER_OT_view_all(struct wmOperatorType *ot); void SEQUENCER_OT_view_selected(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 600ef87e1b3..c6e5fbe39a4 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -77,6 +77,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_toggle); WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); + WM_operatortype_append(SEQUENCER_OT_snap); WM_operatortype_append(SEQUENCER_OT_view_all); WM_operatortype_append(SEQUENCER_OT_view_selected); |