[Bf-blender-cvs] [37913cf5326] blender2.8: Outliner Filtering System + Cleanup

Dalai Felinto noreply at git.blender.org
Fri Jan 19 15:20:47 CET 2018


Commit: 37913cf5326a732cb94c28f96c1deb8f3965c846
Author: Dalai Felinto
Date:   Fri Jan 19 11:39:54 2018 -0200
Branches: blender2.8
https://developer.blender.org/rB37913cf5326a732cb94c28f96c1deb8f3965c846

Outliner Filtering System + Cleanup

User notes:

The outliner so far was a great system to handle the object oriented workflow
we had in Blender prior to 2.8. However with the introduction of collections
the bloated ammount of data we were exposed at a given time was eventually
getting on the way of fully utilizing the outliner to manage collections and
their objects.

We hope that with this filtering system the user can put together the outliner
with whichever options he or she seem fit for a given task.

Features:
* Collection filter: In case users are only focused on objects.
* Object filter: Allow users to focus on collections only.
* (Object) content filter: Modifiers, mesh, contrainst, materials, ...
* (Object) children filter: Hide object children [1].
* Object State (visible, active, selected).
* Compact header: hide search options under a search toggle.
* Preserve scrolling position before/after filtering [2].

[1] - Note we still need to be able to tell if a children of an object is in a
      collection, or if the parent object is the only one in the collection.
      This in fact was one of the first motivations for this patch. But it is to
      be addressed separately now that we can at least hide children away.

[2] - We look at the top-most collection in the outliner, and try to find it again
      after the filtering and make sure it is in the same position as before.
      This works nice now. But to work REALLY, REALLY nice we need to also store
      the previous filter options to be sure the element we try to keep on top
      was valid for both old and new filters. I would rather do this later though
      since this smell a lot like feature creeping ;)

Remove no longer needed display options:
 * Current Scene (replaced by View Layer/Collections)
 * Visible (replaced by filter)
 * Selected (same)
 * Active (same)
 * Same Type (same-ish)

How about All Scenes? I have a patch that will come next to replace the current
behaviour and focus only on compositing. So basically stop showing the objects
and show only view layers, their passes and collections, besides freestyle.

Also, while at this I'm also reorganizing the menu to keep View Layer and
Collections on top.

Developer notes:

* Unlike the per-object filtering, for collections we need to filter at tree
creation time, to prevent duplication of objects in the outliner.

Acknowledgements:

Thanks Pablo Vazquez for helping testing, thinking some design questions
together and pushing this to its final polished state as you see here.

Thanks Sergey Sharybin and Julian Eisel for code review. Julian couldn't do a
final review pass after I addressed his concerns. So blame is on me for any
issue I may be introducing here. Sergey was the author of the "preserve
scrolling position" idea. I'm happy with how it is working, thank you.

Reviewers: sergey, Severin, venomgfx
Subscribers: lichtwerk, duarteframos

Differential Revision: https://developer.blender.org/D2992

===================================================================

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/blenloader/intern/versioning_260.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index d97f057a903..5b4a7d34264 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -28,8 +28,10 @@ class OUTLINER_HT_header(Header):
         layout = self.layout
 
         space = context.space_data
+        display_mode = space.display_mode
         scene = context.scene
         ks = context.scene.keying_sets.active
+        support_filters = display_mode in {'COLLECTIONS', 'VIEW_LAYER'}
 
         row = layout.row(align=True)
         row.template_header()
@@ -38,13 +40,9 @@ class OUTLINER_HT_header(Header):
 
         layout.prop(space, "display_mode", text="")
 
-        row = layout.row(align=True)
-        row.prop(space, "filter_text", icon='VIEWZOOM', text="")
-        row.prop(space, "use_filter_complete", text="")
-        row.prop(space, "use_filter_case_sensitive", text="")
-
         if space.display_mode == 'DATABLOCKS':
             layout.separator()
+
             row = layout.row(align=True)
             row.operator("outliner.keyingset_add_selected", icon='ZOOMIN', text="")
             row.operator("outliner.keyingset_remove_selected", icon='ZOOMOUT', text="")
