6ff5498cb4aefc0b68dc581db7ee58fef01d19dc
[blender-staging.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         scene = context.scene
32         ks = context.scene.keying_sets.active
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
38
39         layout.prop(space, "display_mode", text="")
40
41         layout.prop(space, "filter_text", icon='VIEWZOOM', text="")
42
43         layout.separator()
44
45         if space.display_mode == 'DATABLOCKS':
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         elif space.display_mode == 'ORPHAN_DATA':
61             layout.operator("outliner.orphans_purge")
62
63
64 class OUTLINER_MT_editor_menus(Menu):
65     bl_idname = "OUTLINER_MT_editor_menus"
66     bl_label = ""
67
68     def draw(self, context):
69         self.draw_menus(self.layout, context)
70
71     @staticmethod
72     def draw_menus(layout, context):
73         space = context.space_data
74
75         layout.menu("OUTLINER_MT_view")
76         layout.menu("OUTLINER_MT_search")
77
78         if space.display_mode == 'DATABLOCKS':
79             layout.menu("OUTLINER_MT_edit_datablocks")
80
81
82 class OUTLINER_MT_view(Menu):
83     bl_label = "View"
84
85     def draw(self, context):
86         layout = self.layout
87
88         space = context.space_data
89
90         if space.display_mode not in {'DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'}:
91             layout.prop(space, "use_sort_alpha")
92             layout.prop(space, "show_restrict_columns")
93             layout.separator()
94             layout.operator("outliner.show_active")
95
96         layout.operator("outliner.show_one_level", text="Show One Level")
97         layout.operator("outliner.show_one_level", text="Hide One Level").open = False
98         layout.operator("outliner.show_hierarchy")
99
100         layout.separator()
101
102         layout.operator("screen.area_dupli")
103         layout.operator("screen.screen_full_area")
104         layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
105
106
107 class OUTLINER_MT_search(Menu):
108     bl_label = "Search"
109
110     def draw(self, context):
111         layout = self.layout
112
113         space = context.space_data
114
115         layout.prop(space, "use_filter_case_sensitive")
116         layout.prop(space, "use_filter_complete")
117
118
119 class OUTLINER_MT_edit_datablocks(Menu):
120     bl_label = "Edit"
121
122     def draw(self, context):
123         layout = self.layout
124
125         layout.operator("outliner.keyingset_add_selected")
126         layout.operator("outliner.keyingset_remove_selected")
127
128         layout.separator()
129
130         layout.operator("outliner.drivers_add_selected")
131         layout.operator("outliner.drivers_delete_selected")
132
133
134 classes = (
135     OUTLINER_HT_header,
136     OUTLINER_MT_edit_datablocks,
137     OUTLINER_MT_editor_menus,
138     OUTLINER_MT_search,
139     OUTLINER_MT_view,
140 )
141
142 if __name__ == "__main__":  # only for live edit.
143     from bpy.utils import register_class
144     for cls in classes:
145         register_class(cls)