VSE: Add option to select handles with box selection

Patch adds an "Handle" option to the `SEQUENCER_OT_box_select` operator,
that allows to select the handles instead of whole strips.
Feature is mapped to Alt key modifier

A difference from the proposed design in T70730 is that covering the entire strip with the box actually selects both handles.

Reviewed By: iss

Differential Revision: https://developer.blender.org/D6372
This commit is contained in:
Richard Antalik 2020-02-09 17:59:13 +01:00
parent f780057d52
commit 5314161491
Notes: blender-bot 2023-02-14 01:57:12 +01:00
Referenced by commit 10b04fa316, Revert "VSE: Add option to select handles with box selection"
4 changed files with 58 additions and 7 deletions

View File

@ -2477,6 +2477,14 @@ def km_sequencer(params):
("sequencer.select_box", {"type": params.select_tweak, "value": 'ANY', "ctrl": True},
{"properties": [("tweak", True), ("mode", 'SUB')]}),
("sequencer.select_box", {"type": 'B', "value": 'PRESS'}, None),
("sequencer.select_box", {"type": 'B', "value": 'PRESS', "alt": True},
{"properties": [("handles", True)]}),
("sequencer.select_box", {"type": params.select_tweak, "value": 'ANY', "alt": True},
{"properties": [("handles", True), ("tweak", True), ("mode", 'SET')]}),
("sequencer.select_box", {"type": params.select_tweak, "value": 'ANY', "shift": True, "alt": True},
{"properties": [("handles", True), ("tweak", True), ("mode", 'ADD')]}),
("sequencer.select_box", {"type": params.select_tweak, "value": 'ANY', "ctrl": True, "alt": True},
{"properties": [("handles", True), ("tweak", True), ("mode", 'SUB')]}),
("sequencer.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
op_menu("SEQUENCER_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("SEQUENCER_MT_change", {"type": 'C', "value": 'PRESS'}),

View File

@ -449,7 +449,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
}
/* clamp handles to defined size in pixel space */
static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx)
float sequence_handle_size_get_clamped(Sequence *seq, const float pixelx)
{
const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN;
const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX;
@ -806,7 +806,7 @@ static void draw_seq_strip(const bContext *C,
View2D *v2d = &ar->v2d;
float x1, x2, y1, y2;
unsigned char col[4], background_col[4], is_single_image;
const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx);
const float handsize_clamped = sequence_handle_size_get_clamped(seq, pixelx);
/* we need to know if this is a single image/color or not for drawing */
is_single_image = (char)BKE_sequence_single_check(seq);

View File

@ -54,6 +54,7 @@ void sequencer_draw_preview(const struct bContext *C,
void color3ubv_from_seq(struct Scene *curscene, struct Sequence *seq, unsigned char col[3]);
void sequencer_special_update_set(Sequence *seq);
float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx);
/* UNUSED */
// void seq_reset_imageofs(struct SpaceSeq *sseq);

View File

@ -1018,15 +1018,17 @@ void SEQUENCER_OT_select_side(wmOperatorType *ot)
static int sequencer_box_select_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
if (ed == NULL) {
return OPERATOR_CANCELLED;
}
View2D *v2d = UI_view2d_fromcontext(C);
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool handles = RNA_boolean_get(op->ptr, "handles");
const bool select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
ED_sequencer_deselect_all(scene);
}
@ -1039,8 +1041,44 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op)
rctf rq;
seq_rectf(seq, &rq);
if (BLI_rctf_isect(&rq, &rectf, NULL)) {
SET_FLAG_FROM_TEST(seq->flag, select, SELECT);
recurs_sel_seq(seq);
if (handles) {
/* Get the handles draw size. */
float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
float handsize = sequence_handle_size_get_clamped(seq, pixelx) * 0.75f;
/* Right handle. */
if (rectf.xmax > (seq->enddisp - handsize)) {
if (select) {
seq->flag |= SELECT | SEQ_RIGHTSEL;
}
else {
/* Deselect the strip if it's left with no handles selected. */
if ((seq->flag & SEQ_RIGHTSEL) && ((seq->flag & SEQ_LEFTSEL) == 0)) {
seq->flag &= ~SELECT;
}
seq->flag &= ~SEQ_RIGHTSEL;
}
}
/* Left handle. */
if (rectf.xmin < (seq->startdisp + handsize)) {
if (select) {
seq->flag |= SELECT | SEQ_LEFTSEL;
}
else {
/* Deselect the strip if it's left with no handles selected. */
if ((seq->flag & SEQ_LEFTSEL) && ((seq->flag & SEQ_RIGHTSEL) == 0)) {
seq->flag &= ~SELECT;
}
seq->flag &= ~SEQ_LEFTSEL;
}
}
}
/* Regular box selection. */
else {
SET_FLAG_FROM_TEST(seq->flag, select, SELECT);
seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
}
}
}
@ -1072,6 +1110,8 @@ static int sequencer_box_select_invoke(bContext *C, wmOperator *op, const wmEven
void SEQUENCER_OT_select_box(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Box Select";
ot->idname = "SEQUENCER_OT_select_box";
@ -1092,9 +1132,11 @@ void SEQUENCER_OT_select_box(wmOperatorType *ot)
WM_operator_properties_gesture_box(ot);
WM_operator_properties_select_operation_simple(ot);
PropertyRNA *prop = RNA_def_boolean(
prop = RNA_def_boolean(
ot->srna, "tweak", 0, "Tweak", "Operator has been activated using a tweak event");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna, "handles", 0, "Select Handles", "Select the strips' handles");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/* ****** Selected Grouped ****** */