Sequencer: split select side of frame out of the select operator
The select operator was getting overloaded with functionality unrelated to selecting the strip at the mouse position. - Don't save settings, allowing the keymap only to include non-default options. - Fix selecting strips overlapping the current frame overwrite all flags.
This commit is contained in:
@@ -2474,21 +2474,19 @@ def km_sequencer(params):
|
||||
)
|
||||
),
|
||||
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS'},
|
||||
{"properties": [
|
||||
("extend", False), ("deselect_all", True),
|
||||
("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("deselect_all", True)]}),
|
||||
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "shift": True},
|
||||
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("extend", True)]}),
|
||||
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "alt": True},
|
||||
{"properties": [("extend", False), ("linked_handle", True), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("linked_handle", True)]}),
|
||||
("sequencer.select", {"type": params.select_mouse, "value": 'PRESS', "shift": True, "alt": True},
|
||||
{"properties": [("extend", True), ("linked_handle", True), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("extend", True), ("linked_handle", True)]}),
|
||||
("sequencer.select",
|
||||
{"type": params.select_mouse, "value": 'PRESS' if params.legacy else 'CLICK', "ctrl": True},
|
||||
{"properties": [("linked_handle", False), ("left_right", 'MOUSE'), ("linked_time", True), ("extend", False)]}),
|
||||
{"properties": [("side_of_frame", True), ("linked_time", True)]}),
|
||||
("sequencer.select",
|
||||
{"type": params.select_mouse, "value": 'PRESS' if params.legacy else 'CLICK', "ctrl": True, "shift": True},
|
||||
{"properties": [("linked_handle", False), ("left_right", 'MOUSE'), ("linked_time", True), ("extend", True)]}),
|
||||
{"properties": [("side_of_frame", True), ("linked_time", True), ("extend", True)]}),
|
||||
("sequencer.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True}, None),
|
||||
("sequencer.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True}, None),
|
||||
("sequencer.select_linked_pick", {"type": 'L', "value": 'PRESS'},
|
||||
@@ -2517,18 +2515,18 @@ def km_sequencer(params):
|
||||
{"properties": [("mode", 'TIME_EXTEND')]}),
|
||||
("marker.add", {"type": 'M', "value": 'PRESS'}, None),
|
||||
("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None),
|
||||
("sequencer.select", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
|
||||
{"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", 'OVERLAP'), ("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", 'OVERLAP'), ("linked_time", True), ("extend", True)]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'LEFT_BRACKET', "value": 'PRESS'},
|
||||
{"properties": [("side", 'LEFT')]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
|
||||
{"properties": [("side", 'RIGHT')]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'EQUAL', "value": 'PRESS'},
|
||||
{"properties": [("side", 'OVERLAP')]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'LEFT_BRACKET', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("side", 'LEFT'), ("extend", True)]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("side", 'RIGHT'), ("extend", True)]}),
|
||||
("sequencer.select_side_of_frame", {"type": 'EQUAL', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("side", 'OVERLAP'), ("extend", True)]}),
|
||||
|
||||
*_template_items_context_menu("SEQUENCER_MT_context_menu", params.context_menu_event),
|
||||
])
|
||||
|
||||
@@ -1785,17 +1785,17 @@ def km_sequencer(params):
|
||||
)
|
||||
),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
|
||||
{"properties": [("extend", False), ("deselect_all", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("deselect_all", True)]}),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("extend", True)]}),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "alt": True},
|
||||
{"properties": [("extend", False), ("linked_handle", True), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("linked_handle", True)]}),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "alt": True},
|
||||
{"properties": [("extend", True), ("linked_handle", True), ("left_right", 'NONE'), ("linked_time", False)]}),
|
||||
{"properties": [("extend", True), ("linked_handle", True)]}),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
|
||||
{"properties": [("extend", False), ("linked_handle", False), ("left_right", 'MOUSE'), ("linked_time", True)]}),
|
||||
{"properties": [("side_of_frame", True), ("linked_time", True)]}),
|
||||
("sequencer.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True, "ctrl": True},
|
||||
{"properties": [("extend", True), ("linked_handle", False), ("left_right", 'NONE'), ("linked_time", True)]}),
|
||||
{"properties": [("extend", True), ("side_of_frame", True), ("linked_time", True)]}),
|
||||
("sequencer.select_more", {"type": 'UP_ARROW', "value": 'PRESS'}, None),
|
||||
("sequencer.select_less", {"type": 'DOWN_ARROW', "value": 'PRESS'}, None),
|
||||
("sequencer.select_linked_pick", {"type": 'RIGHT_BRACKET', "value": 'PRESS'},
|
||||
|
||||
@@ -394,23 +394,6 @@ class SEQUENCER_MT_select_linked(Menu):
|
||||
layout.operator("sequencer.select_more", text="More")
|
||||
|
||||
|
||||
class SEQUENCER_MT_select_side_of_frame(Menu):
|
||||
bl_label = "Side of Current Frame"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
props = layout.operator("sequencer.select", text="Overlap")
|
||||
props.left_right = 'OVERLAP'
|
||||
props.linked_time = True
|
||||
props = layout.operator("sequencer.select", text="Left")
|
||||
props.left_right = 'LEFT'
|
||||
props.linked_time = True
|
||||
props = layout.operator("sequencer.select", text="Right")
|
||||
props.left_right = 'RIGHT'
|
||||
props.linked_time = True
|
||||
|
||||
|
||||
class SEQUENCER_MT_select(Menu):
|
||||
bl_label = "Select"
|
||||
|
||||
@@ -429,7 +412,7 @@ class SEQUENCER_MT_select(Menu):
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("SEQUENCER_MT_select_side_of_frame")
|
||||
layout.operator_menu_enum("sequencer.select_side_of_frame", "side", text="Side of Frame...")
|
||||
layout.menu("SEQUENCER_MT_select_handle", text="Handle")
|
||||
layout.menu("SEQUENCER_MT_select_channel", text="Channel")
|
||||
layout.menu("SEQUENCER_MT_select_linked", text="Linked")
|
||||
@@ -2221,7 +2204,6 @@ classes = (
|
||||
SEQUENCER_MT_view_toggle,
|
||||
SEQUENCER_MT_preview_zoom,
|
||||
SEQUENCER_MT_proxy,
|
||||
SEQUENCER_MT_select_side_of_frame,
|
||||
SEQUENCER_MT_select_handle,
|
||||
SEQUENCER_MT_select_channel,
|
||||
SEQUENCER_MT_select_linked,
|
||||
|
||||
@@ -158,6 +158,7 @@ void SEQUENCER_OT_view_all_preview(struct wmOperatorType *ot);
|
||||
/* sequencer_select.c */
|
||||
void SEQUENCER_OT_select_all(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select_side_of_frame(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select_more(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select_less(struct wmOperatorType *ot);
|
||||
void SEQUENCER_OT_select_linked(struct wmOperatorType *ot);
|
||||
@@ -186,14 +187,6 @@ enum {
|
||||
SEQ_UNSELECTED,
|
||||
};
|
||||
|
||||
enum {
|
||||
SEQ_SELECT_LR_NONE = 0,
|
||||
SEQ_SELECT_LR_MOUSE,
|
||||
SEQ_SELECT_LR_LEFT,
|
||||
SEQ_SELECT_LR_RIGHT,
|
||||
SEQ_SELECT_LR_OVERLAP,
|
||||
};
|
||||
|
||||
/* Defines used internally. */
|
||||
#define SCE_MARKERS 0 /* XXX - dummy */
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ void sequencer_operatortypes(void)
|
||||
WM_operatortype_append(SEQUENCER_OT_select_linked);
|
||||
WM_operatortype_append(SEQUENCER_OT_select_handles);
|
||||
WM_operatortype_append(SEQUENCER_OT_select_side);
|
||||
WM_operatortype_append(SEQUENCER_OT_select_side_of_frame);
|
||||
WM_operatortype_append(SEQUENCER_OT_select_box);
|
||||
WM_operatortype_append(SEQUENCER_OT_select_grouped);
|
||||
|
||||
|
||||
@@ -363,8 +363,8 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
|
||||
const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
|
||||
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
|
||||
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
|
||||
bool side_of_frame = RNA_boolean_get(op->ptr, "side_of_frame");
|
||||
bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
|
||||
int left_right = RNA_enum_get(op->ptr, "left_right");
|
||||
int mval[2];
|
||||
int ret_value = OPERATOR_CANCELLED;
|
||||
|
||||
@@ -387,9 +387,9 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
seq = find_nearest_seq(scene, v2d, &hand, mval);
|
||||
|
||||
/* XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip */
|
||||
if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) {
|
||||
left_right = SEQ_SELECT_LR_NONE;
|
||||
/* XXX - not nice, Ctrl+RMB needs to do side_of_frame only when not over a strip */
|
||||
if (seq && linked_time) {
|
||||
side_of_frame = false;
|
||||
}
|
||||
|
||||
if (marker) {
|
||||
@@ -413,43 +413,23 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
|
||||
ret_value = OPERATOR_FINISHED;
|
||||
}
|
||||
/* Select left, right or overlapping the current frame. */
|
||||
else if (left_right != SEQ_SELECT_LR_NONE) {
|
||||
else if (side_of_frame) {
|
||||
/* Use different logic for this. */
|
||||
float x;
|
||||
if (extend == false) {
|
||||
ED_sequencer_deselect_all(scene);
|
||||
}
|
||||
|
||||
switch (left_right) {
|
||||
case SEQ_SELECT_LR_MOUSE: {
|
||||
/* 10px margin around current frame to select under the current frame 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_OVERLAP:
|
||||
default:
|
||||
x = CFRA;
|
||||
break;
|
||||
/* 10px margin around current frame to select under the current frame 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;
|
||||
}
|
||||
|
||||
SEQP_BEGIN (ed, seq) {
|
||||
/* Select overlapping the current frame. */
|
||||
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)) {
|
||||
if ((x < CFRA && seq->enddisp <= CFRA) || (x > CFRA && seq->startdisp >= CFRA)) {
|
||||
seq->flag |= SELECT;
|
||||
recurs_sel_seq(seq);
|
||||
}
|
||||
@@ -640,14 +620,6 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
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 to the left of the current frame"},
|
||||
{SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select to the right of the current frame"},
|
||||
{SEQ_SELECT_LR_OVERLAP, "OVERLAP", 0, "Overlap", "Select overlapping the current frame"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* Identifiers. */
|
||||
@@ -666,24 +638,35 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
|
||||
|
||||
/* Properties. */
|
||||
WM_operator_properties_generic_select(ot);
|
||||
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
|
||||
|
||||
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_boolean(ot->srna,
|
||||
"deselect_all",
|
||||
false,
|
||||
"Deselect On Nothing",
|
||||
"Deselect all when nothing under the cursor");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
RNA_def_boolean(
|
||||
ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip");
|
||||
/* For animation this is enum but atm having an enum isn't useful for us. */
|
||||
RNA_def_enum(ot->srna,
|
||||
"left_right",
|
||||
sequencer_select_left_right_types,
|
||||
0,
|
||||
"Left/Right",
|
||||
"Select based on the current frame side the cursor is on");
|
||||
RNA_def_boolean(
|
||||
ot->srna, "linked_time", 0, "Linked Time", "Select other strips at the same time");
|
||||
|
||||
prop = RNA_def_boolean(ot->srna,
|
||||
"linked_handle",
|
||||
false,
|
||||
"Linked Handle",
|
||||
"Select handles next to the active strip");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_boolean(
|
||||
ot->srna, "linked_time", false, "Linked Time", "Select other strips at the same time");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_boolean(
|
||||
ot->srna,
|
||||
"side_of_frame",
|
||||
false,
|
||||
"Side of Frame",
|
||||
"Select all strips on same side of the current frame as the mouse cursor");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
/* Run recursively to select linked. */
|
||||
@@ -953,6 +936,75 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot)
|
||||
"The side of the handle that is selected");
|
||||
}
|
||||
|
||||
static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Editing *ed = BKE_sequencer_editing_get(scene, false);
|
||||
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
||||
const int side = RNA_enum_get(op->ptr, "side");
|
||||
Sequence *seq;
|
||||
|
||||
if (ed == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (extend == false) {
|
||||
ED_sequencer_deselect_all(scene);
|
||||
}
|
||||
const int cfra = CFRA;
|
||||
SEQP_BEGIN (ed, seq) {
|
||||
bool test = false;
|
||||
switch (side) {
|
||||
case -1:
|
||||
test = (cfra >= seq->startdisp);
|
||||
break;
|
||||
case 1:
|
||||
test = (cfra <= seq->enddisp);
|
||||
break;
|
||||
case 0:
|
||||
test = (cfra <= seq->enddisp) && (cfra >= seq->startdisp);
|
||||
break;
|
||||
}
|
||||
|
||||
if (test) {
|
||||
seq->flag |= SELECT;
|
||||
recurs_sel_seq(seq);
|
||||
}
|
||||
}
|
||||
SEQ_END;
|
||||
|
||||
ED_outliner_select_sync_from_sequence_tag(C);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void SEQUENCER_OT_select_side_of_frame(wmOperatorType *ot)
|
||||
{
|
||||
static const EnumPropertyItem sequencer_select_left_right_types[] = {
|
||||
{0, "OVERLAP", 0, "Overlap", "Select overlapping the current frame"},
|
||||
{-1, "LEFT", 0, "Left", "Select to the left of the current frame"},
|
||||
{1, "RIGHT", 0, "Right", "Select to the right of the current frame"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
/* Identifiers. */
|
||||
ot->name = "Select Side of Frame";
|
||||
ot->idname = "SEQUENCER_OT_select_side_of_frame";
|
||||
ot->description = "Select strips relative to the current frame";
|
||||
|
||||
/* Api callbacks. */
|
||||
ot->exec = sequencer_select_side_of_frame_exec;
|
||||
ot->poll = ED_operator_sequencer_active;
|
||||
|
||||
/* Flags. */
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
|
||||
/* Properties. */
|
||||
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
|
||||
ot->prop = RNA_def_enum(ot->srna, "side", sequencer_select_left_right_types, 0, "Side", "");
|
||||
}
|
||||
|
||||
static int sequencer_select_side_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
Reference in New Issue
Block a user