81 if (tselem->
id ==
nullptr) {
121 if (space_outliner->
treestore ==
nullptr) {
127 space_outliner->
runtime->
tree_hash = treehash::TreeHash::create_from_treestore(
143 tselem->
nr = type ? nr : 0;
180 element->abstract_element =
nullptr;
206 [&](
TreeElement &legacy_te) -> std::unique_ptr<AbstractTreeElement> {
210 "Expected this ID type to be ported to new Outliner tree-element design");
218 const void *persistent_ptr,
219 const bool allow_null_identity,
222 ListBaseT<TreeElement> *lb = params.
lb ? params.
lb :
224 BLI_assert_msg(lb !=
nullptr,
"Either a sub-tree or a parent to add the element to is required");
230 ID *persistent_dataptr = owner_id ? owner_id :
231 static_cast<ID *
>(
const_cast<void *
>(persistent_ptr));
232 if (persistent_dataptr ==
nullptr && !allow_null_identity) {
280 ListBaseT<TreeElement> *tree,
285 tree_display.
add_id_element({.lb = tree, .parent = parent},
reinterpret_cast<ID *
>(cob.
ob));
346 if (a_is_ob && b_is_ob) {
364 const bool is_parented_object)
369 {collection, ob},
nullptr);
370 if (cob ==
nullptr) {
382 if (child_col !=
nullptr) {
399 const bool is_parented_object)
404 if (!x1_valid || !x2_valid) {
409 x1, sort_maps, collection_child_map, collection, is_parented_object);
411 x2, sort_maps, collection_child_map, collection, is_parented_object);
412 if (x1_sort_index == x2_sort_index) {
416 return x1_sort_index < x2_sort_index;
421static int treesort_obtype_alpha(
const void *v1,
const void *
v2)
438 else if (((Object *)x1->
id)->type > ((Object *)x2->id)->type) {
475 if (last_te ==
nullptr) {
483 const bool inside_armature_data =
ELEM(
485 const bool has_armature_data_bone_collections =
ELEM(last_tselem->
type,
492 int totelem = lb->count();
517 const int skip_back = has_armature_data_bone_collections ? 1 : 0;
523 for (tp = tear, skip_front = 0; skip_front < totelem; skip_front++, tp++) {
529 if (skip_front < totelem) {
534 lb->clear_no_delete();
536 for (
int i = 0; i < totelem; i++, tp++) {
549 ListBaseT<TreeElement> *lb,
553 if (last_te ==
nullptr) {
558 bool is_parented_object =
false;
559 if (last_te->
parent !=
nullptr) {
561 if (collection ==
nullptr) {
563 te_parent = te_parent->
parent)
566 if (collection !=
nullptr) {
571 is_parented_object =
true;
577 if (collection !=
nullptr) {
578 int totelem = lb->count();
594 if (child_col !=
nullptr) {
597 collection_child_map.
add_new(child_col, cc);
604 auto treesort_custom_fn =
605 [&sort_maps, &collection_child_map, collection, is_parented_object](
const tTreeSort &a,
608 a,
b, sort_maps, collection_child_map, collection, is_parented_object);
611 std::stable_sort(tear, tear + totelem, treesort_custom_fn);
617 {collection, ob},
nullptr);
618 if (cob ==
nullptr) {
621 if (cob !=
nullptr) {
622 if (is_parented_object) {
632 if (child_col !=
nullptr) {
633 CollectionChild *cc = collection_child_map.lookup_default(child_col,
nullptr);
641 lb->clear_no_delete();
643 for (
int i = 0; i < totelem; i++, tp++) {
667 if (scene !=
nullptr) {
694 if (focus->
tselem !=
nullptr) {
700 if (te_new !=
nullptr) {
701 int ys_new = te_new->
ys;
702 int ys_old = focus->
ys;
704 float y_move = std::min(
float(ys_new - ys_old), -v2d->
cur.
ymax);
733 if (callback_test(te)) {
740 space_outliner, &te_iter, limit, callback_test);
741 if (te_sub !=
nullptr) {
762 const float view_co_limit)
765 space_outliner, &space_outliner->
runtime->
tree, view_co);
777 while (te !=
nullptr) {
779 space_outliner, te, view_co_limit, callback_test);
780 if (te_sub !=
nullptr) {
793 if (te->
parent ==
nullptr) {
874 return exclude_filter;
893 Object *ob = id_cast<Object *>(tselem->
id);
938 if (base ==
nullptr) {
942 if (base ==
nullptr) {
947 bool is_visible =
true;
972 is_visible = !is_visible;
1042 int fn_flag = FNM_NOESCAPE;
1045 fn_flag |= FNM_CASEFOLD;
1048 return fnmatch(name, te->
name, fn_flag) == 0;
1068 ListBaseT<TreeElement> *parent_subtree)
1096 ListBaseT<TreeElement> *lb,
1097 const char *search_string,
1103 for (te = lb->first(); te; te = te_next) {
1109 space_outliner, bmain, scene, view_layer, &te->
subtree, search_string, exclude_filter);
1116 space_outliner, bmain, scene, view_layer, &te->
subtree, search_string, exclude_filter);
1138 exclude_filter) == 0)
1151 space_outliner, bmain, scene, view_layer, &te->
subtree, search_string, exclude_filter);
1156 return (lb->is_empty() ==
false);
1165 const char *search_string;
1169 if (exclude_filter == 0) {
1179 search_string = search_buff;
1195 id_iter->
newid =
nullptr;
1234 "Skipping rebuild before tree was built properly, a full redraw should be "
1235 "triggered instead");
1250 space_outliner->
outlinevis, *space_outliner);
1255 TreeSourceData source_data{*mainvar, *workspace, *scene, *view_layer};
1256 space_outliner->
runtime->
tree = ListBaseT<TreeElement>{
#define FOREACH_MAIN_ID_END
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Object groups, one object can be in many groups at once.
#define SO_FILTER_OB_STATE
#define SO_FILTER_OB_TYPE
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
Base Class For Tree-Displays.
TreeElement * add_id_element(const TreeElementAddParams ¶ms, ID *id)
TreeElement * add_element_impl(const TreeElementAddParams ¶ms, short type, ID *owner_id, const void *persistent_ptr, bool allow_null_identity, FunctionRef< std::unique_ptr< AbstractTreeElement >(TreeElement &)> construct_fn)
SpaceOutliner & space_outliner_
static std::unique_ptr< AbstractTreeDisplay > create_from_display_mode(int mode, SpaceOutliner &space_outliner)
static std::unique_ptr< TreeElementID > create_from_id(TreeElement &legacy_te, ID &id)
static TreeElement * outliner_find_first_desired_element_at_y_recursive(const SpaceOutliner *space_outliner, TreeElement *te, const float limit, bool(*callback_test)(TreeElement *))
static std::optional< bool > treesort_child_not_in_collection(const tTreeSort &x1, const tTreeSort &x2)
static bool treesort_alpha_ob(const tTreeSort &x1, const tTreeSort &x2)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBaseT< TreeElement > *tree, float view_co_y)
static eSpaceOutliner_Filter outliner_exclude_filter_get(const SpaceOutliner *space_outliner)
static TreeElement * outliner_extract_children_from_subtree(TreeElement *element, ListBaseT< TreeElement > *parent_subtree)
static void outliner_restore_scrolling_position(SpaceOutliner *space_outliner, ARegion *region, OutlinerTreeElementFocus *focus)
bool outliner_is_collection_tree_element(const TreeElement *te)
static bool outliner_element_is_collection_or_object(TreeElement *te)
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
static bool test_object_callback(TreeElement *te)
static bool outliner_element_visible_get(const Main &bmain, const Scene *scene, ViewLayer *view_layer, TreeElement *te, const eSpaceOutliner_Filter exclude_filter)
static void outliner_storage_cleanup(SpaceOutliner *space_outliner)
BLI_INLINE void outliner_add_collection_objects(AbstractTreeDisplay &tree_display, ListBaseT< TreeElement > *tree, Collection *collection, TreeElement *parent)
static bool treesort_alpha(const tTreeSort &x1, const tTreeSort &x2)
bool outliner_requires_rebuild_on_select_or_active_change(const SpaceOutliner *space_outliner)
static bool outliner_filter_has_name(TreeElement *te, const char *name, int flags)
static void outliner_sort_custom(Main *bmain, Scene *scene, ListBaseT< TreeElement > *lb, const OutlinerSortMaps &sort_maps)
Collection * outliner_collection_from_tree_element(const TreeElement *te)
static bool treesort_custom(const tTreeSort &x1, const tTreeSort &x2, const OutlinerSortMaps &sort_maps, const Map< Collection *, CollectionChild * > &collection_child_map, Collection *collection, const bool is_parented_object)
static int get_sort_index(const tTreeSort &x, const OutlinerSortMaps &sort_maps, const Map< Collection *, CollectionChild * > &collection_map, Collection *collection, const bool is_parented_object)
static void map_all_objects_to_collection(Collection *collection, OutlinerSortMaps &sort_maps)
void outliner_free_tree_element(TreeElement *element, ListBaseT< TreeElement > *parent_subtree)
bool outliner_treesort_tiebreak(bool a_is_object, const char *a_name, bool b_is_object, const char *b_name)
static void check_persistent(SpaceOutliner *space_outliner, TreeElement *te, ID *id, short type, short nr)
@ TE_CHILD_NOT_IN_COLLECTION
void outliner_cleanup_tree(SpaceOutliner *space_outliner)
static void outliner_sort(ListBaseT< TreeElement > *lb)
TreeElement * outliner_find_tree_element(ListBaseT< TreeElement > *lb, const TreeStoreElem *store_elem)
void outliner_free_tree(ListBaseT< TreeElement > *tree)
TreeElement * outliner_add_collection_recursive(AbstractTreeDisplay &tree_display, SpaceOutliner *space_outliner, Collection *collection, TreeElement *ten)
static void outliner_clear_newid_from_main(Main *bmain)
static TreeElement * outliner_find_first_desired_element_at_y(const SpaceOutliner *space_outliner, const float view_co, const float view_co_limit)
void outliner_set_coordinates(const ARegion *region, SpaceOutliner *space_outliner)
BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection)
static int outliner_filter_subtree(SpaceOutliner *space_outliner, const Main &bmain, const Scene *scene, ViewLayer *view_layer, ListBaseT< TreeElement > *lb, const char *search_string, const eSpaceOutliner_Filter exclude_filter)
void outliner_build_tree(Main *mainvar, WorkSpace *workspace, Scene *scene, ViewLayer *view_layer, SpaceOutliner *space_outliner, ARegion *region)
static void outliner_store_scrolling_position(SpaceOutliner *space_outliner, ARegion *region, OutlinerTreeElementFocus *focus)
static void outliner_filter_tree(const Main &bmain, SpaceOutliner *space_outliner, const Scene *scene, ViewLayer *view_layer)
static bool test_collection_callback(TreeElement *te)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ SO_FILTER_NO_OB_MATERIAL
@ SO_FILTER_NO_OB_CONSTRAINTS
@ SO_FILTER_NO_OB_SHAPE_KEYS
@ SO_FILTER_NO_ARMATURE_BONE_COLLECTION
@ SO_FILTER_NO_OB_ARMATURE
@ SO_FILTER_OB_STATE_SELECTED
@ SO_FILTER_OB_STATE_ACTIVE
@ SO_FILTER_NO_OB_MODIFIERS
@ SO_FILTER_NO_OB_GREASE_PENCIL
@ SO_FILTER_OB_STATE_INVERSE
@ SO_FILTER_NO_GREASE_PENCIL_EFFECTS
@ SO_FILTER_NO_POSE_BONES
@ SO_FILTER_NO_OB_CONTENT
@ SO_FILTER_NO_OB_DEFGROUP
@ SO_FILTER_NO_COLLECTION
@ SO_FILTER_OB_STATE_VISIBLE
@ SO_FILTER_OB_STATE_SELECTABLE
@ SO_FILTER_NO_OB_ANIMATION
bool ED_outliner_support_searching(const SpaceOutliner *space_outliner)
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
const char * BKE_collection_ui_name_get(Collection *collection)
@ BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
@ TSE_BONE_COLLECTION_BASE
@ TSE_GPENCIL_EFFECT_BASE
char char * BLI_strncpy_ensure_pad(char *__restrict dst, const char *__restrict src, char pad, size_t dst_maxncpy) ATTR_NONNULL(1
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
CollectionChild * BKE_collection_child_find(Collection *parent, Collection *collection)
@ SO_FILTER_OB_SELECTABLE
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
void * BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const void * element
PipelineCompute comp(comp_main)
#define TREESTORE_ID_TYPE(_id)
#define SEARCHING_OUTLINER(sov)
#define SUPPORT_FILTER_OUTLINER(space_outliner_)
#define TSELEM_OPEN(telm, sv)
bke::ARegionRuntime * runtime
struct Collection * collection
ListBaseT< CollectionChild > children
ListBaseT< CollectionObject > gobject
struct Collection * master_collection
eSpaceOutliner_Mode outlinevis
eSpaceOutliner_SortMethod sort_method
ed::outliner::SpaceOutliner_Runtime * runtime
eSpaceOutliner_Search_Flags search_flags
eSpaceOutliner_Filter filter
eSpaceOutliner_StoreFlag storeflag
eSpaceOutliner_StateFilter filter_state
struct BLI_mempool * treestore
Map< Object *, CollectionObject * > object_to_any_cob_map
Map< std::pair< Collection *, Object * >, CollectionObject * > collection_and_object_to_cob_map
std::unique_ptr< treehash::TreeHash > tree_hash
ListBaseT< ed::outliner::TreeElement > tree
std::unique_ptr< AbstractTreeDisplay > tree_display
ListBaseT< TreeElement > * lb
TreeStoreElem * store_elem
std::unique_ptr< AbstractTreeElement > abstract_element
ListBaseT< TreeElement > subtree
The data to build the tree from.
Establish and manage Outliner trees for different display modes.