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