[Bf-blender-cvs] [c68dff9ff71] soc-2019-outliner: Outliner: Add extend selection to walk select

Nathan Craddock noreply at git.blender.org
Fri Jun 28 01:51:49 CEST 2019


Commit: c68dff9ff71ca5a8b330309b09854b90fab798cb
Author: Nathan Craddock
Date:   Thu Jun 27 17:50:21 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBc68dff9ff71ca5a8b330309b09854b90fab798cb

Outliner: Add extend selection to walk select

Walk select now extends the selection when shift is pressed.
This implementation works well, though if there are existing
selections in the tree the behavior may not work as expected.
This could be improved on in the future if that is a problem.

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

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 6b02d4a4564..128f97fed1b 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -715,7 +715,11 @@ def km_outliner(params):
         ("outliner.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "ctrl": True},
          {"properties": [("tweak", True), ("mode", "SUB")]}),
         ("outliner.select_walk", {"type": 'UP_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'UP')]}),
+        ("outliner.select_walk", {"type": 'UP_ARROW', "value": 'PRESS', "shift": True},
+         {"properties": [("direction", 'UP'), ("extend", True)]}),
         ("outliner.select_walk", {"type": 'DOWN_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'DOWN')]}),
+        ("outliner.select_walk", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True},
+         {"properties": [("direction", 'DOWN'), ("extend", True)]}),
         ("outliner.select_walk", {"type": 'LEFT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'LEFT')]}),
         ("outliner.select_walk", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'RIGHT')]}),
         ("outliner.item_openclose", {"type": 'RET', "value": 'PRESS'},
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 048a915a10b..29e5ba92cf7 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1634,11 +1634,16 @@ static TreeElement *do_outliner_select_walk_down(SpaceOutliner *soops, TreeEleme
   return active;
 }
 
-static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *active, const int direction)
+static void do_outliner_select_walk(SpaceOutliner *soops,
+                                    TreeElement *active,
+                                    const int direction,
+                                    const bool extend)
 {
   TreeStoreElem *tselem = TREESTORE(active);
 
-  outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+  if (!extend) {
+    outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+  }
   tselem->flag &= ~TSE_ACTIVE;
 
   switch (direction) {
@@ -1663,9 +1668,15 @@ static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *active, c
       }
       break;
   }
+  TreeStoreElem *tselem_new = TREESTORE(active);
+
+  if (extend) {
+    const short new_flag = (extend && (tselem_new->flag & TSE_SELECTED)) ? 0 : TSE_SELECTED;
+    tselem->flag &= ~(TSE_ACTIVE | TSE_SELECTED);
+    tselem->flag |= new_flag;
+  }
 
-  tselem = TREESTORE(active);
-  tselem->flag |= TSE_SELECTED | TSE_ACTIVE;
+  tselem_new->flag |= TSE_SELECTED | TSE_ACTIVE;
 }
 
 static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -1673,6 +1684,7 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
   SpaceOutliner *soops = CTX_wm_space_outliner(C);
   ARegion *ar = CTX_wm_region(C);
   const int direction = RNA_enum_get(op->ptr, "direction");
+  const bool extend = RNA_boolean_get(op->ptr, "extend");
 
   TreeElement *active = outliner_find_active_element(&soops->tree);
 
@@ -1698,7 +1710,7 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
       tselem->flag |= TSE_SELECTED;
     }
     else {
-      do_outliner_select_walk(soops, active, direction);
+      do_outliner_select_walk(soops, active, direction, extend);
     }
   }
 
@@ -1738,6 +1750,8 @@ void OUTLINER_OT_select_walk(wmOperatorType *ot)
                       "Walk Direction",
                       "Select file in this direction");
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+  prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection on walk");
+  RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
 /* ****************************************************** */



More information about the Bf-blender-cvs mailing list