[Bf-blender-cvs] [fb06b3fa01a] temp-soc-2019-outliner-sync: Outliner: Fix openclose behavior

Nathan Craddock noreply at git.blender.org
Fri Aug 16 19:30:15 CEST 2019


Commit: fb06b3fa01a7a30f33b7dc0339672e7a0bf140b9
Author: Nathan Craddock
Date:   Fri Aug 16 11:24:24 2019 -0600
Branches: temp-soc-2019-outliner-sync
https://developer.blender.org/rBfb06b3fa01a7a30f33b7dc0339672e7a0bf140b9

Outliner: Fix openclose behavior

Fixes click+drag on disclosure triangles not behaving as expected.
Now the dragged elements will be either closed or opened depending
on the state of the first clicked+dragged.

Also removed walk in and out for arrow left and right.

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

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

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

diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 1fe2b4f0fce..318d90d0dca 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -141,42 +141,25 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot)
 /* Toggle Open/Closed ------------------------------------------- */
 
 /* Open or close a tree element, optionally toggling all children recursively */
-bool outliner_item_openclose(TreeElement *te, bool toggle_all)
+void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all)
 {
   TreeStoreElem *tselem = TREESTORE(te);
 
-  if (toggle_all) {
-    /* Open all children if this element is closed, or if any children are closed */
-    const bool open = (tselem->flag & TSE_CLOSED) ||
-                      (outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1));
-
-    if (open) {
-      tselem->flag &= ~TSE_CLOSED;
-    }
-    else {
-      tselem->flag |= TSE_CLOSED;
-    }
-
-    outliner_flag_set(&te->subtree, TSE_CLOSED, !open);
-
-    return true;
+  if (open) {
+    tselem->flag &= ~TSE_CLOSED;
   }
   else {
-    if (tselem->flag & TSE_CLOSED) {
-      tselem->flag &= ~TSE_CLOSED;
-    }
-    else {
-      tselem->flag |= TSE_CLOSED;
-    }
-
-    return true;
+    tselem->flag |= TSE_CLOSED;
   }
 
-  return false;
+  if (toggle_all) {
+    outliner_flag_set(&te->subtree, TSE_CLOSED, !open);
+  }
 }
 
 typedef struct OpenCloseData {
   TreeStoreElem *prev_tselem;
+  bool open;
   int x_location;
 } OpenCloseData;
 
@@ -198,9 +181,8 @@ static int outliner_item_openclose_modal(bContext *C, wmOperator *op, const wmEv
 
       /* Only toggle openclose on the same level as the first clicked element */
       if (te->xs == data->x_location) {
-        if (outliner_item_openclose(te, false)) {
-          ED_region_tag_redraw(ar);
-        }
+        outliner_item_openclose(te, data->open, false);
+        ED_region_tag_redraw(ar);
       }
     }
 
@@ -233,7 +215,12 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE
   TreeElement *te = outliner_find_item_at_y(soops, &soops->tree, view_mval[1]);
 
   if (te && outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
-    outliner_item_openclose(te, toggle_all);
+    TreeStoreElem *tselem = TREESTORE(te);
+
+    const bool open = (tselem->flag & TSE_CLOSED) ||
+                      (toggle_all && (outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)));
+
+    outliner_item_openclose(te, open, toggle_all);
     ED_region_tag_redraw(ar);
 
     /* Only toggle once for single click toggling */
@@ -243,7 +230,8 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE
 
     /* Store last expanded tselem and x coordinate of disclosure triangle */
     OpenCloseData *toggle_data = MEM_callocN(sizeof(OpenCloseData), "open_close_data");
-    toggle_data->prev_tselem = TREESTORE(te);
+    toggle_data->prev_tselem = tselem;
+    toggle_data->open = open;
     toggle_data->x_location = te->xs;
 
     /* Store the first clicked on element */
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 2dc0276e9a3..e37f3519653 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -354,7 +354,7 @@ void item_object_mode_exit_cb(struct bContext *C,
 
 void outliner_set_coordinates(struct ARegion *ar, struct SpaceOutliner *soops);
 
-bool outliner_item_openclose(TreeElement *te, bool toggle_all);
+void outliner_item_openclose(TreeElement *te, bool open, bool toggle_all);
 
 /* outliner_dragdrop.c */
 void outliner_dropboxes(void);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index f96a78b1fc1..4575a9bc000 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1313,7 +1313,7 @@ static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *soops,
 }
 
 /**
- * A version of #outliner_item_do_acticate_from_cursor that takes the tree element directly.
+ * A version of #outliner_item_do_activate_from_cursor that takes the tree element directly.
  * and doesn't depend on the pointer position.
  *
  * This allows us to simulate clicking on an item without dealing with the mouse cursor.
@@ -1625,46 +1625,6 @@ static TreeElement *outliner_find_next_element(SpaceOutliner *soops, TreeElement
   return walk_element;
 }
 
-/* Walk the element left, or close the element */
-static TreeElement *outliner_walk_left(SpaceOutliner *soops,
-                                       TreeElement *walk_element,
-                                       TreeStoreElem *tselem,
-                                       bool toggle_all)
-{
-  if (TSELEM_OPEN(tselem, soops)) {
-    if (toggle_all) {
-      TREESTORE(walk_element)->flag |= TSE_CLOSED;
-      outliner_flag_set(&walk_element->subtree, TSE_CLOSED, true);
-    }
-    else {
-      outliner_item_openclose(walk_element, false);
-    }
-  }
-  else if (!toggle_all && walk_element->parent) {
-    return walk_element->parent;
-  }
-
-  return walk_element;
-}
-
-/* Walk the element right or expand the element */
-static TreeElement *outliner_walk_right(SpaceOutliner *soops,
-                                        TreeElement *walk_element,
-                                        TreeStoreElem *tselem,
-                                        bool toggle_all)
-{
-  if (!toggle_all && TSELEM_OPEN(tselem, soops)) {
-    return walk_element->subtree.first;
-  }
-  else if ((!TSELEM_OPEN(tselem, soops) ||
-            outliner_flag_is_any_test(&walk_element->subtree, TSE_CLOSED, 1)) &&
-           walk_element->subtree.first) {
-    outliner_item_openclose(walk_element, toggle_all);
-  }
-
-  return walk_element;
-}
-
 static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
                                             TreeElement *walk_element,
                                             const int direction,
@@ -1686,11 +1646,10 @@ static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
       walk_element = outliner_find_next_element(soops, walk_element);
       break;
     case OUTLINER_SELECT_WALK_LEFT:
-      /* Close open element or walk to parent */
-      walk_element = outliner_walk_left(soops, walk_element, tselem, toggle_all);
+      outliner_item_openclose(walk_element, false, toggle_all);
       break;
     case OUTLINER_SELECT_WALK_RIGHT:
-      walk_element = outliner_walk_right(soops, walk_element, tselem, toggle_all);
+      outliner_item_openclose(walk_element, true, toggle_all);
       break;
   }



More information about the Bf-blender-cvs mailing list