Select: support 'diselect on nothing' for masks.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 29 Apr 2019 09:33:50 +0000 (11:33 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 30 Apr 2019 09:34:22 +0000 (11:34 +0200)
Also moved that operator option from 3d-view op to generic
WM_operator_properties_mouse_select() helper, and renamed its label
(since 'Deselect' is already in use).

Part of T57918.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/editors/mask/mask_select.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/windowmanager/intern/wm_operator_props.c

index 97dd074..c398c76 100644 (file)
@@ -1251,7 +1251,8 @@ def km_mask_editing(params):
         ("mask.delete", {"type": 'X', "value": 'PRESS'}, None),
         ("mask.delete", {"type": 'DEL', "value": 'PRESS'}, None),
         ("mask.select", {"type": params.select_mouse, "value": params.select_mouse_value},
-         {"properties": [("extend", False), ("deselect", False), ("toggle", False)]}),
+         {"properties": [("extend", False), ("deselect", False), ("toggle", False),
+                         ("deselect_all", not params.legacy)]}),
         ("mask.select", {"type": params.select_mouse, "value": params.select_mouse_value, "shift": True},
          {"properties": [("extend", False), ("deselect", False), ("toggle", True)]}),
         *_template_items_select_actions(params, "mask.select_all"),
index 00699c8..a592f39 100644 (file)
@@ -262,6 +262,7 @@ static int select_exec(bContext *C, wmOperator *op)
   bool extend = RNA_boolean_get(op->ptr, "extend");
   bool deselect = RNA_boolean_get(op->ptr, "deselect");
   bool toggle = RNA_boolean_get(op->ptr, "toggle");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
   eMaskWhichHandle which_handle;
   const float threshold = 19;
 
@@ -366,6 +367,15 @@ static int select_exec(bContext *C, wmOperator *op)
 
       WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
 
+      return OPERATOR_FINISHED;
+    }
+    else if (deselect_all) {
+      ED_mask_select_toggle_all(mask, SEL_DESELECT);
+
+      ED_mask_select_flush_all(mask);
+
+      WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
+
       return OPERATOR_FINISHED;
     }
   }
index 443c7ab..bac24b8 100644 (file)
@@ -2251,9 +2251,6 @@ void VIEW3D_OT_select(wmOperatorType *ot)
 
   /* properties */
   WM_operator_properties_mouse_select(ot);
-  prop = RNA_def_boolean(
-      ot->srna, "deselect_all", 0, "Deselect", "Deselect all when nothing under the cursor");
-  RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 
   prop = RNA_def_boolean(
       ot->srna,
index 39594a6..5fbf82f 100644 (file)
@@ -449,6 +449,13 @@ void WM_operator_properties_mouse_select(wmOperatorType *ot)
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
   prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection");
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+  prop = RNA_def_boolean(ot->srna,
+                         "deselect_all",
+                         0,
+                         "Deselect On Nothing",
+                         "Deselect all when nothing under the cursor");
+  RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
 /**