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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-17 14:40:59 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-05-17 15:27:59 +0300
commit2e635b650089289ef53b830b2007d34262cb959c (patch)
treead9e858537d2e0e617f2d13a856b8a16219f8821 /source/blender/editors/space_outliner
parent75321a3d24d87ea3f333c55ee3880d7b3972c8eb (diff)
Outliner: add ID type filter option for Blender File and Orphaned Data.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c60
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c1
2 files changed, 39 insertions, 22 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index f985734795c..ed809062a29 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1260,7 +1260,7 @@ static const char *outliner_idcode_to_plural(short idcode)
{
const char *propname = BKE_idcode_to_name_plural(idcode);
PropertyRNA *prop = RNA_struct_type_find_property(&RNA_BlendData, propname);
- return RNA_property_ui_name(prop);
+ return (prop) ? RNA_property_ui_name(prop) : "UNKNOWN";
}
static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib)
@@ -1268,10 +1268,18 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE
TreeElement *ten;
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
+ short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
- tot = set_listbasepointers(mainvar, lbarray);
+ if (filter_id_type) {
+ lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
+ tot = 1;
+ }
+ else {
+ tot = set_listbasepointers(mainvar, lbarray);
+ }
+
for (a = 0; a < tot; a++) {
- if (lbarray[a]->first) {
+ if (lbarray[a] && lbarray[a]->first) {
ID *id = lbarray[a]->first;
/* check if there's data in current lib */
@@ -1280,12 +1288,14 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE
break;
if (id) {
- ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
- ten->directdata = lbarray[a];
-
- ten->name = outliner_idcode_to_plural(GS(id->name));
- if (ten->name == NULL)
- ten->name = "UNKNOWN";
+ if (filter_id_type) {
+ ten = te;
+ }
+ else {
+ ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten->directdata = lbarray[a];
+ ten->name = outliner_idcode_to_plural(GS(id->name));
+ }
for (id = lbarray[a]->first; id; id = id->next) {
if (id->lib == lib)
@@ -1302,10 +1312,18 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
TreeElement *ten;
ListBase *lbarray[MAX_LIBARRAY];
int a, tot;
+ short filter_id_type = (soops->filter & SO_FILTER_ID_TYPE) ? soops->filter_id_type : 0;
- tot = set_listbasepointers(mainvar, lbarray);
+ if (filter_id_type) {
+ lbarray[0] = which_libbase(mainvar, soops->filter_id_type);
+ tot = 1;
+ }
+ else {
+ tot = set_listbasepointers(mainvar, lbarray);
+ }
+
for (a = 0; a < tot; a++) {
- if (lbarray[a]->first) {
+ if (lbarray[a] && lbarray[a]->first) {
ID *id = lbarray[a]->first;
/* check if there are any datablocks of this type which are orphans */
@@ -1316,21 +1334,19 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops)
if (id) {
/* header for this type of datablock */
- /* TODO's:
- * - Add a parameter to BKE_idcode_to_name_plural to get a sane "user-visible" name instead?
- * - Ensure that this uses nice icons for the datablock type involved instead of the dot?
- */
- ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
- ten->directdata = lbarray[a];
-
- ten->name = outliner_idcode_to_plural(GS(id->name));
- if (ten->name == NULL)
- ten->name = "UNKNOWN";
+ if (filter_id_type) {
+ ten = NULL;
+ }
+ else {
+ ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0);
+ ten->directdata = lbarray[a];
+ ten->name = outliner_idcode_to_plural(GS(id->name));
+ }
/* add the orphaned datablocks - these will not be added with any subtrees attached */
for (id = lbarray[a]->first; id; id = id->next) {
if (ID_REAL_USERS(id) <= 0)
- outliner_add_element(soops, &ten->subtree, id, ten, 0, 0);
+ outliner_add_element(soops, (ten) ? &ten->subtree : &soops->tree, id, ten, 0, 0);
}
}
}
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 72c8e0696bc..b762dd31f58 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -487,6 +487,7 @@ static SpaceLink *outliner_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner");
soutliner->spacetype = SPACE_OUTLINER;
+ soutliner->filter_id_type = ID_GR;
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for outliner");