2d0b1c93d1361502fa0b49aa92d74526bd7a5262
[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
33         st = context.space_data
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         if context.area.show_menus:
39             row.menu("GRAPH_MT_view")
40             row.menu("GRAPH_MT_select")
41             row.menu("GRAPH_MT_marker")
42             row.menu("GRAPH_MT_channel")
43             row.menu("GRAPH_MT_key")
44
45         layout.prop(st, "mode", text="")
46
47         dopesheet_filter(layout, context)
48
49         layout.prop(st, "auto_snap", text="")
50         layout.prop(st, "pivot_point", text="", icon_only=True)
51
52         row = layout.row(align=True)
53         row.operator("graph.copy", text="", icon='COPYDOWN')
54         row.operator("graph.paste", text="", icon='PASTEDOWN')
55
56         row = layout.row(align=True)
57         if st.has_ghost_curves:
58             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
59         else:
60             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
61
62
63 class GRAPH_MT_view(Menu):
64     bl_label = "View"
65
66     def draw(self, context):
67         layout = self.layout
68
69         st = context.space_data
70
71         layout.operator("graph.properties", icon='MENU_PANEL')
72         layout.separator()
73
74         layout.prop(st, "use_realtime_update")
75         layout.prop(st, "show_frame_indicator")
76         layout.prop(st, "show_cursor")
77         layout.prop(st, "show_sliders")
78         layout.prop(st, "show_group_colors")
79         layout.prop(st, "use_auto_merge_keyframes")
80
81         layout.separator()
82         layout.prop(st, "use_beauty_drawing")
83
84         layout.separator()
85
86         layout.prop(st, "show_handles")
87
88         layout.prop(st, "use_only_selected_curves_handles")
89         layout.prop(st, "use_only_selected_keyframe_handles")
90
91         layout.prop(st, "show_seconds")
92
93         layout.separator()
94         layout.operator("anim.previewrange_set")
95         layout.operator("anim.previewrange_clear")
96         layout.operator("graph.previewrange_set")
97
98         layout.separator()
99         layout.operator("graph.view_all")
100         layout.operator("graph.view_selected")
101
102         layout.separator()
103         layout.operator("screen.area_dupli")
104         layout.operator("screen.screen_full_area")
105
106
107 class GRAPH_MT_select(Menu):
108     bl_label = "Select"
109
110     def draw(self, context):
111         layout = self.layout
112
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").invert = False
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_leftright", text="Before Current Frame").mode = 'LEFT'
131         layout.operator("graph.select_leftright", text="After Current Frame").mode = 'RIGHT'
132
133         layout.separator()
134         layout.operator("graph.select_more")
135         layout.operator("graph.select_less")
136
137         layout.separator()
138         layout.operator("graph.select_linked")
139
140
141 class GRAPH_MT_marker(Menu):
142     bl_label = "Marker"
143
144     def draw(self, context):
145         layout = self.layout
146
147         from bl_ui.space_time import marker_menu_generic
148         marker_menu_generic(layout)
149
150         # TODO: pose markers for action edit mode only?
151
152
153 class GRAPH_MT_channel(Menu):
154     bl_label = "Channel"
155
156     def draw(self, context):
157         layout = self.layout
158
159         layout.operator_context = 'INVOKE_REGION_CHANNELS'
160
161         layout.operator("anim.channels_delete")
162
163         layout.separator()
164         layout.operator("anim.channels_group")
165         layout.operator("anim.channels_ungroup")
166
167         layout.separator()
168         layout.operator_menu_enum("anim.channels_setting_toggle", "type")
169         layout.operator_menu_enum("anim.channels_setting_enable", "type")
170         layout.operator_menu_enum("anim.channels_setting_disable", "type")
171
172         layout.separator()
173         layout.operator("anim.channels_editable_toggle")
174         layout.operator("anim.channels_visibility_set")
175         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
176
177         layout.separator()
178         layout.operator("anim.channels_expand")
179         layout.operator("anim.channels_collapse")
180
181         layout.separator()
182         layout.operator_menu_enum("anim.channels_move", "direction", text="Move...")
183
184         layout.separator()
185         layout.operator("anim.channels_fcurves_enable")
186
187
188 class GRAPH_MT_key(Menu):
189     bl_label = "Key"
190
191     def draw(self, context):
192         layout = self.layout
193
194         layout.menu("GRAPH_MT_key_transform", text="Transform")
195
196         layout.operator_menu_enum("graph.snap", "type", text="Snap")
197         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
198
199         layout.separator()
200         layout.operator("graph.keyframe_insert")
201         layout.operator("graph.fmodifier_add")
202         layout.operator("graph.sound_bake")
203
204         layout.separator()
205         layout.operator("graph.frame_jump")
206
207         layout.separator()
208         layout.operator("graph.duplicate_move")
209         layout.operator("graph.delete")
210
211         layout.separator()
212         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
213         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
214
215         layout.separator()
216         layout.operator("graph.clean")
217         layout.operator("graph.smooth")
218         layout.operator("graph.sample")
219         layout.operator("graph.bake")
220
221         layout.separator()
222         layout.operator("graph.copy")
223         layout.operator("graph.paste")
224
225         layout.separator()
226         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
227
228
229 class GRAPH_MT_key_transform(Menu):
230     bl_label = "Transform"
231
232     def draw(self, context):
233         layout = self.layout
234
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 if __name__ == "__main__":  # only for live edit.
241     bpy.utils.register_module(__name__)