Outliner: Change default display mode to "Active Layer"
authorJulian Eisel <eiseljulian@gmail.com>
Wed, 15 Mar 2017 19:03:35 +0000 (20:03 +0100)
committerJulian Eisel <eiseljulian@gmail.com>
Wed, 15 Mar 2017 19:14:26 +0000 (20:14 +0100)
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.

source/blender/blenloader/intern/versioning_280.c

index ce1ea4e8ede0b97e2054f3c642542053d9299b3e..ac3f703fbd5c8598dff1502a7c6d519d69428b29 100644 (file)
@@ -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);
        }
-
 }