e2aeb92f19ddbb0e68f90240cc31fa3ce6779202
[blender-staging.git] / release / scripts / ui / space_outliner.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6
7 import bpy
8
9 class OUTLINER_HT_header(bpy.types.Header):
10     bl_space_type = 'OUTLINER'
11
12     def draw(self, context):
13         layout = self.layout
14
15         space = context.space_data
16         scene = context.scene
17         ks = context.scene.active_keying_set
18
19         row = layout.row(align=True)
20         row.template_header()
21
22         if context.area.show_menus:
23             sub = row.row(align=True)
24             sub.itemM("OUTLINER_MT_view")
25             if space.display_mode == 'DATABLOCKS':
26                 sub.itemM("OUTLINER_MT_edit_datablocks")
27
28         layout.itemR(space, "display_mode", text="")
29
30         layout.itemS()
31
32         if space.display_mode == 'DATABLOCKS':
33             row = layout.row(align=True)
34             row.itemO("outliner.keyingset_add_selected", icon='ICON_ZOOMIN', text="")
35             row.itemO("outliner.keyingset_remove_selected", icon='ICON_ZOOMOUT', text="")
36
37             if ks:
38                 row = layout.row(align=False)
39                 row.item_pointerR(scene, "active_keying_set", scene, "keying_sets", text="")
40
41                 row = layout.row(align=True)
42                 row.itemO("anim.insert_keyframe", text="", icon='ICON_KEY_HLT')
43                 row.itemO("anim.delete_keyframe", text="", icon='ICON_KEY_DEHLT')
44             else:
45                 row = layout.row(align=False)
46                 row.itemL(text="No Keying Set active")
47
48 class OUTLINER_MT_view(bpy.types.Menu):
49     bl_label = "View"
50
51     def draw(self, context):
52         layout = self.layout
53
54         space = context.space_data
55
56         col = layout.column()
57         if space.display_mode not in ('DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'):
58             col.itemR(space, "show_restriction_columns")
59             col.itemS()
60             col.itemO("outliner.show_active")
61
62         col.itemO("outliner.show_one_level")
63         col.itemO("outliner.show_hierarchy")
64
65 class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
66     bl_label = "Edit"
67
68     def draw(self, context):
69         layout = self.layout
70
71         col = layout.column()
72
73         col.itemO("outliner.keyingset_add_selected")
74         col.itemO("outliner.keyingset_remove_selected")
75
76         col.itemS()
77
78         col.itemO("outliner.drivers_add_selected")
79         col.itemO("outliner.drivers_delete_selected")
80
81 bpy.types.register(OUTLINER_HT_header)
82 bpy.types.register(OUTLINER_MT_view)
83 bpy.types.register(OUTLINER_MT_edit_datablocks)