[Bf-blender-cvs] [ab4654cdfe8] master: Cleanup: Move logic to `outliner_find_item_at_x_in_row`

Nathan Craddock noreply at git.blender.org
Fri Nov 27 04:48:37 CET 2020


Commit: ab4654cdfe8f393d70426456a29c3ae0bfc4ac03
Author: Nathan Craddock
Date:   Thu Nov 26 13:30:31 2020 -0700
Branches: master
https://developer.blender.org/rBab4654cdfe8f393d70426456a29c3ae0bfc4ac03

Cleanup: Move logic to `outliner_find_item_at_x_in_row`

Move the logic for determining if the item at a given x position is an
icon into the function. This is used for determining selection over an
icon, and will be used in a later commit for checking for hover over an
icon. No functional changes.

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

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
M	source/blender/editors/space_outliner/outliner_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 8de7c233728..bf94e9e04a4 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -117,8 +117,10 @@ static int outliner_highlight_update(bContext *C, wmOperator *UNUSED(op), const
   TreeElement *hovered_te = outliner_find_item_at_y(
       space_outliner, &space_outliner->tree, view_mval[1]);
 
+  bool is_over_icon;
   if (hovered_te) {
-    hovered_te = outliner_find_item_at_x_in_row(space_outliner, hovered_te, view_mval[0], NULL);
+    hovered_te = outliner_find_item_at_x_in_row(
+        space_outliner, hovered_te, view_mval[0], NULL, &is_over_icon);
   }
   bool changed = false;
 
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 5bcb7af1a17..40e83291322 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -515,9 +515,10 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *space_outliner,
                                      const ListBase *tree,
                                      float view_co_y);
 TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *space_outliner,
-                                            const TreeElement *parent_te,
+                                            TreeElement *parent_te,
                                             float view_co_x,
-                                            bool *row_merged);
+                                            bool *row_merged,
+                                            bool *r_is_over_icon);
 TreeElement *outliner_find_tse(struct SpaceOutliner *space_outliner, const TreeStoreElem *tse);
 TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem);
 TreeElement *outliner_find_parent_element(ListBase *lb,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 0cd5e62e6f6..fa8bce9df6a 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1563,11 +1563,9 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
   else {
     /* The row may also contain children, if one is hovered we want this instead of current te. */
     bool merged_elements = false;
+    bool is_over_icon = false;
     TreeElement *activate_te = outliner_find_item_at_x_in_row(
-        space_outliner, te, view_mval[0], &merged_elements);
-
-    /* If `outliner_find_item_at_x_in_row` returned a different element a row icon was selected. */
-    const bool is_row_icon = te != activate_te;
+        space_outliner, te, view_mval[0], &merged_elements, &is_over_icon);
 
     /* If the selected icon was an aggregate of multiple elements, run the search popup */
     if (merged_elements) {
@@ -1594,7 +1592,7 @@ static int outliner_item_do_activate_from_cursor(bContext *C,
       outliner_item_select(C, space_outliner, activate_te, select_flag);
 
       /* Only switch properties editor tabs when icons are selected. */
-      if (is_row_icon || outliner_item_is_co_over_icon(activate_te, view_mval[0])) {
+      if (is_over_icon) {
         outliner_set_properties_tab(C, activate_te, activate_tselem);
       }
     }
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 79f696e1511..f3f2c93e7a0 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -150,16 +150,22 @@ static TreeElement *outliner_find_item_at_x_in_row_recursive(const TreeElement *
  * \return a hovered child item or \a parent_te (if no hovered child found).
  */
 TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *space_outliner,
-                                            const TreeElement *parent_te,
+                                            TreeElement *parent_te,
                                             float view_co_x,
-                                            bool *row_merged)
+                                            bool *row_merged,
+                                            bool *r_is_over_icon)
 {
   /* if parent_te is opened, it doesn't show children in row */
+  TreeElement *te = parent_te;
   if (!TSELEM_OPEN(TREESTORE(parent_te), space_outliner)) {
-    return outliner_find_item_at_x_in_row_recursive(parent_te, view_co_x, row_merged);
+    te = outliner_find_item_at_x_in_row_recursive(parent_te, view_co_x, row_merged);
   }
 
-  return (TreeElement *)parent_te;
+  if ((te != parent_te) || outliner_item_is_co_over_icon(parent_te, view_co_x)) {
+    *r_is_over_icon = true;
+  }
+
+  return te;
 }
 
 /* Find specific item from the treestore */



More information about the Bf-blender-cvs mailing list