[Bf-blender-cvs] [42c062c98a2] master: UI: File browser deselect on click on empty space

Julian Eisel noreply at git.blender.org
Tue Sep 10 18:40:55 CEST 2019


Commit: 42c062c98a2e8e48a63d909ec39ed7d6677a7504
Author: Julian Eisel
Date:   Tue Sep 10 18:36:05 2019 +0200
Branches: master
https://developer.blender.org/rB42c062c98a2e8e48a63d909ec39ed7d6677a7504

UI: File browser deselect on click on empty space

For the default and industry compatible keymap, clicking on empty space
in the file browser will deselect all files.

Also makes selection use same operator description we use for other
select operators.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M	source/blender/editors/space_file/file_ops.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 582757f2168..b9c8e73dab2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1819,7 +1819,7 @@ def km_file_browser_main(params):
          {"properties": [("need_active", True)]}),
         ("file.refresh", {"type": 'NUMPAD_PERIOD', "value": 'PRESS'}, None),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'},
-         {"properties": [("open", False)]}),
+         {"properties": [("open", False), ("deselect_all", not params.legacy)]}),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
          {"properties": [("extend", True)]}),
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index a963f461dd1..29a002b2754 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -1213,7 +1213,7 @@ def km_file_browser_main(params):
         ("file.refresh", {"type": 'R', "value": 'PRESS', "ctrl": True}, None),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK'},
-         {"properties": [("open", False)]}),
+         {"properties": [("open", False), ("deselect_all", True)]}),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True},
          {"properties": [("extend", True)]}),
         ("file.select", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True,},
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index c6061cb6f58..127196cca74 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -489,6 +489,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   const bool extend = RNA_boolean_get(op->ptr, "extend");
   const bool fill = RNA_boolean_get(op->ptr, "fill");
   const bool do_diropen = RNA_boolean_get(op->ptr, "open");
+  const bool deselect_all = RNA_boolean_get(op->ptr, "deselect_all");
 
   if (ar->regiontype != RGN_TYPE_WINDOW) {
     return OPERATOR_CANCELLED;
@@ -521,10 +522,15 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
     filelist_entry_parent_select_set(sfile->files, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
   }
 
-  if (FILE_SELECT_DIR == ret) {
+  if (ret == FILE_SELECT_NOTHING) {
+    if (deselect_all) {
+      file_deselect_all(sfile, FILE_SEL_SELECTED);
+    }
+  }
+  else if (ret == FILE_SELECT_DIR) {
     WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
   }
-  else if (FILE_SELECT_FILE == ret) {
+  else if (ret == FILE_SELECT_FILE) {
     WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
   }
 
@@ -540,8 +546,8 @@ void FILE_OT_select(wmOperatorType *ot)
 
   /* identifiers */
   ot->name = "Select";
-  ot->description = "Activate/select file";
   ot->idname = "FILE_OT_select";
+  ot->description = "Handle mouse clicks to select and activate items";
 
   /* api callbacks */
   ot->invoke = file_select_invoke;
@@ -559,6 +565,12 @@ void FILE_OT_select(wmOperatorType *ot)
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
   prop = RNA_def_boolean(ot->srna, "open", true, "Open", "Open a directory when selecting it");
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+  prop = RNA_def_boolean(ot->srna,
+                         "deselect_all",
+                         false,
+                         "Deselect On Nothing",
+                         "Deselect all when nothing under the cursor");
+  RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
 /**



More information about the Bf-blender-cvs mailing list