19f642684814d15f948b904ac1714e81689d934b
[blender-staging.git] / release / scripts / ui / space_dopesheet.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
21 import bpy
22
23 # used for DopeSheet, NLA, and Graph Editors
24 def dopesheet_filter(layout, context):
25     dopesheet = context.space_data.dopesheet
26     is_nla = context.area.type == 'NLA_EDITOR'
27
28     row = layout.row(align=True)
29     row.prop(dopesheet, "show_only_selected", text="")
30     row.prop(dopesheet, "show_hidden", text="")
31
32     row = layout.row(align=True)
33     row.prop(dopesheet, "show_transforms", text="")
34
35     if is_nla:
36         row.prop(dopesheet, "show_missing_nla", text="")
37
38     row = layout.row(align=True)
39     row.prop(dopesheet, "show_scenes", text="")
40     row.prop(dopesheet, "show_worlds", text="")
41     row.prop(dopesheet, "show_nodes", text="")
42
43     if bpy.data.meshes:
44         row.prop(dopesheet, "show_meshes", text="")
45     if bpy.data.shape_keys:
46         row.prop(dopesheet, "show_shapekeys", text="")
47     if bpy.data.materials:
48         row.prop(dopesheet, "show_materials", text="")
49     if bpy.data.lamps:
50         row.prop(dopesheet, "show_lamps", text="")
51     if bpy.data.textures:
52         row.prop(dopesheet, "show_textures", text="")
53     if bpy.data.cameras:
54         row.prop(dopesheet, "show_cameras", text="")
55     if bpy.data.curves:
56         row.prop(dopesheet, "show_curves", text="")
57     if bpy.data.metaballs:
58         row.prop(dopesheet, "show_metaballs", text="")
59     if bpy.data.armatures:
60         row.prop(dopesheet, "show_armatures", text="")
61     if bpy.data.particles:
62         row.prop(dopesheet, "show_particles", text="")
63
64     if bpy.data.groups:
65         row = layout.row(align=True)
66         row.prop(dopesheet, "show_only_group_objects", text="")
67         if dopesheet.show_only_group_objects:
68             row.prop(dopesheet, "filter_group", text="")
69
70
71 class DOPESHEET_HT_header(bpy.types.Header):
72     bl_space_type = 'DOPESHEET_EDITOR'
73
74     def draw(self, context):
75         layout = self.layout
76
77         st = context.space_data
78
79         row = layout.row(align=True)
80         row.template_header()
81
82         if context.area.show_menus:
83             sub = row.row(align=True)
84
85             sub.menu("DOPESHEET_MT_view")
86             sub.menu("DOPESHEET_MT_select")
87
88             if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None):
89                 sub.menu("DOPESHEET_MT_channel")
90             elif st.mode == 'GPENCIL':
91                 # gpencil Channel menu
92                 pass
93
94             if st.mode != 'GPENCIL':
95                 sub.menu("DOPESHEET_MT_key")
96
97         layout.prop(st, "mode", text="")
98         layout.prop(st.dopesheet, "show_summary", text="Summary")
99
100         if st.mode == 'DOPESHEET':
101             dopesheet_filter(layout, context)
102
103         elif st.mode == 'ACTION':
104             layout.template_ID(st, "action", new="action.new")
105
106         if st.mode != 'GPENCIL':
107             layout.prop(st, "auto_snap", text="")
108
109         row = layout.row(align=True)
110         row.operator("action.copy", text="", icon='COPYDOWN')
111         row.operator("action.paste", text="", icon='PASTEDOWN')
112
113
114 class DOPESHEET_MT_view(bpy.types.Menu):
115     bl_label = "View"
116
117     def draw(self, context):
118         layout = self.layout
119
120         st = context.space_data
121
122         layout.column()
123
124         layout.prop(st, "use_realtime_update")
125         layout.prop(st, "show_frame_indicator")
126         layout.prop(st, "show_sliders")
127         layout.prop(st, "use_auto_merge_keyframes")
128         layout.prop(st, "use_marker_sync")
129
130         if st.show_seconds:
131             layout.operator("anim.time_toggle", text="Show Frames")
132         else:
133             layout.operator("anim.time_toggle", text="Show Seconds")
134
135         layout.separator()
136         layout.operator("anim.previewrange_set")
137         layout.operator("anim.previewrange_clear")
138         layout.operator("action.previewrange_set")
139
140         layout.separator()
141         layout.operator("action.frame_jump")
142         layout.operator("action.view_all")
143
144         layout.separator()
145         layout.operator("screen.area_dupli")
146         layout.operator("screen.screen_full_area")
147
148
149 class DOPESHEET_MT_select(bpy.types.Menu):
150     bl_label = "Select"
151
152     def draw(self, context):
153         layout = self.layout
154
155         layout.column()
156         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
157         layout.operator("action.select_all_toggle")
158         layout.operator("action.select_all_toggle", text="Invert Selection").invert = True
159
160         layout.separator()
161         layout.operator("action.select_border")
162         layout.operator("action.select_border", text="Border Axis Range").axis_range = True
163
164         layout.separator()
165         layout.operator("action.select_column", text="Columns on Selected Keys").mode = 'KEYS'
166         layout.operator("action.select_column", text="Column on Current Frame").mode = 'CFRA'
167
168         layout.operator("action.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
169         layout.operator("action.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
170
171         layout.separator()
172         layout.operator("action.select_more")
173         layout.operator("action.select_less")
174
175         layout.separator()
176         layout.operator("action.select_linked")
177
178
179 class DOPESHEET_MT_channel(bpy.types.Menu):
180     bl_label = "Channel"
181
182     def draw(self, context):
183         layout = self.layout
184
185         layout.operator_context = 'INVOKE_REGION_CHANNELS'
186
187         layout.column()
188         layout.operator("anim.channels_delete")
189
190         layout.separator()
191         layout.operator("anim.channels_setting_toggle")
192         layout.operator("anim.channels_setting_enable")
193         layout.operator("anim.channels_setting_disable")
194
195         layout.separator()
196         layout.operator("anim.channels_editable_toggle")
197
198         layout.separator()
199         layout.operator("anim.channels_expand")
200         layout.operator("anim.channels_collapse")
201
202
203 class DOPESHEET_MT_key(bpy.types.Menu):
204     bl_label = "Key"
205
206     def draw(self, context):
207         layout = self.layout
208
209         layout.column()
210         layout.menu("DOPESHEET_MT_key_transform", text="Transform")
211
212         layout.operator_menu_enum("action.snap", "type", text="Snap")
213         layout.operator_menu_enum("action.mirror", "type", text="Mirror")
214
215         layout.separator()
216         layout.operator("action.keyframe_insert")
217
218         layout.separator()
219         layout.operator("action.duplicate")
220         layout.operator("action.delete")
221
222         layout.separator()
223         layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
224         layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
225         layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
226         layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
227
228         layout.separator()
229         layout.operator("action.clean")
230         layout.operator("action.sample")
231
232         layout.separator()
233         layout.operator("action.copy")
234         layout.operator("action.paste")
235
236
237 class DOPESHEET_MT_key_transform(bpy.types.Menu):
238     bl_label = "Transform"
239
240     def draw(self, context):
241         layout = self.layout
242
243         layout.column()
244         layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE'
245         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
246         layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE'
247         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
248
249
250 def register():
251     pass
252
253
254 def unregister():
255     pass
256
257 if __name__ == "__main__":
258     register()