From 7f596d39dff110479f01cffcec203c3a98999b64 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 15 Mar 2017 20:03:35 +0100 Subject: [PATCH] Outliner: Change default display mode to "Active Layer" We concluded this is going to be the display mode users will need to work with the most, so makes sense to make it the default one. Also, if the opened file only has one collection in the active render layer, we expand it (almost empty list would be misleading). What I had to do to make the expanding work is a bit ugly, but didn't find a better way. During do_version we don't have access to the TreeElement instances, and including ED_outliner.h to share code here should be avoided too. --- .../blenloader/intern/versioning_280.c | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ce1ea4e8ede..ac3f703fbd5 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -42,6 +42,7 @@ #include "BKE_scene.h" #include "BLI_listbase.h" +#include "BLI_mempool.h" #include "BLI_string.h" #include "BLO_readfile.h" @@ -180,6 +181,30 @@ void do_versions_after_linking_280(Main *main) scene->basact = NULL; } } + + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_OUTLINER) { + SpaceOops *soutliner = (SpaceOops *)sl; + SceneLayer *layer = BKE_scene_layer_context_active(screen->scene); + + soutliner->outlinevis = SO_ACT_LAYER; + + if (BLI_listbase_count_ex(&layer->layer_collections, 2) == 1) { + /* Create a tree store element for the collection. This is normally + * done in check_persistent (outliner_tree.c), but we need to access + * it here :/ (expand element if it's the only one) */ + TreeStoreElem *tselem = BLI_mempool_alloc(soutliner->treestore); + tselem->type = TSE_LAYER_COLLECTION; + tselem->id = layer->layer_collections.first; + tselem->nr = tselem->used = 0; + tselem->flag &= ~TSE_CLOSED; + } + } + } + } + } } } @@ -202,5 +227,4 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) /* temporary validation of 280 files for layers */ blo_do_version_temporary(main); } - }