fix [#26754] Live Edit and Editing UI scripts don't work
[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
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.keying_sets.active
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             sub.menu("OUTLINER_MT_search")
40             if space.display_mode == 'DATABLOCKS':
41                 sub.menu("OUTLINER_MT_edit_datablocks")
42
43         layout.prop(space, "display_mode", text="")
44
45         layout.prop(space, "filter_text", icon='VIEWZOOM', text="")
46
47         layout.separator()
48
49         if space.display_mode == 'DATABLOCKS':
50             row = layout.row(align=True)
51             row.operator("outliner.keyingset_add_selected", icon='ZOOMIN', text="")
52             row.operator("outliner.keyingset_remove_selected", icon='ZOOMOUT', text="")
53
54             if ks:
55                 row = layout.row(align=False)
56                 row.prop_search(scene.keying_sets, "active", scene, "keying_sets", text="")
57
58                 row = layout.row(align=True)
59                 row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
60                 row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
61             else:
62                 row = layout.row(align=False)
63                 row.label(text="No Keying Set active")
64
65
66 class OUTLINER_MT_view(bpy.types.Menu):
67     bl_label = "View"
68
69     def draw(self, context):
70         layout = self.layout
71
72         space = context.space_data
73
74         col = layout.column()
75         if space.display_mode not in {'DATABLOCKS', 'USER_PREFERENCES', 'KEYMAPS'}:
76             col.prop(space, "show_restrict_columns")
77             col.separator()
78             col.operator("outliner.show_active")
79
80         col.operator("outliner.show_one_level")
81         col.operator("outliner.show_hierarchy")
82
83         layout.separator()
84
85         layout.operator("screen.area_dupli")
86         layout.operator("screen.screen_full_area")
87
88
89 class OUTLINER_MT_search(bpy.types.Menu):
90     bl_label = "Search"
91
92     def draw(self, context):
93         layout = self.layout
94
95         space = context.space_data
96
97         col = layout.column()
98
99         col.prop(space, "use_filter_case_sensitive")
100         col.prop(space, "use_filter_complete")
101
102
103 class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
104     bl_label = "Edit"
105
106     def draw(self, context):
107         layout = self.layout
108
109         col = layout.column()
110
111         col.operator("outliner.keyingset_add_selected")
112         col.operator("outliner.keyingset_remove_selected")
113
114         col.separator()
115
116         col.operator("outliner.drivers_add_selected")
117         col.operator("outliner.drivers_delete_selected")
118
119 if __name__ == "__main__":  # only for live edit.
120     bpy.utils.register_module(__name__)