51c5ebcfbf8ddcefb322da10909e37a7c34d804d
[blender.git] / release / scripts / 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
23
24 class GRAPH_HT_header(bpy.types.Header):
25     bl_space_type = 'GRAPH_EDITOR'
26
27     def draw(self, context):
28         from space_dopesheet import dopesheet_filter
29
30         layout = self.layout
31
32         st = context.space_data
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         if context.area.show_menus:
38             sub = row.row(align=True)
39
40             sub.menu("GRAPH_MT_view")
41             sub.menu("GRAPH_MT_select")
42             sub.menu("GRAPH_MT_marker")
43             sub.menu("GRAPH_MT_channel")
44             sub.menu("GRAPH_MT_key")
45
46         layout.prop(st, "mode", text="")
47
48         dopesheet_filter(layout, context)
49
50         layout.prop(st, "auto_snap", text="")
51         layout.prop(st, "pivot_point", text="", icon_only=True)
52
53         row = layout.row(align=True)
54         row.operator("graph.copy", text="", icon='COPYDOWN')
55         row.operator("graph.paste", text="", icon='PASTEDOWN')
56
57         row = layout.row(align=True)
58         if st.has_ghost_curves:
59             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
60         else:
61             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
62
63
64 class GRAPH_MT_view(bpy.types.Menu):
65     bl_label = "View"
66
67     def draw(self, context):
68         layout = self.layout
69
70         st = context.space_data
71
72         layout.column()
73
74         layout.operator("graph.properties", icon='MENU_PANEL')
75         layout.separator()
76
77         layout.prop(st, "use_realtime_update")
78         layout.prop(st, "show_frame_indicator")
79         layout.prop(st, "show_cursor")
80         layout.prop(st, "show_sliders")
81         layout.prop(st, "use_auto_merge_keyframes")
82
83         layout.separator()
84         if st.show_handles:
85             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_HLT', text="Show All Handles")
86         else:
87             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_DEHLT', text="Show All Handles")
88         layout.prop(st, "use_only_selected_curves_handles")
89         layout.prop(st, "use_only_selected_keyframe_handles")
90         layout.operator("anim.time_toggle")
91
92         layout.separator()
93         layout.operator("anim.previewrange_set")
94         layout.operator("anim.previewrange_clear")
95         layout.operator("graph.previewrange_set")
96
97         layout.separator()
98         layout.operator("graph.frame_jump")
99         layout.operator("graph.view_all")
100
101         layout.separator()
102         layout.operator("screen.area_dupli")
103         layout.operator("screen.screen_full_area")
104
105
106 class GRAPH_MT_select(bpy.types.Menu):
107     bl_label = "Select"
108
109     def draw(self, context):
110         layout = self.layout
111
112         layout.column()
113         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
114         layout.operator("graph.select_all_toggle")
115         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
116
117         layout.separator()
118         layout.operator("graph.select_border")
119         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
120         layout.operator("graph.select_border", text="Border (Include Handles)").include_handles = True
121
122         layout.separator()
123         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
124         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
125
126         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
127         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
128
129         layout.separator()
130         layout.operator("graph.select_more")
131         layout.operator("graph.select_less")
132
133         layout.separator()
134         layout.operator("graph.select_linked")
135
136
137 class GRAPH_MT_marker(bpy.types.Menu):
138     bl_label = "Marker"
139
140     def draw(self, context):
141         layout = self.layout
142
143         #layout.operator_context = 'EXEC_REGION_WIN'
144
145         layout.column()
146         layout.operator("marker.add", "Add Marker")
147         layout.operator("marker.duplicate", text="Duplicate Marker")
148         layout.operator("marker.delete", text="Delete Marker")
149
150         layout.separator()
151
152         layout.operator("marker.rename", text="Rename Marker")
153         layout.operator("marker.move", text="Grab/Move Marker")
154
155         # TODO: pose markers for action edit mode only?
156
157
158 class GRAPH_MT_channel(bpy.types.Menu):
159     bl_label = "Channel"
160
161     def draw(self, context):
162         layout = self.layout
163
164         layout.operator_context = 'INVOKE_REGION_CHANNELS'
165
166         layout.column()
167         layout.operator("anim.channels_delete")
168
169         layout.separator()
170         layout.operator("anim.channels_setting_toggle")
171         layout.operator("anim.channels_setting_enable")
172         layout.operator("anim.channels_setting_disable")
173
174         layout.separator()
175         layout.operator("anim.channels_editable_toggle")
176         layout.operator("anim.channels_visibility_set")
177         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
178
179         layout.separator()
180         layout.operator("anim.channels_expand")
181         layout.operator("anim.channels_collapse")
182
183         layout.separator()
184         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
185
186         layout.separator()
187         layout.operator("anim.channels_fcurves_enable")
188
189
190 class GRAPH_MT_key(bpy.types.Menu):
191     bl_label = "Key"
192
193     def draw(self, context):
194         layout = self.layout
195
196         layout.column()
197         layout.menu("GRAPH_MT_key_transform", text="Transform")
198
199         layout.operator_menu_enum("graph.snap", "type", text="Snap")
200         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
201
202         layout.separator()
203         layout.operator("graph.keyframe_insert")
204         layout.operator("graph.fmodifier_add")
205
206         layout.separator()
207         layout.operator("graph.duplicate")
208         layout.operator("graph.delete")
209
210         layout.separator()
211         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
212         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
213
214         layout.separator()
215         layout.operator("graph.clean")
216         layout.operator("graph.smooth")
217         layout.operator("graph.sample")
218         layout.operator("graph.bake")
219
220         layout.separator()
221         layout.operator("graph.copy")
222         layout.operator("graph.paste")
223
224         layout.separator()
225         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
226
227
228 class GRAPH_MT_key_transform(bpy.types.Menu):
229     bl_label = "Transform"
230
231     def draw(self, context):
232         layout = self.layout
233
234         layout.column()
235         layout.operator("transform.translate", text="Grab/Move")
236         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
237         layout.operator("transform.rotate", text="Rotate")
238         layout.operator("transform.resize", text="Scale")
239
240
241 def register():
242     pass
243
244
245 def unregister():
246     pass
247
248 if __name__ == "__main__":
249     register()