Select: add 'select on nothing' to Outliner.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 29 Apr 2019 13:09:31 +0000 (15:09 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 30 Apr 2019 09:34:22 +0000 (11:34 +0200)
Althought this has limited usability currently (only 'nothing' area in
Outliner are empty lines below last entries), better for consistency to
have it here too.

Part of T63995.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/editors/space_outliner/outliner_select.c

index 5c18d57..9885ece 100644 (file)
@@ -713,7 +713,7 @@ def km_outliner(params):
         ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None),
         ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
-         {"properties": [("extend", False), ("recursive", False)]}),
+         {"properties": [("extend", False), ("recursive", False), ("deselect_all", not params.legacy)]}),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
          {"properties": [("extend", True), ("recursive", False)]}),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
index 6cc1475..6c1a84a 100644 (file)
@@ -1299,8 +1299,9 @@ void outliner_item_do_activate_from_tree_element(
  * */
 static int outliner_item_do_activate_from_cursor(bContext *C,
                                                  const int mval[2],
-                                                 bool extend,
-                                                 bool recursive)
+                                                 const bool extend,
+                                                 const bool recursive,
+                                                 const bool deselect_all)
 {
   ARegion *ar = CTX_wm_region(C);
   SpaceOutliner *soops = CTX_wm_space_outliner(C);
@@ -1315,7 +1316,10 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
   }
 
   if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
-    /* skip */
+    if (deselect_all) {
+      outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+      changed = true;
+    }
   }
   else if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
     outliner_item_toggle_closed(te, extend);
@@ -1351,9 +1355,10 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
 /* event can enterkey, then it opens/closes */
 static int outliner_item_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
-  bool extend = RNA_boolean_get(op->ptr, "extend");
-  bool recursive = RNA_boolean_get(op->ptr, "recursive");
-  return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive);
+  const bool extend = RNA_boolean_get(op->ptr, "extend");
+  const bool recursive = RNA_boolean_get(op->ptr, "recursive");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
+  return outliner_item_do_activate_from_cursor(C, event->mval, extend, recursive, deselect_all);
 }
 
 void OUTLINER_OT_item_activate(wmOperatorType *ot)
@@ -1368,6 +1373,11 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot)
 
   RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation");
   RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children");
+  RNA_def_boolean(ot->srna,
+                  "deselect_all",
+                  false,
+                  "Deselect On Nothing",
+                  "Deselect all when nothing under the cursor");
 }
 
 /* ****************************************************** */