1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Header, Menu, Panel
24 class OUTLINER_HT_header(Header):
25 bl_space_type = 'OUTLINER'
27 def draw(self, context):
30 space = context.space_data
31 display_mode = space.display_mode
33 ks = context.scene.keying_sets.active
35 row = layout.row(align=True)
38 layout.prop(space, "display_mode", icon_only=True)
40 if display_mode == 'DATA_API':
41 OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
43 layout.separator_spacer()
45 row = layout.row(align=True)
46 row.prop(space, "filter_text", icon='VIEWZOOM', text="")
48 layout.separator_spacer()
50 row = layout.row(align=True)
51 if display_mode in {'VIEW_LAYER'}:
53 panel="OUTLINER_PT_filter",
57 elif display_mode in {'LIBRARIES', 'ORPHAN_DATA'}:
58 row.prop(space, "use_filter_id_type", text="", icon='FILTER')
59 sub = row.row(align=True)
60 sub.active = space.use_filter_id_type
61 sub.prop(space, "filter_id_type", text="", icon_only=True)
63 if display_mode == 'VIEW_LAYER':
64 layout.operator("outliner.collection_new", text="", icon='GROUP').nested = True
66 elif display_mode == 'ORPHAN_DATA':
67 layout.operator("outliner.orphans_purge", text="Purge")
69 elif space.display_mode == 'DATA_API':
72 row = layout.row(align=True)
73 row.operator("outliner.keyingset_add_selected", icon='ADD', text="")
74 row.operator("outliner.keyingset_remove_selected", icon='REMOVE', text="")
78 row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
80 row = layout.row(align=True)
81 row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
82 row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
85 row.label(text="No Keying Set Active")
88 class OUTLINER_MT_editor_menus(Menu):
89 bl_idname = "OUTLINER_MT_editor_menus"
92 def draw(self, context):
94 space = context.space_data
96 if space.display_mode == 'DATA_API':
97 layout.menu("OUTLINER_MT_edit_datablocks")
100 class OUTLINER_MT_context(Menu):
101 bl_label = "Outliner"
103 def draw(self, context):
106 layout.menu("OUTLINER_MT_context_view")
110 layout.menu("INFO_MT_area")
113 class OUTLINER_MT_context_view(Menu):
116 def draw(self, context):
119 layout.operator("outliner.show_active")
123 layout.operator("outliner.show_hierarchy")
124 layout.operator("outliner.show_one_level", text="Show One Level")
125 layout.operator("outliner.show_one_level", text="Hide One Level").open = False
128 class OUTLINER_MT_edit_datablocks(Menu):
131 def draw(self, context):
134 layout.operator("outliner.keyingset_add_selected")
135 layout.operator("outliner.keyingset_remove_selected")
139 layout.operator("outliner.drivers_add_selected")
140 layout.operator("outliner.drivers_delete_selected")
143 class OUTLINER_MT_collection_view_layer(Menu):
144 bl_label = "View Layer"
146 def draw(self, context):
149 layout.operator("outliner.collection_exclude_set")
150 layout.operator("outliner.collection_exclude_clear")
152 if context.engine == 'CYCLES':
153 layout.operator("outliner.collection_indirect_only_set")
154 layout.operator("outliner.collection_indirect_only_clear")
156 layout.operator("outliner.collection_holdout_set")
157 layout.operator("outliner.collection_holdout_clear")
160 class OUTLINER_MT_collection_visibility(Menu):
161 bl_label = "Visibility"
163 def draw(self, context):
166 layout.operator("outliner.collection_isolate", text="Isolate")
170 layout.operator("outliner.collection_show", text="Show", icon="HIDE_OFF")
171 layout.operator("outliner.collection_show_inside", text="Show All Inside")
172 layout.operator("outliner.collection_hide", text="Hide", icon="HIDE_ON")
173 layout.operator("outliner.collection_hide_inside", text="Hide All Inside")
177 layout.operator("outliner.collection_enable", text="Enable in Viewports", icon="RESTRICT_VIEW_OFF")
178 layout.operator("outliner.collection_disable", text="Disable in Viewports")
182 layout.operator("outliner.collection_enable_render", text="Enable in Render", icon="RESTRICT_RENDER_OFF")
183 layout.operator("outliner.collection_disable_render", text="Disable in Render")
186 class OUTLINER_MT_collection(Menu):
187 bl_label = "Collection"
189 def draw(self, context):
192 space = context.space_data
194 layout.operator("outliner.collection_new", text="New").nested = True
195 layout.operator("outliner.collection_duplicate", text="Duplicate")
199 layout.operator("outliner.collection_delete", text="Delete", icon="X").hierarchy = False
200 layout.operator("outliner.collection_delete", text="Delete Hierarchy").hierarchy = True
204 layout.operator("outliner.collection_objects_select", text="Select Objects", icon="RESTRICT_SELECT_OFF")
205 layout.operator("outliner.collection_objects_deselect", text="Deselect Objects")
209 layout.operator("outliner.collection_instance", text="Instance to Scene")
211 if space.display_mode != 'VIEW_LAYER':
212 layout.operator("outliner.collection_link", text="Link to Scene")
213 layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK'
217 layout.menu("OUTLINER_MT_collection_visibility")
219 if space.display_mode == 'VIEW_LAYER':
221 layout.menu("OUTLINER_MT_collection_view_layer", icon="RENDERLAYERS")
225 layout.operator_menu_enum("outliner.id_operation", "type", text="ID Data")
229 OUTLINER_MT_context.draw(self, context)
232 class OUTLINER_MT_collection_new(Menu):
233 bl_label = "Collection"
235 def draw(self, context):
238 layout.operator("outliner.collection_new", text="New").nested = False
242 OUTLINER_MT_context.draw(self, context)
245 class OUTLINER_MT_object(Menu):
248 def draw(self, context):
251 space = context.space_data
252 obj = context.active_object
253 object_mode = 'OBJECT' if obj is None else obj.mode
255 layout.operator("outliner.object_operation", text="Delete", icon="X").type = 'DELETE'
257 if space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection:
258 layout.operator("outliner.object_operation", text="Delete Hierarchy").type = 'DELETE_HIERARCHY'
262 layout.operator("outliner.object_operation", text="Select", icon="RESTRICT_SELECT_OFF").type = 'SELECT'
263 layout.operator("outliner.object_operation", text="Select Hierarchy").type = 'SELECT_HIERARCHY'
264 layout.operator("outliner.object_operation", text="Deselect").type = 'DESELECT'
268 if object_mode in {'EDIT', 'POSE'}:
269 name = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode].name
270 layout.operator("outliner.object_operation", text=f"{name:s} Set").type = 'OBJECT_MODE_ENTER'
271 layout.operator("outliner.object_operation", text=f"{name:s} Clear").type = 'OBJECT_MODE_EXIT'
276 if not (space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection):
277 layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK'
280 layout.operator_menu_enum("outliner.id_operation", "type", text="ID Data")
284 OUTLINER_MT_context.draw(self, context)
287 class OUTLINER_PT_filter(Panel):
288 bl_space_type = 'OUTLINER'
289 bl_region_type = 'HEADER'
292 def draw(self, context):
295 space = context.space_data
296 display_mode = space.display_mode
298 layout.prop(space, "use_filter_complete", text="Exact Match Search")
299 layout.prop(space, "use_filter_case_sensitive", text="Case Sensitive Search")
303 if display_mode != 'DATA_API':
304 layout.prop(space, "use_sort_alpha")
305 layout.prop(space, "show_restrict_columns")
308 col = layout.column(align=True)
310 col.prop(space, "use_filter_collection", text="Collections", icon='GROUP')
311 col.prop(space, "use_filter_object", text="Objects", icon='OBJECT_DATAMODE')
313 sub = col.column(align=True)
314 sub.active = space.use_filter_object
317 sub.prop(space, "use_filter_object_mesh", text="Meshes", icon='MESH_DATA')
318 if bpy.data.armatures:
319 sub.prop(space, "use_filter_object_armature", text="Armatures", icon='ARMATURE_DATA')
321 sub.prop(space, "use_filter_object_light", text="Lights", icon='LIGHT_DATA')
323 sub.prop(space, "use_filter_object_camera", text="Cameras", icon='CAMERA_DATA')
325 sub.prop(space, "use_filter_object_empty", text="Empties", icon='EMPTY_DATA')
329 bpy.data.metaballs or
330 bpy.data.lightprobes or
335 sub.prop(space, "use_filter_object_others", text="Others")
337 subsub = sub.column(align=False)
338 subsub.prop(space, "filter_state", text="")
339 subsub.prop(space, "use_filter_object_content", text="Object Contents")
340 subsub.prop(space, "use_filter_children", text="Object Children")
345 OUTLINER_MT_editor_menus,
346 OUTLINER_MT_edit_datablocks,
347 OUTLINER_MT_collection,
348 OUTLINER_MT_collection_new,
349 OUTLINER_MT_collection_visibility,
350 OUTLINER_MT_collection_view_layer,
353 OUTLINER_MT_context_view,
357 if __name__ == "__main__": # only for live edit.
358 from bpy.utils import register_class