Outliner Live-Search Bugfixes:
[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             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, "display_filter", 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_object(scene, "active_keying_set", 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_restriction_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 class OUTLINER_MT_search(bpy.types.Menu):
89     bl_label = "Search"
90
91     def draw(self, context):
92         layout = self.layout
93
94         space = context.space_data
95
96         col = layout.column()
97
98         col.prop(space, "match_case_sensitive")
99         col.prop(space, "match_complete")
100
101 class OUTLINER_MT_edit_datablocks(bpy.types.Menu):
102     bl_label = "Edit"
103
104     def draw(self, context):
105         layout = self.layout
106
107         col = layout.column()
108
109         col.operator("outliner.keyingset_add_selected")
110         col.operator("outliner.keyingset_remove_selected")
111
112         col.separator()
113
114         col.operator("outliner.drivers_add_selected")
115         col.operator("outliner.drivers_delete_selected")
116
117
118 classes = [
119     OUTLINER_HT_header,
120     OUTLINER_MT_view,
121         OUTLINER_MT_search,
122     OUTLINER_MT_edit_datablocks]
123
124
125 def register():
126     register = bpy.types.register
127     for cls in classes:
128         register(cls)
129
130
131 def unregister():
132     unregister = bpy.types.unregister
133     for cls in classes:
134         unregister(cls)
135
136 if __name__ == "__main__":
137     register()