Outliner: Remove User Preferences
[blender.git] / release / scripts / startup / bl_ui / space_outliner.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu
22
23
24 class OUTLINER_HT_header(Header):
25     bl_space_type = 'OUTLINER'
26
27     def draw(self, context):
28         layout = self.layout
29
30         space = context.space_data
31         display_mode = space.display_mode
32         scene = context.scene
33         ks = context.scene.keying_sets.active
34         support_filters = display_mode in {'COLLECTIONS', 'VIEW_LAYER'}
35
36         row = layout.row(align=True)
37         row.template_header()
38
39         OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
40
41         layout.prop(space, "display_mode", text="")
42
43         if space.display_mode == 'DATABLOCKS':
44             layout.separator()
45
46             row = layout.row(align=True)
47             row.operator("outliner.keyingset_add_selected", icon='ZOOMIN', text="")
48             row.operator("outliner.keyingset_remove_selected", icon='ZOOMOUT', text="")
49
50             if ks:
51                 row = layout.row()
52                 row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
53
54                 row = layout.row(align=True)
55                 row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
56                 row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
57             else:
58                 row = layout.row()
59                 row.label(text="No Keying Set Active")
60
61         row = layout.row(align=True)
62         row.prop(space, "use_filter_search", text="")
63         if space.use_filter_search:
64             row.prop(space, "filter_text", text="")
65             row.prop(space, "use_filter_complete", text="")
66             row.prop(space, "use_filter_case_sensitive", text="")
67
68         if support_filters:
69             row.separator()
70
71             row.prop(space, "use_filters", text="")
72             if space.use_filters:
73                 row.separator()
74                 row.prop(space, "use_filter_collection", text="")
75                 row.prop(space, "use_filter_object", text="")
76                 sub = row.row(align=True)
77                 sub.active = space.use_filter_object
78                 sub.prop(space, "use_filter_object_content", text="")
79                 sub.prop(space, "use_filter_children", text="")
80
81                 sub.separator()
82                 sub.prop(space, "use_filter_object_type", text="")
83
84                 if space.use_filter_object_type:
85                     if bpy.data.meshes:
86                         sub.prop(space, "use_filter_object_mesh", text="")
87                     if bpy.data.armatures:
88                         sub.prop(space, "use_filter_object_armature", text="")
89                     if bpy.data.lamps:
90                         sub.prop(space, "use_filter_object_lamp", text="")
91                     if bpy.data.cameras:
92                         sub.prop(space, "use_filter_object_camera", text="")
93
94                     sub.prop(space, "use_filter_object_empty", text="")
95
96                     if bpy.data.curves or \
97                        bpy.data.metaballs or \
98                        bpy.data.lightprobes or \
99                        bpy.data.lattices or \
100                        bpy.data.fonts or bpy.data.speakers:
101                         sub.prop(space, "use_filter_object_others", text="")
102
103                 sub.separator()
104                 sub.prop(space, "use_filter_object_state", text="")
105
106                 if space.use_filter_object_state:
107                     sub.prop(space, "filter_state", text="", expand=True)
108
109
110 class OUTLINER_MT_editor_menus(Menu):
111     bl_idname = "OUTLINER_MT_editor_menus"
112     bl_label = ""
113
114     def draw(self, context):
115         self.draw_menus(self.layout, context)
116
117     @staticmethod
118     def draw_menus(layout, context):
119         space = context.space_data
120
121         layout.menu("OUTLINER_MT_view")
122
123         if space.display_mode == 'DATABLOCKS':
124             layout.menu("OUTLINER_MT_edit_datablocks")
125
126         elif space.display_mode == 'ORPHAN_DATA':
127             layout.menu("OUTLINER_MT_edit_orphan_data")
128
129         elif space.display_mode == 'VIEW_LAYER':
130             layout.menu("OUTLINER_MT_edit_view_layer")
131
132
133 class OUTLINER_MT_view(Menu):
134     bl_label = "View"
135
136     def draw(self, context):
137         layout = self.layout
138
139         space = context.space_data
140
141         if space.display_mode != 'DATABLOCKS':
142             layout.prop(space, "use_sort_alpha")
143             layout.prop(space, "show_restrict_columns")
144             layout.separator()
145             layout.operator("outliner.show_active")
146
147         layout.operator("outliner.show_one_level", text="Show One Level")
148         layout.operator("outliner.show_one_level", text="Hide One Level").open = False
149         layout.operator("outliner.show_hierarchy")
150
151         layout.separator()
152
153         layout.operator("screen.area_dupli")
154         layout.operator("screen.screen_full_area")
155         layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
156
157
158 class OUTLINER_MT_edit_view_layer(Menu):
159     bl_label = "Edit"
160
161     def draw(self, context):
162         layout = self.layout
163
164         layout.operator("outliner.collection_link", icon='LINKED')
165         layout.operator("outliner.collection_new", icon='NEW')
166
167
168 class OUTLINER_MT_edit_datablocks(Menu):
169     bl_label = "Edit"
170
171     def draw(self, context):
172         layout = self.layout
173
174         layout.operator("outliner.keyingset_add_selected")
175         layout.operator("outliner.keyingset_remove_selected")
176
177         layout.separator()
178
179         layout.operator("outliner.drivers_add_selected")
180         layout.operator("outliner.drivers_delete_selected")
181
182
183 class OUTLINER_MT_edit_orphan_data(Menu):
184     bl_label = "Edit"
185
186     def draw(self, context):
187         layout = self.layout
188         layout.operator("outliner.orphans_purge")
189
190
191 class OUTLINER_MT_context_scene_collection(Menu):
192     bl_label = "Collection"
193
194     def draw(self, context):
195         layout = self.layout
196
197         layout.operator("outliner.collection_nested_new", text="New Collection", icon='NEW')
198         layout.operator("outliner.collection_delete_selected", text="Delete Collections", icon='X')
199         layout.separator()
200         layout.operator("outliner.collection_objects_add", text="Add Selected", icon='ZOOMIN')
201         layout.operator("outliner.collection_objects_remove", text="Remove Selected", icon='ZOOMOUT')
202
203
204 classes = (
205     OUTLINER_HT_header,
206     OUTLINER_MT_editor_menus,
207     OUTLINER_MT_view,
208     OUTLINER_MT_edit_view_layer,
209     OUTLINER_MT_edit_datablocks,
210     OUTLINER_MT_edit_orphan_data,
211     OUTLINER_MT_context_scene_collection,
212 )
213
214 if __name__ == "__main__":  # only for live edit.
215     from bpy.utils import register_class
216     for cls in classes:
217         register_class(cls)