[Bf-blender-cvs] [5314161491d] master: VSE: Add option to select handles with box selection

Richard Antalik noreply at git.blender.org
Sun Feb 9 18:05:42 CET 2020


Commit: 5314161491d41461fe09c4774229481dde93e250
Author: Richard Antalik
Date:   Sun Feb 9 17:59:13 2020 +0100
Branches: master
https://developer.blender.org/rB5314161491d41461fe09c4774229481dde93e250

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

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_intern.h
M	source/blender/editors/space_sequencer/sequencer_select.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index d90aaceff60..e85c94ba5e6 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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'}),
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index ae1d63b5f93..6ebccf31355 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -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);
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h
index 0a51578da3b..ef5fed492e5 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -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);
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index a5bb66ca65f..bf06fa768ca 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -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 ****** */



More information about the Bf-blender-cvs mailing list