Keymap: Support shift-click to select multiple reports
authorCampbell Barton <ideasman42@gmail.com>
Fri, 26 Apr 2019 05:59:30 +0000 (15:59 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 26 Apr 2019 06:00:27 +0000 (16:00 +1000)
Also support drag for box-select, matching the outliner.

D4660 by @Poulpator with edits.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
source/blender/editors/space_info/info_report.c

index 694b1b00312a88a257919595d7e87bd41e4865ca..a0798ab60abcf1d2609ca00919c3561052436856 100644 (file)
@@ -1740,7 +1740,11 @@ def km_info(params):
     )
 
     items.extend([
-        ("info.select_pick", {"type": params.select_mouse, "value": 'PRESS'}, None),
+        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK'}, None),
+        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True},
+         {"properties": [("extend", True)]}),
+        ("info.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+         {"properties": [("wait_for_input", False)]}),
         *_template_items_select_actions(params, "info.select_all"),
         ("info.select_box", {"type": 'B', "value": 'PRESS'}, None),
         ("info.report_replay", {"type": 'R', "value": 'PRESS'}, None),
index b4209778609eb8958a00f23b40d4fec842fe31ca..287bdc4dff9cf7de516bce330eb98be27049204b 100644 (file)
@@ -1130,6 +1130,10 @@ def km_info(params):
 
     items.extend([
         ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
+        ("info.select_pick", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("extend", True)]}),
+        ("info.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'},
+         {"properties": [("wait_for_input", False)]}),
         ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, {"properties": [("action", 'SELECT')]}),
         ("info.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True, "shift": True}, None),
         ("info.select_all", {"type": 'I', "value": 'PRESS', "ctrl": True}, None),
index 1521a4007799674ba6714905e12b6cde5346f58a..f7499313a4ad293f56d01548e5f0d93725c4c316 100644 (file)
 
 #include "info_intern.h"
 
+static void reports_select_all(ReportList *reports, int report_mask, int action)
+{
+  if (action == SEL_TOGGLE) {
+    action = SEL_SELECT;
+    for (Report *report = reports->list.last; report; report = report->prev) {
+      if ((report->type & report_mask) && (report->flag & SELECT)) {
+        action = SEL_DESELECT;
+        break;
+      }
+    }
+  }
+
+  for (Report *report = reports->list.last; report; report = report->prev) {
+    if (report->type & report_mask) {
+      switch (action) {
+        case SEL_SELECT:
+          report->flag = SELECT;
+          break;
+        case SEL_DESELECT:
+          report->flag = ~SELECT;
+          break;
+        case SEL_INVERT:
+          report->flag ^= SELECT;
+          break;
+        default:
+          BLI_assert(0);
+      }
+    }
+  }
+}
+
 int info_report_mask(SpaceInfo *UNUSED(sinfo))
 {
 #if 0
@@ -112,12 +143,20 @@ void INFO_OT_report_replay(wmOperatorType *ot)
 static int select_report_pick_exec(bContext *C, wmOperator *op)
 {
   int report_index = RNA_int_get(op->ptr, "report_index");
+  bool extend = RNA_boolean_get(op->ptr, "extend");
+
   Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
 
+  SpaceInfo *sinfo = CTX_wm_space_info(C);
+  ReportList *reports = CTX_wm_reports(C);
+  const int report_mask = info_report_mask(sinfo);
   if (!report) {
     return OPERATOR_CANCELLED;
   }
 
+  if (!extend) {
+    reports_select_all(reports, report_mask, SEL_DESELECT);
+  }
   report->flag ^= SELECT; /* toggle */
 
   ED_area_tag_redraw(CTX_wm_area(C));
@@ -157,6 +196,7 @@ void INFO_OT_select_pick(wmOperatorType *ot)
   /* properties */
   RNA_def_int(
       ot->srna, "report_index", 0, 0, INT_MAX, "Report", "Index of the report", 0, INT_MAX);
+  RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend report selection");
 }
 
 static int report_select_all_exec(bContext *C, wmOperator *op)
@@ -166,34 +206,7 @@ static int report_select_all_exec(bContext *C, wmOperator *op)
   const int report_mask = info_report_mask(sinfo);
 
   int action = RNA_enum_get(op->ptr, "action");
-
-  if (action == SEL_TOGGLE) {
-    action = SEL_SELECT;
-    for (Report *report = reports->list.last; report; report = report->prev) {
-      if ((report->type & report_mask) && (report->flag & SELECT)) {
-        action = SEL_DESELECT;
-        break;
-      }
-    }
-  }
-
-  for (Report *report = reports->list.last; report; report = report->prev) {
-    if (report->type & report_mask) {
-      switch (action) {
-        case SEL_SELECT:
-          report->flag = SELECT;
-          break;
-        case SEL_DESELECT:
-          report->flag = ~SELECT;
-          break;
-        case SEL_INVERT:
-          report->flag ^= SELECT;
-          break;
-        default:
-          BLI_assert(0);
-      }
-    }
-  }
+  reports_select_all(reports, report_mask, action);
 
   ED_area_tag_redraw(CTX_wm_area(C));