Select: proper handling of 'deselect on nothing' for GPencil edit mode.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 29 Apr 2019 09:56:54 +0000 (11:56 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 30 Apr 2019 09:34:22 +0000 (11:34 +0200)
Was unconditionnaly behaving that way, now use proper common setting to
control whether we should deselect everything when clicking on an empty
area.

Part of T57918.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/editors/gpencil/gpencil_select.c

index c398c76..5fd86d4 100644 (file)
@@ -3027,7 +3027,8 @@ def km_grease_pencil_stroke_edit_mode(params):
         ("gpencil.interpolate", {"type": 'E', "value": 'PRESS', "ctrl": True, "alt": True}, None),
         ("gpencil.interpolate_sequence", {"type": 'E', "value": 'PRESS', "shift": True, "ctrl": True}, None),
         # Normal select
-        ("gpencil.select", {"type": params.select_mouse, "value": params.select_mouse_value}, None),
+        ("gpencil.select", {"type": params.select_mouse, "value": params.select_mouse_value},
+         {"properties": [("deselect_all", not params.legacy)]}),
         # Selection
         *_grease_pencil_selection(params),
         # Duplicate and move selected points
index b854035..ba80602 100644 (file)
@@ -1298,6 +1298,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
   bool deselect = RNA_boolean_get(op->ptr, "deselect");
   bool toggle = RNA_boolean_get(op->ptr, "toggle");
   bool whole = RNA_boolean_get(op->ptr, "entire_strokes");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
 
   int mval[2] = {0};
 
@@ -1360,15 +1361,18 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
 
   /* Abort if nothing hit... */
   if (ELEM(NULL, hit_stroke, hit_point)) {
+    if (deselect_all) {
+      /* since left mouse select change, deselect all if click outside any hit */
+      deselect_all_selected(C);
 
-    /* since left mouse select change, deselect all if click outside any hit */
-    deselect_all_selected(C);
+      /* copy on write tag is needed, or else no refresh happens */
+      DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
+      DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
+      WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
+      WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
 
-    /* copy on write tag is needed, or else no refresh happens */
-    DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
-    DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
-    WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL);
-    WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+      return OPERATOR_FINISHED;
+    }
 
     return OPERATOR_CANCELLED;
   }