rename operators TFM_OT_* --> TRANSFORM_OT_*
[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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 import bpy
20
21
22 class GRAPH_HT_header(bpy.types.Header):
23     bl_space_type = 'GRAPH_EDITOR'
24
25     def draw(self, context):
26         layout = self.layout
27
28         st = context.space_data
29
30         row = layout.row(align=True)
31         row.template_header()
32
33         if context.area.show_menus:
34             sub = row.row(align=True)
35
36             sub.menu("GRAPH_MT_view")
37             sub.menu("GRAPH_MT_select")
38             sub.menu("GRAPH_MT_channel")
39             sub.menu("GRAPH_MT_key")
40
41         layout.prop(st, "mode", text="")
42
43         layout.template_dopesheet_filter(st.dopesheet)
44
45         layout.prop(st, "autosnap", text="")
46         layout.prop(st, "pivot_point", text="", icon_only=True)
47
48         row = layout.row(align=True)
49         row.operator("graph.copy", text="", icon='COPYDOWN')
50         row.operator("graph.paste", text="", icon='PASTEDOWN')
51
52         row = layout.row(align=True)
53         if st.has_ghost_curves:
54             row.operator("graph.ghost_curves_clear", text="", icon='GHOST_DISABLED')
55         else:
56             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
57
58
59 class GRAPH_MT_view(bpy.types.Menu):
60     bl_label = "View"
61
62     def draw(self, context):
63         layout = self.layout
64
65         st = context.space_data
66
67         layout.column()
68
69         layout.separator()
70         layout.operator("graph.properties", icon='MENU_PANEL')
71
72         layout.prop(st, "show_cframe_indicator")
73         layout.prop(st, "show_cursor")
74         layout.prop(st, "show_sliders")
75         layout.prop(st, "automerge_keyframes")
76
77         layout.separator()
78         if st.show_handles:
79             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_HLT', text="Show All Handles")
80         else:
81             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_DEHLT', text="Show All Handles")
82         layout.prop(st, "only_selected_curves_handles")
83         layout.prop(st, "only_selected_keyframe_handles")
84         layout.operator("anim.time_toggle")
85
86         layout.separator()
87         layout.operator("anim.previewrange_set")
88         layout.operator("anim.previewrange_clear")
89         layout.operator("graph.previewrange_set")
90
91         layout.separator()
92         layout.operator("graph.frame_jump")
93         layout.operator("graph.view_all")
94
95         layout.separator()
96         layout.operator("screen.area_dupli")
97         layout.operator("screen.screen_full_area")
98
99
100 class GRAPH_MT_select(bpy.types.Menu):
101     bl_label = "Select"
102
103     def draw(self, context):
104         layout = self.layout
105
106         layout.column()
107         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
108         layout.operator("graph.select_all_toggle")
109         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
110
111         layout.separator()
112         layout.operator("graph.select_border")
113         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
114
115         layout.separator()
116         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
117         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
118
119         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
120         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
121
122
123 class GRAPH_MT_channel(bpy.types.Menu):
124     bl_label = "Channel"
125
126     def draw(self, context):
127         layout = self.layout
128
129         layout.column()
130         layout.operator("anim.channels_setting_toggle")
131         layout.operator("anim.channels_setting_enable")
132         layout.operator("anim.channels_setting_disable")
133
134         layout.separator()
135         layout.operator("anim.channels_editable_toggle")
136
137         layout.separator()
138         layout.operator("anim.channels_expand")
139         layout.operator("anim.channels_collapse")
140
141
142 class GRAPH_MT_key(bpy.types.Menu):
143     bl_label = "Key"
144
145     def draw(self, context):
146         layout = self.layout
147
148         layout.column()
149         layout.menu("GRAPH_MT_key_transform", text="Transform")
150
151         layout.operator_menu_enum("graph.snap", property="type", text="Snap")
152         layout.operator_menu_enum("graph.mirror", property="type", text="Mirror")
153
154         layout.separator()
155         layout.operator("graph.keyframe_insert")
156         layout.operator("graph.fmodifier_add")
157
158         layout.separator()
159         layout.operator("graph.duplicate")
160         layout.operator("graph.delete")
161
162         layout.separator()
163         layout.operator_menu_enum("graph.handle_type", property="type", text="Handle Type")
164         layout.operator_menu_enum("graph.interpolation_type", property="type", text="Interpolation Mode")
165         layout.operator_menu_enum("graph.extrapolation_type", property="type", text="Extrapolation Mode")
166
167         layout.separator()
168         layout.operator("graph.clean")
169         layout.operator("graph.sample")
170         layout.operator("graph.bake")
171
172         layout.separator()
173         layout.operator("graph.copy")
174         layout.operator("graph.paste")
175
176
177 class GRAPH_MT_key_transform(bpy.types.Menu):
178     bl_label = "Transform"
179
180     def draw(self, context):
181         layout = self.layout
182
183         layout.column()
184         layout.operator("transform.translate", text="Grab/Move")
185         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
186         layout.operator("transform.rotate", text="Rotate")
187         layout.operator("transform.resize", text="Scale")
188
189
190 bpy.types.register(GRAPH_HT_header) # header/menu classes
191 bpy.types.register(GRAPH_MT_view)
192 bpy.types.register(GRAPH_MT_select)
193 bpy.types.register(GRAPH_MT_channel)
194 bpy.types.register(GRAPH_MT_key)
195 bpy.types.register(GRAPH_MT_key_transform)