blender/release/scripts/startup/bl_ui/space_outliner.py

268 lines
9.1 KiB
Python
Raw Normal View History

# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2010-02-12 13:34:04 +00:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
import bpy
from bpy.types import Header, Menu
class OUTLINER_HT_header(Header):
bl_space_type = 'OUTLINER'
def draw(self, context):
layout = self.layout
space = context.space_data
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
2018-01-19 13:39:54 +00:00
display_mode = space.display_mode
scene = context.scene
ks = context.scene.keying_sets.active
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
2018-01-19 13:39:54 +00:00
support_filters = display_mode in {'COLLECTIONS', 'VIEW_LAYER'}
row = layout.row(align=True)
row.template_header()
OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
layout.prop(space, "display_mode", text="")
if space.display_mode == 'DATABLOCKS':
layout.separator()
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
2018-01-19 13:39:54 +00:00
row = layout.row(align=True)
row.operator("outliner.keyingset_add_selected", icon='ZOOMIN', text="")
row.operator("outliner.keyingset_remove_selected", icon='ZOOMOUT', text="")
if ks:
row = layout.row()
row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
row = layout.row(align=True)
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
else:
row = layout.row()
row.label(text="No Keying Set Active")
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
2018-01-19 13:39:54 +00:00
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"
bl_label = ""
def draw(self, context):
self.draw_menus(self.layout, context)
@staticmethod
def draw_menus(layout, context):
space = context.space_data
layout.menu("OUTLINER_MT_view")
if space.display_mode == 'DATABLOCKS':
layout.menu("OUTLINER_MT_edit_datablocks")
elif space.display_mode == 'ORPHAN_DATA':
layout.menu("OUTLINER_MT_edit_orphan_data")
elif space.display_mode == 'VIEW_LAYER':
layout.menu("OUTLINER_MT_edit_view_layer")
class OUTLINER_MT_view(Menu):
bl_label = "View"
def draw(self, context):
layout = self.layout
space = context.space_data
if space.display_mode != 'DATABLOCKS':
layout.prop(space, "use_sort_alpha")
layout.prop(space, "show_restrict_columns")
layout.separator()
layout.operator("outliner.show_active")
2017-01-25 05:59:10 +00:00
layout.operator("outliner.show_one_level", text="Show One Level")
layout.operator("outliner.show_one_level", text="Hide One Level").open = False
layout.operator("outliner.show_hierarchy")
layout.separator()
layout.operator("screen.area_dupli")
layout.operator("screen.screen_full_area")
layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
class OUTLINER_MT_edit_view_layer(Menu):
bl_label = "Edit"
def draw(self, context):
layout = self.layout
layout.operator("outliner.collection_link", icon='LINKED')
layout.operator("outliner.collection_new", icon='NEW')
class OUTLINER_MT_edit_datablocks(Menu):
bl_label = "Edit"
def draw(self, context):
layout = self.layout
layout.operator("outliner.keyingset_add_selected")
layout.operator("outliner.keyingset_remove_selected")
layout.separator()
layout.operator("outliner.drivers_add_selected")
layout.operator("outliner.drivers_delete_selected")
class OUTLINER_MT_edit_orphan_data(Menu):
bl_label = "Edit"
def draw(self, context):
layout = self.layout
layout.operator("outliner.orphans_purge")
class OUTLINER_MT_context_scene_collection(Menu):
bl_label = "Collection"
def draw(self, context):
layout = self.layout
layout.operator("outliner.collection_nested_new", text="New Collection", icon='NEW')
layout.operator("outliner.collection_duplicate", text="Duplicate Collection")
layout.operator("outliner.collection_delete_selected", text="Delete Collections", icon='X')
layout.separator()
layout.operator("outliner.collection_objects_add", text="Add Selected", icon='ZOOMIN')
layout.operator("outliner.collection_objects_remove", text="Remove Selected", icon='ZOOMOUT')
class OUTLINER_MT_context_object_select(Menu):
bl_label = "Object Operation Select"
def draw(self, context):
layout = self.layout
layout.operator("outliner.object_operation", text="Select").type='SELECT'
layout.operator("outliner.object_operation", text="Deselect").type='DESELECT'
layout.operator("outliner.object_operation", text="Select Hierarchy").type='SELECT_HIERARCHY'
class OUTLINER_MT_context_object_delete(Menu):
bl_label = "Object Operation Delete"
def draw(self, context):
layout = self.layout
layout.operator("outliner.object_operation", text="Delete").type='DELETE'
layout.operator("outliner.object_operation", text="Delete Hierarchy").type='DELETE_HIERARCHY'
class OUTLINER_MT_context_object_collection(Menu):
bl_label = "Object Operation Collection"
def draw(self, context):
layout = self.layout
layout.operator("outliner.object_add_to_new_collection", text="Add to New Collection", icon='ZOOMIN')
layout.operator("outliner.object_remove_from_collection", text="Remove from Collection", icon='ZOOMOUT')
class OUTLINER_MT_context_object(Menu):
bl_label = "Object"
def draw(self, context):
layout = self.layout
layout.menu("OUTLINER_MT_context_object_select", text="Select")
layout.menu("OUTLINER_MT_context_object_delete", text="Delete")
layout.menu("OUTLINER_MT_context_object_collection", text="Collection")
layout.separator()
layout.operator("outliner.object_operation", text="Remap Users").type='REMAP'
layout.operator("outliner.object_operation", text="Rename").type='RENAME'
classes = (
OUTLINER_HT_header,
OUTLINER_MT_editor_menus,
OUTLINER_MT_view,
OUTLINER_MT_edit_view_layer,
OUTLINER_MT_edit_datablocks,
OUTLINER_MT_edit_orphan_data,
OUTLINER_MT_context_scene_collection,
OUTLINER_MT_context_object,
OUTLINER_MT_context_object_delete,
OUTLINER_MT_context_object_select,
OUTLINER_MT_context_object_collection,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)