fix for keying set rna path attribute and object select menu incorrect args to UI...
[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         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.operator("graph.properties", icon='MENU_PANEL')
72         layout.separator()
73
74         layout.prop(st, "realtime_updates")
75         layout.prop(st, "show_cframe_indicator")
76         layout.prop(st, "show_cursor")
77         layout.prop(st, "show_sliders")
78         layout.prop(st, "automerge_keyframes")
79
80         layout.separator()
81         if st.show_handles:
82             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_HLT', text="Show All Handles")
83         else:
84             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_DEHLT', text="Show All Handles")
85         layout.prop(st, "only_selected_curves_handles")
86         layout.prop(st, "only_selected_keyframe_handles")
87         layout.operator("anim.time_toggle")
88
89         layout.separator()
90         layout.operator("anim.previewrange_set")
91         layout.operator("anim.previewrange_clear")
92         layout.operator("graph.previewrange_set")
93
94         layout.separator()
95         layout.operator("graph.frame_jump")
96         layout.operator("graph.view_all")
97
98         layout.separator()
99         layout.operator("screen.area_dupli")
100         layout.operator("screen.screen_full_area")
101
102
103 class GRAPH_MT_select(bpy.types.Menu):
104     bl_label = "Select"
105
106     def draw(self, context):
107         layout = self.layout
108
109         layout.column()
110         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
111         layout.operator("graph.select_all_toggle")
112         layout.operator("graph.select_all_toggle", text="Invert Selection").invert = True
113
114         layout.separator()
115         layout.operator("graph.select_border")
116         layout.operator("graph.select_border", text="Border Axis Range").axis_range = True
117
118         layout.separator()
119         layout.operator("graph.select_column", text="Columns on Selected Keys").mode = 'KEYS'
120         layout.operator("graph.select_column", text="Column on Current Frame").mode = 'CFRA'
121
122         layout.operator("graph.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
123         layout.operator("graph.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
124
125         layout.separator()
126         layout.operator("graph.select_more")
127         layout.operator("graph.select_less")
128
129
130 class GRAPH_MT_channel(bpy.types.Menu):
131     bl_label = "Channel"
132
133     def draw(self, context):
134         layout = self.layout
135
136         layout.operator_context = 'INVOKE_REGION_CHANNELS'
137
138         layout.column()
139         layout.operator("anim.channels_setting_toggle")
140         layout.operator("anim.channels_setting_enable")
141         layout.operator("anim.channels_setting_disable")
142
143         layout.separator()
144         layout.operator("anim.channels_editable_toggle")
145         layout.operator("anim.channels_visibility_set")
146
147         layout.separator()
148         layout.operator("anim.channels_expand")
149         layout.operator("anim.channels_collapse")
150
151         layout.separator()
152         layout.operator("graph.euler_filter", text="Discontinuity (Euler) Filter")
153
154
155 class GRAPH_MT_key(bpy.types.Menu):
156     bl_label = "Key"
157
158     def draw(self, context):
159         layout = self.layout
160
161         layout.column()
162         layout.menu("GRAPH_MT_key_transform", text="Transform")
163
164         layout.operator_menu_enum("graph.snap", "type", text="Snap")
165         layout.operator_menu_enum("graph.mirror", "type", text="Mirror")
166
167         layout.separator()
168         layout.operator("graph.keyframe_insert")
169         layout.operator("graph.fmodifier_add")
170
171         layout.separator()
172         layout.operator("graph.duplicate")
173         layout.operator("graph.delete")
174
175         layout.separator()
176         layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type")
177         layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode")
178         layout.operator_menu_enum("graph.extrapolation_type", "type", text="Extrapolation Mode")
179
180         layout.separator()
181         layout.operator("graph.clean")
182         layout.operator("graph.sample")
183         layout.operator("graph.bake")
184
185         layout.separator()
186         layout.operator("graph.copy")
187         layout.operator("graph.paste")
188
189
190 class GRAPH_MT_key_transform(bpy.types.Menu):
191     bl_label = "Transform"
192
193     def draw(self, context):
194         layout = self.layout
195
196         layout.column()
197         layout.operator("transform.translate", text="Grab/Move")
198         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
199         layout.operator("transform.rotate", text="Rotate")
200         layout.operator("transform.resize", text="Scale")
201
202
203 classes = [
204     GRAPH_HT_header, # header/menu classes
205     GRAPH_MT_view,
206     GRAPH_MT_select,
207     GRAPH_MT_channel,
208     GRAPH_MT_key,
209     GRAPH_MT_key_transform]
210
211
212 def register():
213     register = bpy.types.register
214     for cls in classes:
215         register(cls)
216
217
218 def unregister():
219     unregister = bpy.types.unregister
220     for cls in classes:
221         unregister(cls)
222
223 if __name__ == "__main__":
224     register()