change python scripts so modules which register with blender have a register() functi...
[blender.git] / release / scripts / 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
22
23 class OUTLINER_HT_header(bpy.types.Header):
24     bl_space_type = 'OUTLINER'
25
26     def draw(self, context):
27         layout = self.layout
28
29         space = context.space_data
30         scene = context.scene
31         ks = context.scene.active_keying_set
32
33         row = layout.row(align=True)
34         row.template_header()
35
36         if context.area.show_menus:
37             sub = row.row(align=True)
38             sub.menu("OUTLINER_MT_view")
39             if space.display_mode == 'DATABLOCKS':
40                 sub.menu("OUTLINER_MT_edit_datablocks")
41
42         layout.prop(space, "display_mode", text="")
43
44         layout.separator()
45
46         if space.display_mode == 'DATABLOCKS':
47             row = layout.row(align=True)
48             row.operator("outliner.keyingset_add_selected", icon='ZOOMIN', text="")
49             row.operator("outliner.keyingset_remove_selected", icon='ZOOMOUT', text="")
50
51             if ks:
52                 row = layout.row(align=False)
53                 row.prop_object(scene, "active_keying_set", scene, "keying_sets", text="")
54
55                 row = layout.row(align=True)
56                 row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
57                 row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
58             else:
59                 row = layout.row(align=False)
60                 row.label(text="No Keying Set active")
61
62
63 class OUTLINER_MT_view(bpy.types.Menu):
64     bl_label = "View"
65
66     def draw(self, context):
67         layout = self.layout
68
69         space = context.space_data
70
71         col = layout.column()
72         if space.display_mode not in ('DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'):
73             col.prop(space, "show_restriction_columns")
74             col.separator()
75             col.operator("outliner.show_active")
76
77         col.operator("outliner.show_one_level")
78         col.operator("outliner.show_hierarchy")
79
80         layout.separator()
81
82         layout.operator("screen.area_dupli")
83         layout.operator("screen.screen_full_area")
84
85
86 class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
87     bl_label = "Edit"
88
89     def draw(self, context):
90         layout = self.layout
91
92         col = layout.column()
93
94         col.operator("outliner.keyingset_add_selected")
95         col.operator("outliner.keyingset_remove_selected")
96
97         col.separator()
98
99         col.operator("outliner.drivers_add_selected")
100         col.operator("outliner.drivers_delete_selected")
101
102
103 classes = [
104     OUTLINER_HT_header,
105     OUTLINER_MT_view,
106     OUTLINER_MT_edit_datablocks]
107
108
109 def register():
110     register = bpy.types.register
111     for cls in classes:
112         register(cls)
113
114 def unregister():
115     unregister = bpy.types.unregister
116     for cls in classes:
117         unregister(cls)