From be6b147d169f2cd63ef25b60647673d2ce849301 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 29 Sep 2025 12:52:09 +0200 Subject: [PATCH] Outliner: allow "Show Active" to center/scroll in Data API view Unlike other Outliner views, this will not open up elements to find objects "underneath" (since Data API view lazy loads elements iirc), but given that you already have that object visible somewhere in the DataAPI view (so e.g. Objects expanded) we could actually do the centering/ scrolling by getting an ID from the `TreeElement` (in case of an `TSE_RNA_STRUCT`). This came up in #145904 Pull Request: https://projects.blender.org/blender/blender/pulls/145920 --- .../editors/space_outliner/outliner_utils.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/editors/space_outliner/outliner_utils.cc b/source/blender/editors/space_outliner/outliner_utils.cc index 4a1ce077ee3..8833d66f4de 100644 --- a/source/blender/editors/space_outliner/outliner_utils.cc +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -31,6 +31,7 @@ #include "outliner_intern.hh" #include "tree/tree_display.hh" +#include "tree/tree_element_rna.hh" namespace blender::ed::outliner { @@ -195,6 +196,19 @@ TreeElement *outliner_find_id(SpaceOutliner *space_outliner, ListBase *lb, const return te; } } + else if (tselem->type == TSE_RNA_STRUCT) { + /* No ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock we are + * good. */ + const TreeElementRNAStruct *te_rna_struct = tree_element_cast(te); + if (te_rna_struct) { + const PointerRNA &ptr = te_rna_struct->get_pointer_rna(); + if (RNA_struct_is_ID(ptr.type)) { + if (static_cast(ptr.data) == id) { + return te; + } + } + } + } TreeElement *tes = outliner_find_id(space_outliner, &te->subtree, id); if (tes) {