5ed58a57e47c8092ea099baab600531aa98b3ec9
[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 import bpy
22 from bpy.types import Header, Menu
23
24
25 class GRAPH_HT_header(Header):
26     bl_space_type = 'GRAPH_EDITOR'
27
28     def draw(self, context):
29         from .space_dopesheet import dopesheet_filter
30
31         layout = self.layout
32         toolsettings = context.tool_settings
33
34         st = context.space_data
35
36         row = layout.row(align=True)
37         row.template_header()
38
39         GRAPH_MT_editor_menus.draw_collapsible(context, layout)
40
41         layout.prop(st, "mode", text="")
42
43         dopesheet_filter(layout, context)
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         row = layout.row(align=True)
52
53         row.prop(toolsettings, "use_proportional_fcurve",
54                  text="", icon_only=True)
55         if toolsettings.use_proportional_fcurve:
56             row.prop(toolsettings, "proportional_edit_falloff",
57                      text="", icon_only=True)
58
59         layout.prop(st, "auto_snap", text="")
60         layout.prop(st, "pivot_point", icon_only=True)
61
62         row = layout.row(align=True)
63         row.operator("graph.copy", text="", icon='COPYDOWN')
64         row.operator("graph.paste", text="", icon='PASTEDOWN')
65         row.operator("graph.paste", text="", icon='PASTEFLIPDOWN').flipped = True
66
67         row = layout.row(align=True)
68         if st.has_ghost_curves:
69             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
70         else:
71             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
72
73
74 class GRAPH_MT_editor_menus(Menu):
75     bl_idname = "GRAPH_MT_editor_menus"
76     bl_label = ""
77
78     def draw(self, context):
79         self.draw_menus(self.layout, context)
80
81     @staticmethod
82     def draw_menus(layout, context):
83         layout.menu("GRAPH_MT_view")
84         layout.menu("GRAPH_MT_select")
85         layout.menu("GRAPH_MT_marker")
86         layout.menu("GRAPH_MT_channel")
87         layout.menu("GRAPH_MT_key")
88
89
90 class GRAPH_MT_view(Menu):
91     bl_label = "View"
92
93     def draw(self, context):
94         layout = self.layout
95
96         st = context.space_data
97
98         layout.operator("graph.properties", icon='MENU_PANEL')
99         layout.separator()
100
101         layout.prop(st, "use_realtime_update")
102         layout.prop(st, "show_frame_indicator")
103         layout.prop(st, "show_cursor")
104         layout.prop(st, "show_sliders")
105         layout.prop(st, "show_group_colors")
106         layout.prop(st, "use_auto_merge_keyframes")
107
108         layout.separator()
109         layout.prop(st, "use_beauty_drawing")
110
111         layout.separator()
112
113         layout.prop(st, "show_handles")
114
115         layout.prop(st, "use_only_selected_curves_handles")
116         layout.prop(st, "use_only_selected_keyframe_handles")
117
118         layout.prop(st, "show_seconds")
119         layout.prop(st, "show_locked_time")
120
121         layout.separator()
122         layout.operator("anim.previewrange_set")
123         layout.operator("anim.previewrange_clear")
124         layout.operator("graph.previewrange_set")
125
126         layout.separator()
127         layout.operator("graph.view_all")
128         layout.operator("graph.view_selected")
129         layout.operator("graph.view_frame")
130
131         layout.separator()
132         layout.operator("screen.area_dupli")
133         layout.operator("screen.screen_full_area")
134         layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
135
136
137 class GRAPH_MT_select(Menu):
138     bl_label = "Select"
139
140     def draw(self, context):
141         layout = self.layout
142
143         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
144         layout.operator("graph.select_all_toggle").invert = False
145         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
146
147         layout.separator()
148         props = layout.operator("graph.select_border")
149         props.axis_range = False
150         props.include_handles = False
151         props = layout.operator("graph.select_border", text="Border Axis Range")
152         props.axis_range = True
153         props.include_handles = False
154         props = layout.operator("graph.select_border", text="Border (Include Handles)")
155         props.axis_range = False
156         props.include_handles = True
157
158         layout.operator("graph.select_circle")
159
160         layout.separator()
161         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
162         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
163
164         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
165         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
166
167         layout.separator()
168         props = layout.operator("graph.select_leftright", text="Before Current Frame")
169         props.extend = False
170         props.mode = 'LEFT'
171         props = layout.operator("graph.select_leftright", text="After Current Frame")
172         props.extend = False
173         props.mode = 'RIGHT'
174
175         layout.separator()
176         layout.operator("graph.select_more")
177         layout.operator("graph.select_less")
178
179         layout.separator()
180         layout.operator("graph.select_linked")
181
182
183 class GRAPH_MT_marker(Menu):
184     bl_label = "Marker"
185
186     def draw(self, context):
187         layout = self.layout
188
189         from .space_time import marker_menu_generic
190         marker_menu_generic(layout)
191
192         # TODO: pose markers for action edit mode only?
193
194
195 class GRAPH_MT_channel(Menu):
196     bl_label = "Channel"
197
198     def draw(self, context):
199         layout = self.layout
200
201         layout.operator_context = 'INVOKE_REGION_CHANNELS'
202
203         layout.operator("anim.channels_delete")
204         if context.space_data.mode == 'DRIVERS':
205             layout.operator("graph.driver_delete_invalid")
206
207         layout.separator()
208         layout.operator("anim.channels_group")
209         layout.operator("anim.channels_ungroup")
210
211         layout.separator()
212         layout.operator_menu_enum("anim.channels_setting_toggle", "type")
213         layout.operator_menu_enum("anim.channels_setting_enable", "type")
214         layout.operator_menu_enum("anim.channels_setting_disable", "type")
215
216         layout.separator()
217         layout.operator("anim.channels_editable_toggle")
218         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
219
220         layout.separator()
221         layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
222         layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
223         layout.operator("graph.reveal")
224
225         layout.separator()
226         layout.operator("anim.channels_expand")
227         layout.operator("anim.channels_collapse")
228
229         layout.separator()
230         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
231
232         layout.separator()
233         layout.operator("anim.channels_fcurves_enable")
234
235
236 class GRAPH_MT_key(Menu):
237     bl_label = "Key"
238
239     def draw(self, context):
240         layout = self.layout
241
242         layout.menu("GRAPH_MT_key_transform", text="Transform")
243
244         layout.operator_menu_enum("graph.snap", "type", text="Snap")
245         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
246
247         layout.separator()
248         layout.operator_menu_enum("graph.keyframe_insert", "type")
249         layout.operator_menu_enum("graph.fmodifier_add", "type")
250         layout.operator("graph.sound_bake")
251
252         layout.separator()
253         layout.operator("graph.frame_jump")
254
255         layout.separator()
256         layout.operator("graph.duplicate_move")
257         layout.operator("graph.delete")
258
259         layout.separator()
260         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
261         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
262         layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
263
264         layout.separator()
265         layout.operator("graph.clean").channels = False
266         layout.operator("graph.clean", text="Clean Channels").channels = True
267         layout.operator("graph.smooth")
268         layout.operator("graph.sample")
269         layout.operator("graph.bake")
270
271         layout.separator()
272         layout.operator("graph.copy")
273         layout.operator("graph.paste")
274
275         layout.separator()
276         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
277
278
279 class GRAPH_MT_key_transform(Menu):
280     bl_label = "Transform"
281
282     def draw(self, context):
283         layout = self.layout
284
285         layout.operator("transform.translate", text="Grab/Move")
286         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
287         layout.operator("transform.rotate", text="Rotate")
288         layout.operator("transform.resize", text="Scale")
289
290
291 class GRAPH_MT_delete(Menu):
292     bl_label = "Delete"
293
294     def draw(self, context):
295         layout = self.layout
296
297         layout.operator("graph.delete")
298
299         layout.separator()
300
301         layout.operator("graph.clean").channels = False
302         layout.operator("graph.clean", text="Clean Channels").channels = True
303
304
305 classes = (
306     GRAPH_HT_header,
307     GRAPH_MT_editor_menus,
308     GRAPH_MT_view,
309     GRAPH_MT_select,
310     GRAPH_MT_marker,
311     GRAPH_MT_channel,
312     GRAPH_MT_key,
313     GRAPH_MT_key_transform,
314     GRAPH_MT_delete,
315 )
316
317 if __name__ == "__main__":  # only for live edit.
318     from bpy.utils import register_class
319     for cls in classes:
320         register_class(cls)