From ff50a53d6911cba730ca42d95c734ab443d62608 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 9 Mar 2022 15:14:57 +0100 Subject: Cleanup: Deduplicate Outliner item culling logic For whatever reason the "in-view" check was using 2x the element height. From what I can see this isn't needed, so I'll remove it in a follow-up commit. --- source/blender/editors/space_outliner/outliner_draw.cc | 7 +++---- source/blender/editors/space_outliner/outliner_intern.hh | 9 ++++++++- source/blender/editors/space_outliner/outliner_utils.cc | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 04d4da5e62f..7b62b28abc5 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1721,7 +1721,7 @@ static void outliner_draw_userbuts(uiBlock *block, LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); - if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { + if (outliner_is_element_in_view(te, ®ion->v2d)) { if (tselem->type == TSE_SOME_ID) { uiBut *bt; ID *id = tselem->id; @@ -1792,8 +1792,7 @@ static bool outliner_draw_overrides_buts(uiBlock *block, LISTBASE_FOREACH (TreeElement *, te, lb) { bool item_has_warnings = false; - const bool do_draw = (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && - te->ys <= region->v2d.cur.ymax); + const bool do_draw = outliner_is_element_in_view(te, ®ion->v2d); int but_flag = UI_BUT_DRAG_LOCK; const char *tip = nullptr; @@ -1903,7 +1902,7 @@ static void outliner_draw_rnabuts( LISTBASE_FOREACH (TreeElement *, te, lb) { TreeStoreElem *tselem = TREESTORE(te); - if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) { + if (outliner_is_element_in_view(te, ®ion->v2d)) { if (TreeElementRNAProperty *te_rna_prop = tree_element_cast(te)) { ptr = te_rna_prop->getPointerRNA(); prop = te_rna_prop->getPropertyRNA(); diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index 7a45531c608..b9ffea7c735 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -33,6 +33,7 @@ struct ViewLayer; struct bContext; struct bContextDataResult; struct bPoseChannel; +struct View2D; struct wmKeyConfig; struct wmOperatorType; @@ -642,9 +643,15 @@ float outliner_restrict_columns_width(const struct SpaceOutliner *space_outliner */ TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag); /** - * Find if element is visible in the outliner tree. + * Find if element is visible in the outliner tree, i.e. if all of its parents are expanded. + * Doesn't check if the item is in view-bounds, for that use #outliner_is_element_in_view(). */ bool outliner_is_element_visible(const TreeElement *te); +/** + * Check if the element is displayed within the view bounds. Doesn't check if all parents are + * open/uncollapsed. + */ +bool outliner_is_element_in_view(const TreeElement *te, const struct View2D *v2d); /** * Scroll view vertically while keeping within total bounds. */ diff --git a/source/blender/editors/space_outliner/outliner_utils.cc b/source/blender/editors/space_outliner/outliner_utils.cc index b49a2416b38..15a7a3bec15 100644 --- a/source/blender/editors/space_outliner/outliner_utils.cc +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -386,6 +386,11 @@ bool outliner_is_element_visible(const TreeElement *te) return true; } +bool outliner_is_element_in_view(const TreeElement *te, const View2D *v2d) +{ + return ((te->ys + 2 * UI_UNIT_Y) >= v2d->cur.ymin) && (te->ys <= v2d->cur.ymax); +} + bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x) { /* Special case: count area left of Scene Collection as empty space */ -- cgit v1.2.3