@@ -60,6 +58,54 @@ class OUTLINER_HT_header(Header):
                 row = layout.row()
                 row.label(text="No Keying Set Active")
 
+        row = layout.row(align=True)
+        row.prop(space, "use_filter_search", text="")
+        if space.use_filter_search:
+            row.prop(space, "filter_text", text="")
+            row.prop(space, "use_filter_complete", text="")
+            row.prop(space, "use_filter_case_sensitive", text="")
+
+        if support_filters:
+            row.separator()
+
+            row.prop(space, "use_filters", text="")
+            if space.use_filters:
+                row.separator()
+                row.prop(space, "use_filter_collection", text="")
+                row.prop(space, "use_filter_object", text="")
+                sub = row.row(align=True)
+                sub.active = space.use_filter_object
+                sub.prop(space, "use_filter_object_content", text="")
+                sub.prop(space, "use_filter_children", text="")
+
+                sub.separator()
+                sub.prop(space, "use_filter_object_type", text="")
+
+                if space.use_filter_object_type:
+                    if bpy.data.meshes:
+                        sub.prop(space, "use_filter_object_mesh", text="")
+                    if bpy.data.armatures:
+                        sub.prop(space, "use_filter_object_armature", text="")
+                    if bpy.data.lamps:
+                        sub.prop(space, "use_filter_object_lamp", text="")
+                    if bpy.data.cameras:
+                        sub.prop(space, "use_filter_object_camera", text="")
+
+                    sub.prop(space, "use_filter_object_empty", text="")
+
+                    if bpy.data.curves or \
+                       bpy.data.metaballs or \
+                       bpy.data.lightprobes or \
+                       bpy.data.lattices or \
+                       bpy.data.fonts or bpy.data.speakers:
+                        sub.prop(space, "use_filter_object_others", text="")
+
+                sub.separator()
+                sub.prop(space, "use_filter_object_state", text="")
+
+                if space.use_filter_object_state:
+                    sub.prop(space, "filter_state", text="", expand=True)
+
 
 class OUTLINER_MT_editor_menus(Menu):
     bl_idname = "OUTLINER_MT_editor_menus"
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 77542d8deb9..bf5b19b92ee 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -2453,9 +2453,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
 					if (sl->spacetype == SPACE_OUTLINER) {
 						SpaceOops *so = (SpaceOops *)sl;
 
-						if (!ELEM(so->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_SELECTED, SO_ACTIVE,
-						                          SO_SAME_TYPE, SO_GROUPS, SO_LIBRARIES, SO_SEQUENCE, SO_DATABLOCKS,
-						                          SO_USERDEF))
+						if (!ELEM(so->outlinevis,
+						          SO_ALL_SCENES,
+						          SO_GROUPS,
+						          SO_LIBRARIES,
+						          SO_SEQUENCE,
+						          SO_DATABLOCKS,
+						          SO_USERDEF))
 						{
 							so->outlinevis = SO_ALL_SCENES;
 						}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 49cf86fc84c..9a4d171f7fa 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -883,4 +883,37 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	{
+		if (DNA_struct_elem_find(fd->filesdna, "SpaceOops", "int", "filter") == false) {
+			bScreen *sc;
+			ScrArea *sa;
+			SpaceLink *sl;
+
+			/* Update files using invalid (outdated) outlinevis Outliner values. */
+			for (sc = main->screen.first; sc; sc = sc->id.next) {
+				for (sa = sc->areabase.first; sa; sa = sa->next) {
+					for (sl = sa->spacedata.first; sl; sl = sl->next) {
+						if (sl->spacetype == SPACE_OUTLINER) {
+							SpaceOops *so = (SpaceOops *)sl;
+
+							if (!ELEM(so->outlinevis,
+									  SO_ALL_SCENES,
+									  SO_GROUPS,
+									  SO_LIBRARIES,
+									  SO_SEQUENCE,
+									  SO_DATABLOCKS,
+									  SO_USERDEF,
+							          SO_ID_ORPHANS,
+							          SO_VIEW_LAYER,
+							          SO_COLLECTIONS))
+							{
+								so->outlinevis = SO_VIEW_LAYER;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 8f46767711f..c903a5026cf 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1415,7 +1415,7 @@ static void outliner_draw_tree_element(
 			te->flag |= TE_ACTIVE; // for lookup in display hierarchies
 		}
 		
-		if ((soops->outlinevis == SO_COLLECTIONS) && te->parent == NULL) {
+		if ((soops->outlinevis == SO_COLLECTIONS) && (tselem->type == TSE_SCENE_COLLECTION) && (te->parent == NULL)) {
 			/* Master collection can't expand/collapse. */
 		}
 		else if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) {
@@ -1720,7 +1720,9 @@ static void outliner_draw_highlights_recursive(
         int start_x, int *io_start_y)
 {
 	const bool is_searching = SEARCHING_OUTLINER(soops) ||
-	                          (soops->outlinevis == SO_DATABLOCKS && soops->search_string[0] != 0);
+	                          (soops->outlinevis == SO_DATABLOCKS &&
+	                           (soops->filter & SO_FILTER_SEARCH) &&
+	                           soops->search_string[0] != 0);
 
 	for (TreeElement *te = lb->first; te; te = te->next) {
 		const TreeStoreElem *tselem = TREESTORE(te);
@@ -1904,7 +1906,7 @@ void draw_outliner(const bContext *C)
 	TreeElement *te_edit = NULL;
 	bool has_restrict_icons;
 
-	outliner_build_tree(mainvar, scene, view_layer, soops); // always
+	outliner_build_tree(mainvar, scene, view_layer, soops, ar); // always
 	
 	/* get extents of data */
 	outliner_height(soops, &soops->tree, &sizey);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 8cd76179f23..96692799e0d 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -949,7 +949,7 @@ static void outliner_set_coordinates_element_recursive(SpaceOops *soops, TreeEle
 }
 
 /* to retrieve coordinates with redrawing the entire tree */
-static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
+void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
 {
 	TreeElement *te;
 	int starty = (int)(ar->v2d.tot.ymax) - UI_UNIT_Y;
@@ -2085,7 +2085,7 @@ static int outliner_parenting_poll(bContext *C)
 	SpaceOops *soops = CTX_wm_space_outliner(C);
 
 	if (soops) {
-		return ELEM(soops->outlinevis, SO_ALL_SCENES, SO_CUR_SCENE, SO_VISIBLE, SO_GROUPS);
+		return ELEM(soops->outlinevis, SO_ALL_SCENES, SO_GROUPS);
 	}
 
 	return false;
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 66f6c7026e6..9e8433a519a 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -36,6 +36,7 @@
 
 /* internal exports only */
 
+struct ARegion;
 struct wmOperatorType;
 struct TreeElement;
 struct TreeStoreElem;
@@ -154,6 +155,9 @@ typedef enum {
 #define OL_RNA_COL_SIZEX    (UI_UNIT_X * 7.5f)
 #define OL_RNA_COL_SPACEX   (UI_UNIT_X * 2.5f)
 
+/* The outliner display modes that support the filter system.
+ * Note: keep it synced with space_outliner.py */
+#define SUPPORT_FILTER_OUTLINER(soops_) ELEM((soops_)->outlinevis, SO_VIEW_LAYER, SO_COLLECTIONS)
 
 /* Outliner Searching --
  *
@@ -171,7 +175,7 @@ typedef enum {
  * - not searching into RNA items helps but isn't the complete solution
  */
 
-#define SEARCHING_OUTLINER(sov)   (sov->search_flags & SO_SEARCH_RECURSIVE)
+#define SEARCHING_OUTLINER(sov)   ((sov->search_flags & SO_SEARCH_RECURSIVE) && (sov->filter & SO_FILTER_SEARCH))
 
 /* is the currrent element open? if so we also show children */
 #define TSELEM_OPEN(telm, sv)    ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) )
@@ -183,7 +187,8 @@ void outliner_cleanup_tree(struct SpaceOops *soops);
 void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree);
 void outliner_remove_treestore_element(struct SpaceOops *soops, TreeStoreElem *tselem);
 
-void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct ViewLayer *view_layer, struct SpaceOops *soops);
+void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Vie

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list