[Bf-blender-cvs] [fc0ac4c0320] soc-2020-greasepencil-curve: GPencil: Selection and toggle selection of handles

Falk David noreply at git.blender.org
Thu Jun 18 00:10:40 CEST 2020


Commit: fc0ac4c0320bb1662739e215a15fa0594ab510e0
Author: Falk David
Date:   Wed Jun 17 23:43:21 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rBfc0ac4c0320bb1662739e215a15fa0594ab510e0

GPencil: Selection and toggle selection of handles

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

M	source/blender/editors/gpencil/gpencil_select.c
M	source/blender/makesdna/DNA_curve_types.h

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

diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 765c2969ac4..6accc06d175 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1683,6 +1683,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
   bGPDspoint *hit_point = NULL;
   bGPDcurve *hit_curve = NULL;
   bGPDcurve_point *hit_curve_point = NULL;
+  char hit_curve_handle = 0;
   int hit_distance = radius_squared;
 
   /* sanity checks */
@@ -1705,8 +1706,8 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
   }
 
   if (is_curve_edit) {
-    char handle = 0;
-    gpencil_select_curve_point(C, mval, radius_squared, &hit_curve, &hit_curve_point, &handle);
+    gpencil_select_curve_point(
+        C, mval, radius_squared, &hit_curve, &hit_curve_point, &hit_curve_handle);
   }
 
   if (hit_curve_point == NULL) {
@@ -1800,7 +1801,13 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
   /* adjust selection behavior - for toggle option */
   if (toggle) {
     if (hit_curve_point != NULL) {
-      deselect = (hit_curve_point->flag & GP_CURVE_POINT_SELECT) != 0;
+      BezTriple *bezt = &hit_curve_point->bezt;
+      if (bezt->f1 & SELECT && hit_curve_handle == 0)
+        deselect = true;
+      if (bezt->f2 & SELECT && hit_curve_handle == 1)
+        deselect = true;
+      if (bezt->f3 & SELECT && hit_curve_handle == 2)
+        deselect = true;
     }
     else {
       deselect = (hit_point->flag & GP_SPOINT_SELECT) != 0;
@@ -1864,7 +1871,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
     if (deselect == false) {
       if (hit_curve_point != NULL) {
         hit_curve_point->flag |= GP_CURVE_POINT_SELECT;
-        BEZT_SEL_ALL(&hit_curve_point->bezt);
+        BEZT_SEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
         hit_curve->flag |= GP_CURVE_SELECT;
       }
       else {
@@ -1894,8 +1901,10 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
     }
     else {
       if (hit_curve_point != NULL) {
-        hit_curve_point->flag &= ~GP_CURVE_POINT_SELECT;
-        BEZT_DESEL_ALL(&hit_curve_point->bezt);
+        BEZT_DESEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
+        if (!BEZT_ISSEL_ANY(&hit_curve_point->bezt)) {
+          hit_curve_point->flag &= ~GP_CURVE_POINT_SELECT;
+        }
         BKE_gpencil_curve_sync_selection(hit_curve);
       }
       else {
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 72a8adeff85..84d733761c3 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -526,6 +526,42 @@ typedef enum eBezTriple_KeyframeType {
   } \
   ((void)0)
 
+#define BEZT_SEL_IDX(bezt, i) \
+  { \
+    switch (i) { \
+      case 0: \
+        (bezt)->f1 |= SELECT; \
+        break; \
+      case 1: \
+        (bezt)->f2 |= SELECT; \
+        break; \
+      case 2: \
+        (bezt)->f3 |= SELECT; \
+        break; \
+      default: \
+        break; \
+    } \
+  } \
+  ((void)0)
+
+#define BEZT_DESEL_IDX(bezt, i) \
+  { \
+    switch (i) { \
+      case 0: \
+        (bezt)->f1 &= ~SELECT; \
+        break; \
+      case 1: \
+        (bezt)->f2 &= ~SELECT; \
+        break; \
+      case 2: \
+        (bezt)->f3 &= ~SELECT; \
+        break; \
+      default: \
+        break; \
+    } \
+  } \
+  ((void)0)
+
 #define BEZT_IS_AUTOH(bezt) \
   (ELEM((bezt)->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM((bezt)->h2, HD_AUTO, HD_AUTO_ANIM))



More information about the Bf-blender-cvs mailing list