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