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