[Bf-blender-cvs] [490d4440977] soc-2020-outliner: Outliner: Add walk navigation left and right

Nathan Craddock noreply at git.blender.org
Thu Jun 11 05:55:16 CEST 2020


Commit: 490d44409770767d5c8394f17bb34cae474009de
Author: Nathan Craddock
Date:   Wed Jun 10 21:36:58 2020 -0600
Branches: soc-2020-outliner
https://developer.blender.org/rB490d44409770767d5c8394f17bb34cae474009de

Outliner: Add walk navigation left and right

Support walk navigation up and down the tree by pressing the left and
right arrows. When holding shift (to toggle expand/collapse on all
children) walking is never done.

When walking right, open the tree if it is closed, or walk into the tree
if it is opened. When walking left, close the tree if it is open, or
select the parent element when closed.

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

M	source/blender/editors/space_outliner/outliner_select.c

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

diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index f1a5373574c..f7c567fe559 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1707,6 +1707,40 @@ static TreeElement *outliner_find_next_element(SpaceOutliner *soops, TreeElement
   return walk_element;
 }
 
+static TreeElement *outliner_walk_left(SpaceOutliner *soops,
+                                       TreeElement *walk_element,
+                                       bool toggle_all)
+{
+  TreeStoreElem *tselem = TREESTORE(walk_element);
+
+  if (TSELEM_OPEN(tselem, soops)) {
+    outliner_item_openclose(walk_element, false, toggle_all);
+  }
+  /* Only walk up a level if the element is closed and not toggling expand */
+  else if (!toggle_all && walk_element->parent) {
+    walk_element = walk_element->parent;
+  }
+
+  return walk_element;
+}
+
+static TreeElement *outliner_walk_right(SpaceOutliner *soops,
+                                        TreeElement *walk_element,
+                                        bool toggle_all)
+{
+  TreeStoreElem *tselem = TREESTORE(walk_element);
+
+  /* Only walk down a level if the element is open and not toggling expand */
+  if (!toggle_all && TSELEM_OPEN(tselem, soops) && walk_element->subtree.first) {
+    walk_element = walk_element->subtree.first;
+  }
+  else {
+    outliner_item_openclose(walk_element, true, toggle_all);
+  }
+
+  return walk_element;
+}
+
 static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
                                             TreeElement *walk_element,
                                             const int direction,
@@ -1728,10 +1762,10 @@ static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
       walk_element = outliner_find_next_element(soops, walk_element);
       break;
     case UI_SELECT_WALK_LEFT:
-      outliner_item_openclose(walk_element, false, toggle_all);
+      walk_element = outliner_walk_left(soops, walk_element, toggle_all);
       break;
     case UI_SELECT_WALK_RIGHT:
-      outliner_item_openclose(walk_element, true, toggle_all);
+      walk_element = outliner_walk_right(soops, walk_element, toggle_all);
       break;
   }



More information about the Bf-blender-cvs mailing list