2.5 Sequencer
New Operator for 'Move current frame to next/previous edit point' Keymap: PageUp/PageDown (small Durian wish)
This commit is contained in:
@@ -2445,3 +2445,119 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot)
|
|||||||
/* flags */
|
/* flags */
|
||||||
ot->flag= OPTYPE_REGISTER;
|
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 */
|
||||||
|
}
|
||||||
@@ -91,6 +91,8 @@ void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot);
|
|||||||
void SEQUENCER_OT_meta_make(struct wmOperatorType *ot);
|
void SEQUENCER_OT_meta_make(struct wmOperatorType *ot);
|
||||||
void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot);
|
void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot);
|
||||||
void SEQUENCER_OT_snap(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_all(struct wmOperatorType *ot);
|
||||||
void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
|
void SEQUENCER_OT_view_selected(struct wmOperatorType *ot);
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ void sequencer_operatortypes(void)
|
|||||||
WM_operatortype_append(SEQUENCER_OT_meta_make);
|
WM_operatortype_append(SEQUENCER_OT_meta_make);
|
||||||
WM_operatortype_append(SEQUENCER_OT_meta_separate);
|
WM_operatortype_append(SEQUENCER_OT_meta_separate);
|
||||||
WM_operatortype_append(SEQUENCER_OT_snap);
|
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_all);
|
||||||
WM_operatortype_append(SEQUENCER_OT_view_selected);
|
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_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_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 :/ */
|
/* Mouse selection, a bit verbose :/ */
|
||||||
WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
|
WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user