Cleanup: unused imports
[blender.git] / release / scripts / startup / bl_ui / space_graph.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 from bpy.types import Header, Menu, Panel
22 from .space_dopesheet import (
23     DopesheetFilterPopoverBase,
24     dopesheet_filter,
25 )
26
27
28 class GRAPH_HT_header(Header):
29     bl_space_type = 'GRAPH_EDITOR'
30
31     def draw(self, context):
32         layout = self.layout
33         tool_settings = context.tool_settings
34
35         st = context.space_data
36
37         row = layout.row(align=True)
38         row.template_header()
39
40         # Now a exposed as a sub-space type
41         # layout.prop(st, "mode", text="")
42
43         GRAPH_MT_editor_menus.draw_collapsible(context, layout)
44
45         row = layout.row(align=True)
46         row.prop(st, "use_normalization", icon='NORMALIZE_FCURVES', text="Normalize", toggle=True)
47         sub = row.row(align=True)
48         sub.active = st.use_normalization
49         sub.prop(st, "use_auto_normalization", icon='FILE_REFRESH', text="", toggle=True)
50
51         layout.separator_spacer()
52
53         dopesheet_filter(layout, context)
54
55         row = layout.row(align=True)
56         if st.has_ghost_curves:
57             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
58         else:
59             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
60
61         layout.popover(
62             panel="GRAPH_PT_filters",
63             text="",
64             icon='FILTER',
65         )
66
67         layout.prop(st, "pivot_point", icon_only=True)
68
69         layout.prop(st, "auto_snap", text="")
70
71         row = layout.row(align=True)
72         row.prop(tool_settings, "use_proportional_fcurve", text="", icon_only=True)
73         sub = row.row(align=True)
74         sub.active = tool_settings.use_proportional_fcurve
75         sub.prop(tool_settings, "proportional_edit_falloff", text="", icon_only=True)
76
77
78 class GRAPH_PT_filters(DopesheetFilterPopoverBase, Panel):
79     bl_space_type = 'GRAPH_EDITOR'
80     bl_region_type = 'HEADER'
81     bl_label = "Filters"
82
83     def draw(self, context):
84         layout = self.layout
85
86         DopesheetFilterPopoverBase.draw_generic_filters(context, layout)
87         layout.separator()
88         DopesheetFilterPopoverBase.draw_search_filters(context, layout)
89         layout.separator()
90         DopesheetFilterPopoverBase.draw_standard_filters(context, layout)
91
92
93 class GRAPH_MT_editor_menus(Menu):
94     bl_idname = "GRAPH_MT_editor_menus"
95     bl_label = ""
96
97     def draw(self, context):
98         layout = self.layout
99         layout.menu("GRAPH_MT_view")
100         layout.menu("GRAPH_MT_select")
101         layout.menu("GRAPH_MT_marker")
102         layout.menu("GRAPH_MT_channel")
103         layout.menu("GRAPH_MT_key")
104
105
106 class GRAPH_MT_view(Menu):
107     bl_label = "View"
108
109     def draw(self, context):
110         layout = self.layout
111
112         st = context.space_data
113
114         layout.operator("graph.properties", icon='MENU_PANEL')
115         layout.separator()
116
117         layout.prop(st, "use_realtime_update")
118         layout.prop(st, "show_frame_indicator")
119         layout.prop(st, "show_cursor")
120         layout.prop(st, "show_sliders")
121         layout.prop(st, "show_group_colors")
122         layout.prop(st, "show_marker_lines")
123         layout.prop(st, "use_auto_merge_keyframes")
124
125         layout.separator()
126         layout.prop(st, "use_beauty_drawing")
127
128         layout.separator()
129
130         layout.prop(st, "show_handles")
131
132         layout.prop(st, "use_only_selected_curves_handles")
133         layout.prop(st, "use_only_selected_keyframe_handles")
134
135         layout.prop(st, "show_seconds")
136         layout.prop(st, "show_locked_time")
137
138         layout.separator()
139         layout.operator("anim.previewrange_set")
140         layout.operator("anim.previewrange_clear")
141         layout.operator("graph.previewrange_set")
142
143         layout.separator()
144         layout.operator("graph.view_all")
145         layout.operator("graph.view_selected")
146         layout.operator("graph.view_frame")
147
148         # Add this to show key-binding (reverse action in dope-sheet).
149         layout.separator()
150         props = layout.operator("wm.context_set_enum", text="Toggle Dope Sheet")
151         props.data_path = "area.type"
152         props.value = 'DOPESHEET_EDITOR'
153
154         layout.separator()
155         layout.menu("INFO_MT_area")
156
157
158 class GRAPH_MT_select(Menu):
159     bl_label = "Select"
160
161     def draw(self, context):
162         layout = self.layout
163
164         layout.operator("graph.select_all", text="All").action = 'SELECT'
165         layout.operator("graph.select_all", text="None").action = 'DESELECT'
166         layout.operator("graph.select_all", text="Invert").action = 'INVERT'
167
168         layout.separator()
169
170         props = layout.operator("graph.select_box")
171         props.axis_range = False
172         props.include_handles = False
173         props = layout.operator("graph.select_box", text="Border Axis Range")
174         props.axis_range = True
175         props.include_handles = False
176         props = layout.operator("graph.select_box", text="Border (Include Handles)")
177         props.axis_range = False
178         props.include_handles = True
179
180         layout.operator("graph.select_circle")
181
182         layout.separator()
183         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
184         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
185
186         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
187         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
188
189         layout.separator()
190         props = layout.operator("graph.select_leftright", text="Before Current Frame")
191         props.extend = False
192         props.mode = 'LEFT'
193         props = layout.operator("graph.select_leftright", text="After Current Frame")
194         props.extend = False
195         props.mode = 'RIGHT'
196
197         layout.separator()
198         layout.operator("graph.select_more")
199         layout.operator("graph.select_less")
200
201         layout.separator()
202         layout.operator("graph.select_linked")
203
204
205 class GRAPH_MT_marker(Menu):
206     bl_label = "Marker"
207
208     def draw(self, context):
209         layout = self.layout
210
211         from .space_time import marker_menu_generic
212         marker_menu_generic(layout, context)
213
214         # TODO: pose markers for action edit mode only?
215
216
217 class GRAPH_MT_channel(Menu):
218     bl_label = "Channel"
219
220     def draw(self, context):
221         layout = self.layout
222
223         layout.operator_context = 'INVOKE_REGION_CHANNELS'
224
225         layout.operator("anim.channels_delete")
226         if context.space_data.mode == 'DRIVERS':
227             layout.operator("graph.driver_delete_invalid")
228
229         layout.separator()
230         layout.operator("anim.channels_group")
231         layout.operator("anim.channels_ungroup")
232
233         layout.separator()
234         layout.operator_menu_enum("anim.channels_setting_toggle", "type")
235         layout.operator_menu_enum("anim.channels_setting_enable", "type")
236         layout.operator_menu_enum("anim.channels_setting_disable", "type")
237
238         layout.separator()
239         layout.operator("anim.channels_editable_toggle")
240         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
241
242         layout.separator()
243         layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
244         layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
245         layout.operator("graph.reveal")
246
247         layout.separator()
248         layout.operator("anim.channels_expand")
249         layout.operator("anim.channels_collapse")
250
251         layout.separator()
252         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
253
254         layout.separator()
255         layout.operator("anim.channels_fcurves_enable")
256
257
258 class GRAPH_MT_key(Menu):
259     bl_label = "Key"
260
261     def draw(self, context):
262         layout = self.layout
263
264         layout.menu("GRAPH_MT_key_transform", text="Transform")
265
266         layout.operator_menu_enum("graph.snap", "type", text="Snap")
267         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
268
269         layout.separator()
270         layout.operator_menu_enum("graph.keyframe_insert", "type")
271         layout.operator_menu_enum("graph.fmodifier_add", "type")
272         layout.operator("graph.sound_bake")
273
274         layout.separator()
275         layout.operator("graph.frame_jump")
276
277         layout.separator()
278         layout.operator("graph.copy")
279         layout.operator("graph.paste")
280         layout.operator("graph.paste", text="Paste Flipped").flipped = True
281         layout.operator("graph.duplicate_move")
282         layout.operator("graph.delete")
283
284         layout.separator()
285         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
286         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
287         layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
288
289         layout.separator()
290         layout.operator("graph.clean").channels = False
291         layout.operator("graph.clean", text="Clean Channels").channels = True
292         layout.operator("graph.smooth")
293         layout.operator("graph.sample")
294         layout.operator("graph.bake")
295
296         layout.separator()
297         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
298
299
300 class GRAPH_MT_key_transform(Menu):
301     bl_label = "Transform"
302
303     def draw(self, context):
304         layout = self.layout
305
306         layout.operator("transform.translate", text="Move")
307         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
308         layout.operator("transform.rotate", text="Rotate")
309         layout.operator("transform.resize", text="Scale")
310
311
312 class GRAPH_MT_delete(Menu):
313     bl_label = "Delete"
314
315     def draw(self, context):
316         layout = self.layout
317
318         layout.operator("graph.delete")
319
320         layout.separator()
321
322         layout.operator("graph.clean").channels = False
323         layout.operator("graph.clean", text="Clean Channels").channels = True
324
325
326 class GRAPH_MT_context_menu(Menu):
327     bl_label = "F-Curve Context Menu"
328
329     def draw(self, context):
330         layout = self.layout
331
332         layout.operator("graph.copy", text="Copy")
333         layout.operator("graph.paste", text="Paste")
334         layout.operator("graph.paste", text="Paste Flipped").flipped = True
335
336         layout.separator()
337
338         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
339         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
340         layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
341
342         layout.separator()
343
344         layout.operator("graph.keyframe_insert").type = 'SEL'
345         layout.operator("graph.duplicate_move")
346         layout.operator("graph.delete")
347
348         layout.separator()
349
350         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
351         layout.operator_menu_enum("graph.snap", "type", text="Snap")
352
353
354 class GRAPH_MT_pivot_pie(Menu):
355     bl_label = "Pivot Point"
356
357     def draw(self, context):
358         layout = self.layout
359         pie = layout.menu_pie()
360
361         pie.prop_enum(context.space_data, "pivot_point", value='BOUNDING_BOX_CENTER')
362         pie.prop_enum(context.space_data, "pivot_point", value='CURSOR')
363         pie.prop_enum(context.space_data, "pivot_point", value='INDIVIDUAL_ORIGINS')
364
365
366 class GRAPH_MT_snap_pie(Menu):
367     bl_label = "Snap"
368
369     def draw(self, context):
370         layout = self.layout
371         pie = layout.menu_pie()
372
373         pie.operator("graph.snap", text="Current Frame").type = 'CFRA'
374         pie.operator("graph.snap", text="Cursor Value").type = 'VALUE'
375         pie.operator("graph.snap", text="Nearest Frame").type = 'NEAREST_FRAME'
376         pie.operator("graph.snap", text="Nearest Second").type = 'NEAREST_SECOND'
377         pie.operator("graph.snap", text="Nearest Marker").type = 'NEAREST_MARKER'
378         pie.operator("graph.snap", text="Flatten Handles").type = 'HORIZONTAL'
379
380
381 class GRAPH_MT_channel_context_menu(Menu):
382     bl_label = "F-Curve Channel Context Menu"
383
384     def draw(self, context):
385         layout = self.layout
386         st = context.space_data
387
388         layout.separator()
389         layout.operator("anim.channels_setting_enable", text="Mute Channels").type = 'MUTE'
390         layout.operator("anim.channels_setting_disable", text="Unmute Channels").type = 'MUTE'
391         layout.separator()
392         layout.operator("anim.channels_setting_enable", text="Protect Channels").type = 'PROTECT'
393         layout.operator("anim.channels_setting_disable", text="Unprotect Channels").type = 'PROTECT'
394
395         layout.separator()
396         layout.operator("anim.channels_group")
397         layout.operator("anim.channels_ungroup")
398
399         layout.separator()
400         layout.operator("anim.channels_editable_toggle")
401         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
402
403         layout.separator()
404         layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
405         layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
406         layout.operator("graph.reveal")
407
408         layout.separator()
409         layout.operator("anim.channels_expand")
410         layout.operator("anim.channels_collapse")
411
412         layout.separator()
413         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
414
415         layout.separator()
416
417         layout.operator("anim.channels_delete")
418         if st.mode == 'DRIVERS':
419             layout.operator("graph.driver_delete_invalid")
420
421
422 classes = (
423     GRAPH_HT_header,
424     GRAPH_MT_editor_menus,
425     GRAPH_MT_view,
426     GRAPH_MT_select,
427     GRAPH_MT_marker,
428     GRAPH_MT_channel,
429     GRAPH_MT_key,
430     GRAPH_MT_key_transform,
431     GRAPH_MT_delete,
432     GRAPH_MT_context_menu,
433     GRAPH_MT_channel_context_menu,
434     GRAPH_MT_pivot_pie,
435     GRAPH_MT_snap_pie,
436     GRAPH_PT_filters,
437 )
438
439 if __name__ == "__main__":  # only for live edit.
440     from bpy.utils import register_class
441     for cls in classes:
442         register_class(cls)