[Bf-blender-cvs] [1986efe44de] soc-2019-outliner: Outliner: Search recursively for icons in row
Nathan Craddock
noreply at git.blender.org
Thu Jul 18 06:54:56 CEST 2019
Commit: 1986efe44de539cb2220d8720e84c68f8e076d5d
Author: Nathan Craddock
Date: Wed Jul 17 22:53:24 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB1986efe44de539cb2220d8720e84c68f8e076d5d
Outliner: Search recursively for icons in row
Rather than searching just the child list, search recursively
down the tree to allow clicking on all icons.
===================================================================
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_outliner/outliner_intern.h
M source/blender/editors/space_outliner/outliner_utils.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index b318d58a107..bcd8af26882 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2738,8 +2738,11 @@ static void outliner_draw_iconrow_doit(uiBlock *block,
if (num_elements > 1) {
outliner_draw_iconrow_number(fstyle, *offsx, ys, num_elements);
+ te->flag |= TE_ICONROW_MULTI;
+ }
+ else {
+ te->flag |= TE_ICONROW;
}
- te->flag |= TE_ICONROW;
(*offsx) += UI_UNIT_X;
}
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index fd0489c13cc..1f3541379b4 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -139,6 +139,7 @@ enum {
TE_DISABLED = (1 << 4),
TE_DRAGGING = (1 << 5),
TE_CHILD_NOT_IN_COLLECTION = (1 << 6),
+ TE_ICONROW_MULTI = (1 << 7),
};
/* button events */
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 50b1ef08cc9..c2dd9100dc4 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -62,6 +62,34 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
return NULL;
}
+static TreeElement *outliner_find_item_at_x_in_row_recursive(const TreeElement *parent_te,
+ float view_co_x)
+{
+ TreeElement *child_te = parent_te->subtree.first;
+
+ bool over_element = false;
+
+ while (child_te && view_co_x >= child_te->xs) {
+ over_element = (view_co_x > child_te->xs) && (view_co_x < child_te->xend);
+ if ((child_te->flag & TE_ICONROW) && over_element) {
+ return child_te;
+ }
+ else if ((child_te->flag & TE_ICONROW_MULTI) && over_element) {
+ return child_te;
+ }
+
+ TreeElement *te = outliner_find_item_at_x_in_row_recursive(child_te, view_co_x);
+ if (te != child_te) {
+ return te;
+ }
+
+ child_te = child_te->next;
+ }
+
+ /* return parent if no child is hovered */
+ return (TreeElement *)parent_te;
+}
+
/**
* Collapsed items can show their children as click-able icons. This function tries to find
* such an icon that represents the child item at x-coordinate \a view_co_x (view-space).
@@ -72,22 +100,11 @@ TreeElement *outliner_find_item_at_x_in_row(const SpaceOutliner *soops,
const TreeElement *parent_te,
float view_co_x)
{
- /* if parent_te is opened, it doesn't show childs in row */
+ /* if parent_te is opened, it doesn't show children in row */
if (!TSELEM_OPEN(TREESTORE(parent_te), soops)) {
- /* no recursion, items can only display their direct children in the row */
- for (TreeElement *child_te = parent_te->subtree.first;
- /* don't look further if co_x is smaller than child position*/
- child_te && view_co_x >= child_te->xs;
-
- child_te = child_te->next) {
- if ((child_te->flag & TE_ICONROW) && (view_co_x > child_te->xs) &&
- (view_co_x < child_te->xend)) {
- return child_te;
- }
- }
+ return outliner_find_item_at_x_in_row_recursive(parent_te, view_co_x);
}
- /* return parent if no child is hovered */
return (TreeElement *)parent_te;
}
More information about the Bf-blender-cvs
mailing list