VSE: Add select under playhead, and shortcuts for left, right, under.

Add `UNDER` option for `left_right` property of `sequencer.select` operator.
Add Equal as shortcut for select under playhead, and move Insert Gaps to backspace + ctrl.
Add extend shortcut for left, right under options.
The function is added to Select > Playhead menu.

Reviewed By: ISS

Differential Revision: https://developer.blender.org/D7679
This commit is contained in:
Peter Fog 2020-06-01 04:14:54 +02:00 committed by Richard Antalik
parent d0e028a78e
commit 95e3356a27
4 changed files with 33 additions and 4 deletions

View File

@ -2463,7 +2463,7 @@ def km_sequencer(params):
{"properties": [("all", False)]}),
("sequencer.gap_remove", {"type": 'BACK_SPACE', "value": 'PRESS', "shift": True},
{"properties": [("all", True)]}),
("sequencer.gap_insert", {"type": 'EQUAL', "value": 'PRESS', "shift": True}, None),
("sequencer.gap_insert", {"type": 'BACK_SPACE', "value": 'PRESS', "ctrl": True}, None),
("sequencer.snap", {"type": 'S', "value": 'PRESS', "shift": True}, None),
("sequencer.swap_inputs", {"type": 'S', "value": 'PRESS', "alt": True}, None),
*(
@ -2521,6 +2521,15 @@ def km_sequencer(params):
{"properties": [("left_right", 'LEFT'), ("linked_time", True)]}),
("sequencer.select", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
{"properties": [("left_right", 'RIGHT'), ("linked_time", True)]}),
("sequencer.select", {"type": 'EQUAL', "value": 'PRESS'},
{"properties": [("left_right", 'UNDER'), ("linked_time", True)]}),
("sequencer.select", {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
{"properties": [("left_right", 'LEFT'), ("linked_time", True), ("extend", True)]}),
("sequencer.select", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
{"properties": [("left_right", 'RIGHT'), ("linked_time", True), ("extend", True)]}),
("sequencer.select", {"type": 'EQUAL', "value": 'PRESS', "shift": True},
{"properties": [("left_right", 'UNDER'), ("linked_time", True), ("extend", True)]}),
*_template_items_context_menu("SEQUENCER_MT_context_menu", params.context_menu_event),
])

View File

@ -382,6 +382,9 @@ class SEQUENCER_MT_select_playhead(Menu):
def draw(self, _context):
layout = self.layout
props = layout.operator("sequencer.select", text="Under")
props.left_right = 'UNDER'
props.linked_time = True
props = layout.operator("sequencer.select", text="Left")
props.left_right = 'LEFT'
props.linked_time = True

View File

@ -191,6 +191,7 @@ enum {
SEQ_SELECT_LR_MOUSE,
SEQ_SELECT_LR_LEFT,
SEQ_SELECT_LR_RIGHT,
SEQ_SELECT_LR_UNDER_PLAYHEAD,
};
/* Defines used internally. */

View File

@ -412,6 +412,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
ret_value = OPERATOR_FINISHED;
}
/* Select left, right or under playhead. */
else if (left_right != SEQ_SELECT_LR_NONE) {
/* Use different logic for this. */
float x;
@ -421,19 +422,33 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
switch (left_right) {
case SEQ_SELECT_LR_MOUSE:
/* 10px margin around playhead to select under playhead with mouse. */
float margin = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask) * 10;
x = UI_view2d_region_to_view_x(v2d, mval[0]);
if (x >= CFRA - margin && x <= CFRA + margin) {
x = CFRA;
}
break;
case SEQ_SELECT_LR_LEFT:
x = CFRA - 1.0f;
break;
case SEQ_SELECT_LR_RIGHT:
x = CFRA + 1.0f;
break;
case SEQ_SELECT_LR_UNDER_PLAYHEAD:
default:
x = CFRA;
break;
}
SEQP_BEGIN (ed, seq) {
if (((x < CFRA) && (seq->enddisp <= CFRA)) || ((x >= CFRA) && (seq->startdisp >= CFRA))) {
/* Select under playhead. */
if ((x == CFRA) && (seq->startdisp <= CFRA) && (seq->enddisp >= CFRA)) {
seq->flag = SELECT;
recurs_sel_seq(seq);
}
/* Select left or right. */
else if ((x < CFRA && seq->enddisp <= CFRA) || (x > CFRA && seq->startdisp >= CFRA)) {
seq->flag |= SELECT;
recurs_sel_seq(seq);
}
@ -627,8 +642,9 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
static const EnumPropertyItem sequencer_select_left_right_types[] = {
{SEQ_SELECT_LR_NONE, "NONE", 0, "None", "Don't do left-right selection"},
{SEQ_SELECT_LR_MOUSE, "MOUSE", 0, "Mouse", "Use mouse position for selection"},
{SEQ_SELECT_LR_LEFT, "LEFT", 0, "Left", "Select left"},
{SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select right"},
{SEQ_SELECT_LR_LEFT, "LEFT", 0, "Left", "Select to the left of the playhead"},
{SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select to the right of the playhead"},
{SEQ_SELECT_LR_UNDER_PLAYHEAD, "UNDER", 0, "Under", "Select under the playhead"},
{0, NULL, 0, NULL, NULL},
};
PropertyRNA *prop;