[Bf-blender-cvs] [c91148c9662] soc-2019-outliner: Outliner: Fix range select when active element is not selected

Nathan Craddock noreply at git.blender.org
Sun Jun 30 06:43:31 CEST 2019


Commit: c91148c9662329b91b1bcddab3da69ab635c3c11
Author: Nathan Craddock
Date:   Sat Jun 29 22:42:04 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rBc91148c9662329b91b1bcddab3da69ab635c3c11

Outliner: Fix range select when active element is not selected

When the active element was not selected and range select
was used, it would become selected and the range select would
execute. A more intuitive behavior is to simply select the clicked
element.

Also optimized the outliner_is_element_visible utility function

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index a0c0b63246d..818424cc13f 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -466,7 +466,7 @@ bool outliner_tree_traverse(const SpaceOutliner *soops,
                             void *customdata);
 float outliner_restrict_columns_width(const struct SpaceOutliner *soops);
 TreeElement *outliner_find_active_element(const ListBase *lb);
-bool outliner_is_element_visible(const ListBase *lb, const TreeElement *te);
+bool outliner_is_element_visible(const TreeElement *te);
 
 /* outliner_sync.c ---------------------------------------------- */
 
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index c031a045ff5..cbcd58b89a4 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1278,16 +1278,18 @@ static void do_outliner_range_select_recursive(ListBase *lb,
 static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor)
 {
   TreeElement *active = outliner_find_active_element(&soops->tree);
-
-  outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+  TreeStoreElem *tselem = TREESTORE(active);
 
   /* Select element under cursor if active element not visible or if the cursor element is the
    * active element */
-  if (!outliner_is_element_visible(&soops->tree, active) || (active == cursor)) {
+  if (!(tselem->flag & TSE_SELECTED) || !outliner_is_element_visible(active) ||
+      (active == cursor)) {
     TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE;
     return;
   }
 
+  outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+
   bool selecting = false;
   do_outliner_range_select_recursive(&soops->tree, active, cursor, &selecting);
 }
@@ -1681,9 +1683,9 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
     active = soops->tree.first;
     TREESTORE(active)->flag |= TSE_SELECTED | TSE_ACTIVE;
   }
-  else if (!outliner_is_element_visible(&soops->tree, active)) {
+  else if (!outliner_is_element_visible(active)) {
     /* If active is not visible, set its first visble parent to active */
-    while (!outliner_is_element_visible(&soops->tree, active)) {
+    while (!outliner_is_element_visible(active)) {
       active = active->parent;
     }
 
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index de18ea03d1f..caf4fe4bfa9 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -316,21 +316,21 @@ TreeElement *outliner_find_active_element(const ListBase *lb)
   return NULL;
 }
 
-/* Find if element is visible in the outliner tree */
-bool outliner_is_element_visible(const ListBase *lb, const TreeElement *search_te)
+// /* Find if element is visible in the outliner tree */
+bool outliner_is_element_visible(const TreeElement *te)
 {
-  for (TreeElement *te = lb->first; te; te = te->next) {
-    if (te == search_te) {
-      return true;
-    }
+  TreeStoreElem *tselem;
 
-    /* Search the next layer if the element is open */
-    if (!(TREESTORE(te)->flag & TSE_CLOSED)) {
-      bool element = outliner_is_element_visible(&te->subtree, search_te);
-      if (element) {
-        return element;
-      }
+  while (te->parent) {
+    tselem = TREESTORE(te->parent);
+
+    if (tselem->flag & TSE_CLOSED) {
+      return false;
+    }
+    else {
+      te = te->parent;
     }
   }
-  return false;
+
+  return true;
 }



More information about the Bf-blender-cvs mailing list