diff options
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
9 files changed, 41 insertions, 136 deletions
diff --git a/source/blender/editors/space_outliner/tree/tree_display.hh b/source/blender/editors/space_outliner/tree/tree_display.hh index bdca1954a9c..a60d3339042 100644 --- a/source/blender/editors/space_outliner/tree/tree_display.hh +++ b/source/blender/editors/space_outliner/tree/tree_display.hh @@ -136,8 +136,7 @@ class TreeDisplayOverrideLibrary final : public AbstractTreeDisplay { ListBase buildTree(const TreeSourceData &source_data) override; private: - TreeElement *add_library_contents(Main &, ListBase &, Library *); - bool override_library_id_filter_poll(const Library *lib, ID *id) const; + ListBase add_library_contents(Main &); short id_filter_get() const; }; diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc index 0023b7c7b62..476bbdb63ae 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc @@ -150,7 +150,7 @@ TreeElement *TreeDisplayLibraries::add_library_contents(Main &mainvar, ListBase } else { ten = outliner_add_element( - &space_outliner_, &tenlib->subtree, lbarray[a], nullptr, TSE_ID_BASE, 0); + &space_outliner_, &tenlib->subtree, lib, nullptr, TSE_ID_BASE, a); ten->directdata = lbarray[a]; ten->name = outliner_idcode_to_plural(GS(id->name)); } diff --git a/source/blender/editors/space_outliner/tree/tree_display_override_library.cc b/source/blender/editors/space_outliner/tree/tree_display_override_library.cc index f94727ba356..2162c303da1 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_override_library.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_override_library.cc @@ -32,72 +32,22 @@ TreeDisplayOverrideLibrary::TreeDisplayOverrideLibrary(SpaceOutliner &space_outl ListBase TreeDisplayOverrideLibrary::buildTree(const TreeSourceData &source_data) { - ListBase tree = {nullptr}; - - { - /* current file first - mainvar provides tselem with unique pointer - not used */ - TreeElement *ten = add_library_contents(*source_data.bmain, tree, nullptr); - TreeStoreElem *tselem; - - if (ten) { - tselem = TREESTORE(ten); - if (!tselem->used) { - tselem->flag &= ~TSE_CLOSED; - } - } - } + ListBase tree = add_library_contents(*source_data.bmain); - for (ID *id : List<ID>(source_data.bmain->libraries)) { - Library *lib = reinterpret_cast<Library *>(id); - TreeElement *ten = add_library_contents(*source_data.bmain, tree, lib); - /* NULL-check matters, due to filtering there may not be a new element. */ - if (ten) { - lib->id.newid = (ID *)ten; + for (TreeElement *top_level_te : List<TreeElement>(tree)) { + TreeStoreElem *tselem = TREESTORE(top_level_te); + if (!tselem->used) { + tselem->flag &= ~TSE_CLOSED; } } - /* make hierarchy */ - for (TreeElement *ten : List<TreeElement>(tree)) { - if (ten == tree.first) { - /* First item is main, skip. */ - continue; - } - - TreeStoreElem *tselem = TREESTORE(ten); - Library *lib = (Library *)tselem->id; - BLI_assert(!lib || (GS(lib->id.name) == ID_LI)); - if (!lib || !lib->parent) { - continue; - } - - TreeElement *parent = (TreeElement *)lib->parent->id.newid; - - if (tselem->id->tag & LIB_TAG_INDIRECT) { - /* Only remove from 'first level' if lib is not also directly used. */ - BLI_remlink(&tree, ten); - BLI_addtail(&parent->subtree, ten); - ten->parent = parent; - } - else { - /* Else, make a new copy of the libtree for our parent. */ - TreeElement *dupten = add_library_contents(*source_data.bmain, parent->subtree, lib); - if (dupten) { - dupten->parent = parent; - } - } - } - /* restore newid pointers */ - for (ID *library_id : List<ID>(source_data.bmain->libraries)) { - library_id->newid = nullptr; - } - return tree; } -TreeElement *TreeDisplayOverrideLibrary::add_library_contents(Main &mainvar, - ListBase &lb, - Library *lib) +ListBase TreeDisplayOverrideLibrary::add_library_contents(Main &mainvar) { + ListBase tree = {nullptr}; + const short filter_id_type = id_filter_get(); ListBase *lbarray[INDEX_ID_MAX]; @@ -110,7 +60,6 @@ TreeElement *TreeDisplayOverrideLibrary::add_library_contents(Main &mainvar, tot = set_listbasepointers(&mainvar, lbarray); } - TreeElement *tenlib = nullptr; for (int a = 0; a < tot; a++) { if (!lbarray[a] || !lbarray[a]->first) { continue; @@ -118,56 +67,51 @@ TreeElement *TreeDisplayOverrideLibrary::add_library_contents(Main &mainvar, ID *id = nullptr; - /* check if there's data in current lib */ + /* check if there's data in current id list */ for (ID *id_iter : List<ID>(lbarray[a])) { - if (id_iter->lib == lib && ID_IS_OVERRIDE_LIBRARY_REAL(id_iter)) { + if (ID_IS_OVERRIDE_LIBRARY_REAL(id_iter) && !ID_IS_LINKED(id_iter)) { id = id_iter; break; } } - if (id != nullptr) { - if (!tenlib) { - /* Create library tree element on demand, depending if there are any data-blocks. */ - if (lib) { - tenlib = outliner_add_element(&space_outliner_, &lb, lib, nullptr, TSE_SOME_ID, 0); - } - else { - tenlib = outliner_add_element(&space_outliner_, &lb, &mainvar, nullptr, TSE_ID_BASE, 0); - tenlib->name = IFACE_("Current File"); - } - if (tenlib->flag & TE_HAS_WARNING) { - has_warnings = true; - } - } + if (id == nullptr) { + continue; + } - /* Create data-block list parent element on demand. */ - TreeElement *ten; + /* Create data-block list parent element on demand. */ + TreeElement *id_base_te = nullptr; + ListBase *lb_to_expand = &tree; - if (filter_id_type) { - ten = tenlib; - } - else { - ten = outliner_add_element( - &space_outliner_, &tenlib->subtree, lbarray[a], nullptr, TSE_ID_BASE, 0); - ten->directdata = lbarray[a]; - ten->name = outliner_idcode_to_plural(GS(id->name)); - } + if (!filter_id_type) { + id_base_te = outliner_add_element( + &space_outliner_, &tree, lbarray[a], nullptr, TSE_ID_BASE, 0); + id_base_te->directdata = lbarray[a]; + id_base_te->name = outliner_idcode_to_plural(GS(id->name)); - for (ID *id : List<ID>(lbarray[a])) { - if (override_library_id_filter_poll(lib, id)) { - TreeElement *override_tree_element = outliner_add_element( - &space_outliner_, &ten->subtree, id, ten, TSE_LIBRARY_OVERRIDE_BASE, 0); + lb_to_expand = &id_base_te->subtree; + } - if (BLI_listbase_is_empty(&override_tree_element->subtree)) { - outliner_free_tree_element(override_tree_element, &ten->subtree); - } + for (ID *id : List<ID>(lbarray[a])) { + if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && !ID_IS_LINKED(id)) { + TreeElement *override_tree_element = outliner_add_element( + &space_outliner_, lb_to_expand, id, id_base_te, TSE_LIBRARY_OVERRIDE_BASE, 0); + + if (BLI_listbase_is_empty(&override_tree_element->subtree)) { + outliner_free_tree_element(override_tree_element, lb_to_expand); } } } } - return tenlib; + /* Remove ID base elements that turn out to be empty. */ + LISTBASE_FOREACH_MUTABLE (TreeElement *, te, &tree) { + if (BLI_listbase_is_empty(&te->subtree)) { + outliner_free_tree_element(te, &tree); + } + } + + return tree; } short TreeDisplayOverrideLibrary::id_filter_get() const @@ -178,17 +122,4 @@ short TreeDisplayOverrideLibrary::id_filter_get() const return 0; } -bool TreeDisplayOverrideLibrary::override_library_id_filter_poll(const Library *lib, ID *id) const -{ - if (id->lib != lib) { - return false; - } - - if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) { - return false; - } - - return true; -} - } // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc index 0ee5059a54d..19811e45b90 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc @@ -154,15 +154,6 @@ void TreeDisplayViewLayer::add_layer_collections_recursive(ListBase &tree, if (!exclude && show_objects_) { add_layer_collection_objects(ten->subtree, *lc, *ten); } - - const bool lib_overrides_visible = !exclude && (!SUPPORT_FILTER_OUTLINER(&space_outliner_) || - ((space_outliner_.filter & - SO_FILTER_NO_LIB_OVERRIDE) == 0)); - - if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY_REAL(&lc->collection->id)) { - outliner_add_element( - &space_outliner_, &ten->subtree, &lc->collection->id, ten, TSE_LIBRARY_OVERRIDE_BASE, 0); - } } } diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 3c2023d7905..ca67aad00db 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -107,7 +107,6 @@ void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner return; } tree_element.expand(space_outliner); - tree_element.postExpand(space_outliner); } bool tree_element_warnings_get(TreeElement *te, int *r_icon, const char **r_message) diff --git a/source/blender/editors/space_outliner/tree/tree_element.hh b/source/blender/editors/space_outliner/tree/tree_element.hh index 2fbc86705b9..6f2d803ae96 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.hh +++ b/source/blender/editors/space_outliner/tree/tree_element.hh @@ -40,9 +40,6 @@ class AbstractTreeElement { { return true; } - virtual void postExpand(SpaceOutliner &) const - { - } /** * Just while transitioning to the new tree-element design: Some types are only partially ported, diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index 64c73f57107..ef5e056f229 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -93,17 +93,6 @@ TreeElementID::TreeElementID(TreeElement &legacy_te, ID &id) legacy_te_.idcode = GS(id.name); } -void TreeElementID::postExpand(SpaceOutliner &space_outliner) const -{ - const bool lib_overrides_visible = !SUPPORT_FILTER_OUTLINER(&space_outliner) || - ((space_outliner.filter & SO_FILTER_NO_LIB_OVERRIDE) == 0); - - if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY_REAL(&id_)) { - outliner_add_element( - &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE_BASE, 0); - } -} - bool TreeElementID::expandPoll(const SpaceOutliner &space_outliner) const { const TreeStoreElem *tsepar = legacy_te_.parent ? TREESTORE(legacy_te_.parent) : nullptr; diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.hh b/source/blender/editors/space_outliner/tree/tree_element_id.hh index 75dc7e737e2..b7519fe06f9 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_id.hh @@ -24,7 +24,6 @@ class TreeElementID : public AbstractTreeElement { static std::unique_ptr<TreeElementID> createFromID(TreeElement &legacy_te, ID &id); - void postExpand(SpaceOutliner &) const override; bool expandPoll(const SpaceOutliner &) const override; /** diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.cc b/source/blender/editors/space_outliner/tree/tree_element_rna.cc index abc7cd8f8ce..914104f1f06 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc @@ -52,7 +52,7 @@ bool TreeElementRNACommon::isRNAValid() const return rna_ptr_.data != nullptr; } -bool TreeElementRNACommon::expandPoll(const SpaceOutliner &) const +bool TreeElementRNACommon::expandPoll(const SpaceOutliner &UNUSED(space_outliner)) const { return isRNAValid(); } |