diff options
author | Andrea Weikert <elubie@gmx.net> | 2009-10-28 22:53:25 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2009-10-28 22:53:25 +0300 |
commit | c2f9cfb40a740f926d78cbdb20f1f8b09cc7aadd (patch) | |
tree | ff44db23ced9a51502099b133e418118556cf47f /source | |
parent | ce441678debae50624d4422ae5bccab011d9fb59 (diff) |
2.5 Sequencer
New Operator for 'Move current frame to next/previous edit point'
Keymap: PageUp/PageDown
(small Durian wish)
Diffstat (limited to 'source')
3 files changed, 123 insertions, 0 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 80b018eec66..d2d4b7ac2c4 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2445,3 +2445,119 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER; } + + +static int find_next_prev_edit(Scene *scene, int cfra, int side) +{ + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq,*best_seq = NULL,*frame_seq = NULL; + + int dist, best_dist; + best_dist = MAXFRAME*2; + + if(ed==NULL) return cfra; + + for(seq= ed->seqbasep->first; seq; seq= seq->next) { + dist = MAXFRAME*2; + + switch (side) { + case SEQ_SIDE_LEFT: + if (seq->startdisp < cfra) { + dist = cfra - seq->startdisp; + } + break; + case SEQ_SIDE_RIGHT: + if (seq->startdisp > cfra) { + dist = seq->startdisp - cfra; + } else if (seq->startdisp == cfra) { + frame_seq=seq; + } + break; + } + + if (dist < best_dist) { + best_dist = dist; + best_seq = seq; + } + } + + /* if no sequence to the right is found and the + frame is on the start of the last sequence, + move to the end of the last sequence */ + if (frame_seq) cfra = frame_seq->enddisp; + + return best_seq ? best_seq->startdisp : cfra; +} + +static int next_prev_edit_internal(Scene *scene, int side) { + Editing *ed= seq_give_editing(scene, FALSE); + int change=0; + int cfra = CFRA; + int nfra= find_next_prev_edit(scene, cfra, side); + + if (nfra != cfra) { + CFRA = nfra; + change= 1; + } + + return change; +} + +/* select less operator */ +static int sequencer_next_edit_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + if (next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) { + ED_area_tag_redraw(CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + } + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_next_edit(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Next Edit"; + ot->idname= "SEQUENCER_OT_next_edit"; + ot->description="Move frame to next edit point."; + + /* api callbacks */ + ot->exec= sequencer_next_edit_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ +} + +/* move frame to previous edit point operator */ +static int sequencer_previous_edit_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + if (next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) { + ED_area_tag_redraw(CTX_wm_area(C)); + } + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_previous_edit(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Previous Edit"; + ot->idname= "SEQUENCER_OT_previous_edit"; + ot->description="Move frame to previous edit point."; + + /* api callbacks */ + ot->exec= sequencer_previous_edit_exec; + ot->poll= ED_operator_sequencer_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ +}
\ No newline at end of file diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index d45d7bf4d18..c69a57931b9 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -91,6 +91,8 @@ 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_previous_edit(struct wmOperatorType *ot); +void SEQUENCER_OT_next_edit(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 58ac143d349..0e4a8df04c6 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -77,6 +77,8 @@ void sequencer_operatortypes(void) 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_next_edit); + WM_operatortype_append(SEQUENCER_OT_previous_edit); WM_operatortype_append(SEQUENCER_OT_view_all); WM_operatortype_append(SEQUENCER_OT_view_selected); @@ -142,6 +144,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); + 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); + /* Mouse selection, a bit verbose :/ */ WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); |