Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-03-09 17:14:57 +0300
committerFabian Schempp <fabianschempp@googlemail.com>2022-04-11 01:30:37 +0300
commitff50a53d6911cba730ca42d95c734ab443d62608 (patch)
treee7ca73cafc8aecc3177ea7af0e2eb2aab71deac4 /source/blender/editors/space_outliner
parente4557d589c3eeb7f45babee842b6bd07aef8cd6a (diff)
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.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.cc7
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.hh9
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.cc5
3 files changed, 16 insertions, 5 deletions
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, &region->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, &region->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, &region->v2d)) {
if (TreeElementRNAProperty *te_rna_prop = tree_element_cast<TreeElementRNAProperty>(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,10 +643,16 @@ 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.
*/
void outliner_scroll_view(struct SpaceOutliner *space_outliner,
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 */