[Bf-blender-cvs] [155cb8505c1] soc-2019-outliner: Outliner: Click and drag to box select

Nathan Craddock noreply at git.blender.org
Fri May 31 06:57:58 CEST 2019


Commit: 155cb8505c12db6d9b010017c1578906769a4eb2
Author: Nathan Craddock
Date:   Thu May 30 22:53:52 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB155cb8505c12db6d9b010017c1578906769a4eb2

Outliner: Click and drag to box select

Allows tweak event for box selection from the left gutter of the outliner.
If the gutter is clicked, everything is deselected

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

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

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7f08c635778..f50f91207eb 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -692,8 +692,8 @@ def km_outliner(params):
          {"properties": [("extend", False), ("range", False), ("recursive", True)]}),
         ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "alt": True},
          {"properties": [("extend", True), ("range", False), ("recursive", True)]}),
-        # ("outliner.select_range", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, None),
-        ("outliner.select_box", {"type": 'B', "value": 'PRESS'}, None),
+        ("outliner.select_box", {"type": 'B', "value": 'PRESS'}, {"properties": [("tweak", False)]}),
+        ("outliner.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, {"properties": [("tweak", True)]}),
         ("outliner.item_openclose", {"type": 'RET', "value": 'PRESS'},
          {"properties": [("all", False)]}),
         ("outliner.item_openclose", {"type": 'RET', "value": 'PRESS', "shift": True},
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 235c0374d35..21fe27afe62 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1342,7 +1342,8 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
     return OPERATOR_CANCELLED;
   }
 
-  if (!(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
+  if (view_mval[0] < UI_UNIT_X ||
+      !(te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]))) {
     if (deselect_all) {
       outliner_flag_set(&soops->tree, TSE_SELECTED, false);
       changed = true;
@@ -1462,6 +1463,12 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op)
   WM_operator_properties_border_to_rctf(op, &rectf);
   UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf);
 
+  /* Ensure one item is active (remove when sync selection) */
+  if (!outliner_find_active_element(&soops->tree)) {
+    TreeElement *te = soops->tree.first;
+    TREESTORE(te)->flag |= TSE_ACTIVE;
+  }
+
   for (TreeElement *te = soops->tree.first; te; te = te->next) {
     outliner_item_box_select(soops, scene, &rectf, te, select);
   }
@@ -1473,6 +1480,22 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+static int outliner_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+  ARegion *ar = CTX_wm_region(C);
+  float view_mval[2];
+  const bool tweak = RNA_boolean_get(op->ptr, "tweak");
+
+  UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &view_mval[0], &view_mval[1]);
+
+  /* Pass through if click is outside of left gutter */
+  if (tweak && view_mval[0] > UI_UNIT_X) {
+    return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
+  }
+
+  return WM_gesture_box_invoke(C, op, event);
+}
+
 void OUTLINER_OT_select_box(wmOperatorType *ot)
 {
   /* identifiers */
@@ -1481,7 +1504,7 @@ void OUTLINER_OT_select_box(wmOperatorType *ot)
   ot->description = "Use box selection to select tree elements";
 
   /* api callbacks */
-  ot->invoke = WM_gesture_box_invoke;
+  ot->invoke = outliner_box_select_invoke;
   ot->exec = outliner_box_select_exec;
   ot->modal = WM_gesture_box_modal;
   ot->cancel = WM_gesture_box_cancel;
@@ -1492,6 +1515,8 @@ void OUTLINER_OT_select_box(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   /* properties */
+  RNA_def_boolean(
+      ot->srna, "tweak", true, "Tweak", "Click and drag from the gutter for box selection");
   WM_operator_properties_gesture_box(ot);
   WM_operator_properties_select_operation_simple(ot);
 }



More information about the Bf-blender-cvs mailing list