d48b6650460b52b07120a7f1920aae322044150e
[blender-staging.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 bl_ui.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 bl_ui.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
205         layout.separator()
206         layout.operator("anim.channels_group")
207         layout.operator("anim.channels_ungroup")
208
209         layout.separator()
210         layout.operator_menu_enum("anim.channels_setting_toggle", "type")
211         layout.operator_menu_enum("anim.channels_setting_enable", "type")
212         layout.operator_menu_enum("anim.channels_setting_disable", "type")
213
214         layout.separator()
215         layout.operator("anim.channels_editable_toggle")
216         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
217
218         layout.separator()
219         layout.operator("graph.hide", text="Hide Selected Curves").unselected = False
220         layout.operator("graph.hide", text="Hide Unselected Curves").unselected = True
221         layout.operator("graph.reveal")
222
223         layout.separator()
224         layout.operator("anim.channels_expand")
225         layout.operator("anim.channels_collapse")
226
227         layout.separator()
228         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
229
230         layout.separator()
231         layout.operator("anim.channels_fcurves_enable")
232
233
234 class GRAPH_MT_key(Menu):
235     bl_label = "Key"
236
237     def draw(self, context):
238         layout = self.layout
239
240         layout.menu("GRAPH_MT_key_transform", text="Transform")
241
242         layout.operator_menu_enum("graph.snap", "type", text="Snap")
243         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
244
245         layout.separator()
246         layout.operator_menu_enum("graph.keyframe_insert", "type")
247         layout.operator_menu_enum("graph.fmodifier_add", "type")
248         layout.operator("graph.sound_bake")
249
250         layout.separator()
251         layout.operator("graph.frame_jump")
252
253         layout.separator()
254         layout.operator("graph.duplicate_move")
255         layout.operator("graph.delete")
256
257         layout.separator()
258         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
259         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
260         layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type")
261
262         layout.separator()
263         layout.operator("graph.clean").channels = False
264         layout.operator("graph.clean", text="Clean Channels").channels = True
265         layout.operator("graph.smooth")
266         layout.operator("graph.sample")
267         layout.operator("graph.bake")
268
269         layout.separator()
270         layout.operator("graph.copy")
271         layout.operator("graph.paste")
272
273         layout.separator()
274         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
275
276
277 class GRAPH_MT_key_transform(Menu):
278     bl_label = "Transform"
279
280     def draw(self, context):
281         layout = self.layout
282
283         layout.operator("transform.translate", text="Grab/Move")
284         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
285         layout.operator("transform.rotate", text="Rotate")
286         layout.operator("transform.resize", text="Scale")
287
288
289 class GRAPH_MT_delete(Menu):
290     bl_label = "Delete"
291
292     def draw(self, context):
293         layout = self.layout
294
295         layout.operator("graph.delete")
296
297         layout.separator()
298
299         layout.operator("graph.clean").channels = False
300         layout.operator("graph.clean", text="Clean Channels").channels = True
301
302 classes = (
303     GRAPH_HT_header,
304     GRAPH_MT_channel,
305     GRAPH_MT_delete,
306     GRAPH_MT_editor_menus,
307     GRAPH_MT_key,
308     GRAPH_MT_key_transform,
309     GRAPH_MT_marker,
310     GRAPH_MT_select,
311     GRAPH_MT_view,
312 )
313
314 if __name__ == "__main__":  # only for live edit.
315     from bpy.utils import register_class
316     for cls in classes:
317         register_class(cls)