diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_tree.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tree.c | 196 |
1 files changed, 56 insertions, 140 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index f94f19246fa..573fb492613 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1,4 +1,4 @@ -/* +/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -62,23 +62,14 @@ #include "BLT_translation.h" #include "BKE_armature.h" -#include "BKE_fcurve_driver.h" -#include "BKE_idtype.h" #include "BKE_layer.h" #include "BKE_lib_id.h" -#include "BKE_lib_override.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_outliner_treehash.h" -#include "DEG_depsgraph.h" -#include "DEG_depsgraph_build.h" - #include "ED_screen.h" -#include "WM_api.h" -#include "WM_types.h" - #include "RNA_access.h" #include "UI_interface.h" @@ -92,9 +83,6 @@ #endif /* prototypes */ -static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner, - Collection *collection, - TreeElement *ten); static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner); /* ********************************************************* */ @@ -274,7 +262,7 @@ static void outliner_add_bone(SpaceOutliner *space_outliner, } } -static bool outliner_animdata_test(AnimData *adt) +bool outliner_animdata_test(const AnimData *adt) { if (adt) { return (adt->action || adt->drivers.first || adt->nla_tracks.first); @@ -307,53 +295,13 @@ static void outliner_add_line_styles(SpaceOutliner *space_outliner, continue; } linestyle->id.tag &= ~LIB_TAG_DOIT; - outliner_add_element(space_outliner, lb, linestyle, te, 0, 0); + outliner_add_element(space_outliner, lb, linestyle, te, TSE_SOME_ID, 0); } } } } #endif -static void outliner_add_scene_contents(SpaceOutliner *space_outliner, - ListBase *lb, - Scene *sce, - TreeElement *te) -{ - /* View layers */ - TreeElement *ten = outliner_add_element(space_outliner, lb, sce, te, TSE_R_LAYER_BASE, 0); - ten->name = IFACE_("View Layers"); - - ViewLayer *view_layer; - for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { - TreeElement *tenlay = outliner_add_element( - space_outliner, &ten->subtree, sce, ten, TSE_R_LAYER, 0); - tenlay->name = view_layer->name; - tenlay->directdata = view_layer; - } - - /* World */ - outliner_add_element(space_outliner, lb, sce->world, te, 0, 0); - - /* Collections */ - ten = outliner_add_element(space_outliner, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0); - ten->name = IFACE_("Scene Collection"); - outliner_add_collection_recursive(space_outliner, sce->master_collection, ten); - - /* Objects */ - ten = outliner_add_element(space_outliner, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0); - ten->name = IFACE_("Objects"); - FOREACH_SCENE_OBJECT_BEGIN (sce, ob) { - outliner_add_element(space_outliner, &ten->subtree, ob, ten, 0, 0); - } - FOREACH_SCENE_OBJECT_END; - outliner_make_object_parent_hierarchy(&ten->subtree); - - /* Animation Data */ - if (outliner_animdata_test(sce->adt)) { - outliner_add_element(space_outliner, lb, sce, te, TSE_ANIM_DATA, 0); - } -} - /* Can be inlined if necessary. */ static void outliner_add_object_contents(SpaceOutliner *space_outliner, TreeElement *te, @@ -368,14 +316,14 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner, &te->subtree, ob->poselib, te, - 0, + TSE_SOME_ID, 0); /* XXX FIXME.. add a special type for this. */ if (ob->proxy && !ID_IS_LINKED(ob)) { outliner_add_element(space_outliner, &te->subtree, ob->proxy, te, TSE_PROXY, 0); } - outliner_add_element(space_outliner, &te->subtree, ob->data, te, 0, 0); + outliner_add_element(space_outliner, &te->subtree, ob->data, te, TSE_SOME_ID, 0); if (ob->pose) { bArmature *arm = ob->data; @@ -458,7 +406,7 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner, } for (int a = 0; a < ob->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, ob->mat[a], te, 0, a); + outliner_add_element(space_outliner, &te->subtree, ob->mat[a], te, TSE_SOME_ID, a); } if (!BLI_listbase_is_empty(&ob->constraints)) { @@ -624,33 +572,8 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner, /* duplicated group */ if (ob->instance_collection && (ob->transflag & OB_DUPLICOLLECTION)) { - outliner_add_element(space_outliner, &te->subtree, ob->instance_collection, te, 0, 0); - } -} - -static void outliner_add_library_override_contents(SpaceOutliner *soops, TreeElement *te, ID *id) -{ - if (!id->override_library) { - return; - } - - PointerRNA idpoin; - RNA_id_pointer_create(id, &idpoin); - - PointerRNA override_ptr; - PropertyRNA *override_prop; - int index = 0; - LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) { - if (!BKE_lib_override_rna_property_find(&idpoin, op, &override_ptr, &override_prop)) { - /* This is fine, override properties list is not always fully up-to-date with current - * RNA/IDProps etc., this gets cleaned up when re-generating the overrides rules, - * no error here. */ - continue; - } - - TreeElement *ten = outliner_add_element( - soops, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE, index++); - ten->name = RNA_property_ui_name(override_prop); + outliner_add_element( + space_outliner, &te->subtree, ob->instance_collection, te, TSE_SOME_ID, 0); } } @@ -667,14 +590,10 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, /* expand specific data always */ switch (GS(id->name)) { - case ID_LI: { - te->name = ((Library *)id)->filepath; - break; - } - case ID_SCE: { - outliner_add_scene_contents(space_outliner, &te->subtree, (Scene *)id, te); + case ID_LI: + case ID_SCE: + BLI_assert(!"ID type expected to be expanded through new tree-element design"); break; - } case ID_OB: { outliner_add_object_contents(space_outliner, te, tselem, (Object *)id); break; @@ -686,9 +605,9 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, outliner_add_element(space_outliner, &te->subtree, me, te, TSE_ANIM_DATA, 0); } - outliner_add_element(space_outliner, &te->subtree, me->key, te, 0, 0); + outliner_add_element(space_outliner, &te->subtree, me->key, te, TSE_SOME_ID, 0); for (int a = 0; a < me->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, 0, a); + outliner_add_element(space_outliner, &te->subtree, me->mat[a], te, TSE_SOME_ID, a); } /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ @@ -702,7 +621,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, } for (int a = 0; a < cu->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, 0, a); + outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, TSE_SOME_ID, a); } break; } @@ -714,7 +633,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, } for (int a = 0; a < mb->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, 0, a); + outliner_add_element(space_outliner, &te->subtree, mb->mat[a], te, TSE_SOME_ID, a); } break; } @@ -730,7 +649,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, if (outliner_animdata_test(tex->adt)) { outliner_add_element(space_outliner, &te->subtree, tex, te, TSE_ANIM_DATA, 0); } - outliner_add_element(space_outliner, &te->subtree, tex->ima, te, 0, 0); + outliner_add_element(space_outliner, &te->subtree, tex->ima, te, TSE_SOME_ID, 0); break; } case ID_CA: { @@ -901,17 +820,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, default: break; } - - 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(id)) { - TreeElement *ten = outliner_add_element( - space_outliner, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE_BASE, 0); - - ten->name = IFACE_("Library Overrides"); - outliner_add_library_override_contents(space_outliner, ten, id); - } } /** @@ -972,6 +880,10 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, /* New C++ based type handle (`TreeElementType` in C, `AbstractTreeElement` in C++). Only some * support this, eventually this should replace `TreeElement` entirely. */ te->type = outliner_tree_element_type_create(type, te, idv); + if (te->type) { + /* Element types ported to the new design are expected to have their name set at this point! */ + BLI_assert(te->name != NULL); + } if (ELEM(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { /* pass */ @@ -991,41 +903,43 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, else if (type == TSE_ID_BASE) { /* pass */ } + else if (type == TSE_SOME_ID) { + if (!te->type) { + BLI_assert(!"Expected this ID type to be ported to new Outliner tree-element design"); + } + } else { /* Other cases must be caught above. */ BLI_assert(TSE_IS_REAL_ID(tselem)); - /* do here too, for blend file viewer, own ID_LI then shows file name */ - if (GS(id->name) == ID_LI) { - te->name = ((Library *)id)->filepath; - } - else { + /* The new type design sets the name already, don't override that here. We need to figure out + * how to deal with the idcode for non-TSE_SOME_ID types still. Some rely on it... */ + if (!te->type) { te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */ } te->idcode = GS(id->name); } - if (te->type) { + if (te->type && outliner_tree_element_type_is_expand_valid(te->type)) { outliner_tree_element_type_expand(te->type, space_outliner); } - else if (type == 0) { - TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL; - - /* ID data-block. */ - if (tsepar == NULL || tsepar->type != TSE_ID_BASE || space_outliner->filter_id_type) { + else if (type == TSE_SOME_ID) { + /* ID types not (fully) ported to new design yet. */ + if (outliner_tree_element_type_expand_poll(te->type, space_outliner)) { outliner_add_id_contents(space_outliner, te, tselem, id); + outliner_tree_element_type_post_expand(te->type, space_outliner); } } - else if (ELEM(type, TSE_ANIM_DATA, TSE_DRIVER_BASE, TSE_NLA, TSE_NLA_ACTION, TSE_NLA_TRACK)) { + else if (ELEM(type, + TSE_ANIM_DATA, + TSE_DRIVER_BASE, + TSE_NLA, + TSE_NLA_ACTION, + TSE_NLA_TRACK, + TSE_GP_LAYER)) { /* Should already use new AbstractTreeElement design. */ BLI_assert(0); } - else if (type == TSE_GP_LAYER) { - bGPDlayer *gpl = (bGPDlayer *)idv; - - te->name = gpl->info; - te->directdata = gpl; - } else if (type == TSE_SEQUENCE) { Sequence *seq = (Sequence *)idv; @@ -1229,18 +1143,19 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *space_outliner, TreeElement *parent) { LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { - outliner_add_element(space_outliner, tree, cob->ob, parent, 0, 0); + outliner_add_element(space_outliner, tree, cob->ob, parent, TSE_SOME_ID, 0); } } -static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner, - Collection *collection, - TreeElement *ten) +TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner, + Collection *collection, + TreeElement *ten) { outliner_add_collection_init(ten, collection); LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { - outliner_add_element(space_outliner, &ten->subtree, &child->collection->id, ten, 0, 0); + outliner_add_element( + space_outliner, &ten->subtree, &child->collection->id, ten, TSE_SOME_ID, 0); } if (space_outliner->outlinevis != SO_SCENES) { @@ -1265,7 +1180,7 @@ void outliner_make_object_parent_hierarchy(ListBase *lb) TreeElement *ten = te->next; TreeStoreElem *tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == ID_OB) { + if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); @@ -1406,7 +1321,7 @@ static void outliner_sort(ListBase *lb) /* sorting rules; only object lists, ID lists, or deformgroups */ if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || - (tselem->type == 0 && te->idcode == ID_OB)) { + ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB))) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { @@ -1420,7 +1335,7 @@ static void outliner_sort(ListBase *lb) tp->name = te->name; tp->idcode = te->idcode; - if (tselem->type && tselem->type != TSE_DEFGROUP) { + if ((tselem->type != TSE_SOME_ID) && tselem->type != TSE_DEFGROUP) { tp->idcode = 0; /* Don't sort this. */ } if (tselem->type == TSE_ID_BASE) { @@ -1471,7 +1386,7 @@ static void outliner_collections_children_sort(ListBase *lb) TreeStoreElem *tselem = TREESTORE(te); /* Sorting rules: only object lists. */ - if (tselem->type == 0 && te->idcode == ID_OB) { + if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { @@ -1546,7 +1461,7 @@ static bool test_collection_callback(TreeElement *te) static bool test_object_callback(TreeElement *te) { TreeStoreElem *tselem = TREESTORE(te); - return ((tselem->type == 0) && (te->idcode == ID_OB)); + return ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)); } /** @@ -1707,7 +1622,7 @@ static bool outliner_element_visible_get(ViewLayer *view_layer, } TreeStoreElem *tselem = TREESTORE(te); - if ((tselem->type == 0) && (te->idcode == ID_OB)) { + if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) { if ((exclude_filter & SO_FILTER_OB_TYPE) == SO_FILTER_OB_TYPE) { return false; } @@ -1790,14 +1705,15 @@ static bool outliner_element_visible_get(ViewLayer *view_layer, return is_visible; } - if ((te->parent != NULL) && (TREESTORE(te->parent)->type == 0) && + if ((te->parent != NULL) && (TREESTORE(te->parent)->type == TSE_SOME_ID) && (te->parent->idcode == ID_OB)) { if (exclude_filter & SO_FILTER_NO_CHILDREN) { return false; } } } - else if (te->parent != NULL && TREESTORE(te->parent)->type == 0 && te->parent->idcode == ID_OB) { + else if ((te->parent != NULL) && (TREESTORE(te->parent)->type == TSE_SOME_ID) && + (te->parent->idcode == ID_OB)) { if (exclude_filter & SO_FILTER_NO_OB_CONTENT) { return false; } @@ -1821,7 +1737,7 @@ static bool outliner_element_is_collection_or_object(TreeElement *te) { TreeStoreElem *tselem = TREESTORE(te); - if ((tselem->type == 0) && (te->idcode == ID_OB)) { + if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) { return true; } |