[Bf-blender-cvs] [07f938be389] soc-2019-outliner: Outliner: Finish walk select

Nathan Craddock noreply at git.blender.org
Wed Jun 5 07:16:03 CEST 2019


Commit: 07f938be3899e7bd8257f0e49dcad0b36548c251
Author: Nathan Craddock
Date:   Tue Jun 4 23:14:45 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB07f938be3899e7bd8257f0e49dcad0b36548c251

Outliner: Finish walk select

Adds walk in and out for walk select (left and right arrows)
If an element is closed, walk in will open the element. If
the element is open, left will close it. Otherwise left moves the
active element to the parent.

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

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 6594fe87d56..93a3c4f73c3 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1531,38 +1531,94 @@ void OUTLINER_OT_select_box(wmOperatorType *ot)
 
 /* **************** Walk Select Tool ****************** */
 
-static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *active, const int direction)
+static TreeElement *outliner_find_rightmost_child(SpaceOutliner *soops, TreeElement *te)
 {
-  TreeStoreElem *tselem = TREESTORE(active);
+  while (te->subtree.last) {
+    if (TSELEM_OPEN(TREESTORE(te), soops)) {
+      te = te->subtree.last;
+    }
+    else {
+      break;
+    }
+  }
+  return te;
+}
 
-  outliner_flag_set(&soops->tree, TSE_SELECTED, false);
-  tselem->flag &= ~TSE_ACTIVE;
+static TreeElement *do_outliner_select_walk_up(SpaceOutliner *soops, TreeElement *active)
+{
+  if (active->prev) {
+    TreeStoreElem *tselem = TREESTORE(active->prev);
 
-  if (direction == OUTLINER_SELECT_WALK_DOWN) {
     if (TSELEM_OPEN(tselem, soops)) {
-      active = active->subtree.first;
+      active = outliner_find_rightmost_child(soops, active->prev);
     }
-    else if (active->next) {
-      active = active->next;
-    }
-    else if (active->parent->next) {
-      active = active->parent->next;
+    else {
+      active = active->prev;
     }
   }
-  else if (direction == OUTLINER_SELECT_WALK_UP) {
-    if (active->prev) {
-      tselem = TREESTORE(active->prev);
-      if (TSELEM_OPEN(tselem, soops)) {
-        active = active->prev->subtree.first;
+  else if (active->parent) {
+    active = active->parent;
+  }
+  else {
+    active = outliner_find_rightmost_child(soops, active);
+  }
+
+  return active;
+}
+
+static TreeElement *do_outliner_select_walk_down(SpaceOutliner *soops, TreeElement *active)
+{
+  TreeStoreElem *tselem = TREESTORE(active);
+
+  if (TSELEM_OPEN(tselem, soops)) {
+    active = active->subtree.first;
+  }
+  else if (active->next) {
+    active = active->next;
+  }
+  else {
+    while (active->parent) {
+      if (active->parent->next) {
+        active = active->parent->next;
+        break;
       }
       else {
-        active = active->prev;
+        active = active->parent;
       }
     }
-    else if (active->parent) {
+  }
+
+  return active;
+}
+
+static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *active, const int direction)
+{
+  TreeStoreElem *tselem = TREESTORE(active);
+
+  outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+  tselem->flag &= ~TSE_ACTIVE;
+
+  if (direction == OUTLINER_SELECT_WALK_UP) {
+    active = do_outliner_select_walk_up(soops, active);
+  }
+  else if (direction == OUTLINER_SELECT_WALK_DOWN) {
+    active = do_outliner_select_walk_down(soops, active);
+  }
+  else if (direction == OUTLINER_SELECT_WALK_LEFT) {
+    if (TSELEM_OPEN(tselem, soops)) {
+      tselem->flag |= TSE_CLOSED;
+    }
+    else {
+      /* Jummp active to parent */
       active = active->parent;
     }
   }
+  else if (direction == OUTLINER_SELECT_WALK_RIGHT) {
+    if (!TSELEM_OPEN(tselem, soops) && active->subtree.first) {
+      printf("not open\n");
+      tselem->flag &= ~TSE_CLOSED;
+    }
+  }
 
   tselem = TREESTORE(active);
   tselem->flag |= TSE_SELECTED | TSE_ACTIVE;



More information about the Bf-blender-cvs mailing list