fix for keying set rna path attribute and object select menu incorrect args to UI...
[blender.git] / release / scripts / ui / space_dopesheet.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 DOPESHEET_HT_header(bpy.types.Header):
25     bl_space_type = 'DOPESHEET_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("DOPESHEET_MT_view")
39             sub.menu("DOPESHEET_MT_select")
40
41             if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action != None):
42                 sub.menu("DOPESHEET_MT_channel")
43             elif st.mode == 'GPENCIL':
44                 # gpencil Channel menu
45                 pass
46
47             if st.mode != 'GPENCIL':
48                 sub.menu("DOPESHEET_MT_key")
49
50         layout.prop(st, "mode", text="")
51         layout.prop(st.dopesheet, "display_summary", text="Summary")
52
53         if st.mode == 'DOPESHEET':
54             layout.template_dopesheet_filter(st.dopesheet)
55         elif st.mode == 'ACTION':
56             layout.template_ID(st, "action", new="action.new")
57
58         if st.mode != 'GPENCIL':
59             layout.prop(st, "autosnap", text="")
60
61         row = layout.row(align=True)
62         row.operator("action.copy", text="", icon='COPYDOWN')
63         row.operator("action.paste", text="", icon='PASTEDOWN')
64
65
66 class DOPESHEET_MT_view(bpy.types.Menu):
67     bl_label = "View"
68
69     def draw(self, context):
70         layout = self.layout
71
72         st = context.space_data
73
74         layout.column()
75
76         layout.prop(st, "realtime_updates")
77         layout.prop(st, "show_cframe_indicator")
78         layout.prop(st, "show_sliders")
79         layout.prop(st, "automerge_keyframes")
80         layout.prop(st, "use_marker_sync")
81
82         if st.show_seconds:
83             layout.operator("anim.time_toggle", text="Show Frames")
84         else:
85             layout.operator("anim.time_toggle", text="Show Seconds")
86
87         layout.separator()
88         layout.operator("anim.previewrange_set")
89         layout.operator("anim.previewrange_clear")
90         layout.operator("action.previewrange_set")
91
92         layout.separator()
93         layout.operator("action.frame_jump")
94         layout.operator("action.view_all")
95
96         layout.separator()
97         layout.operator("screen.area_dupli")
98         layout.operator("screen.screen_full_area")
99
100
101 class DOPESHEET_MT_select(bpy.types.Menu):
102     bl_label = "Select"
103
104     def draw(self, context):
105         layout = self.layout
106
107         layout.column()
108         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
109         layout.operator("action.select_all_toggle")
110         layout.operator("action.select_all_toggle", text="Invert Selection").invert = True
111
112         layout.separator()
113         layout.operator("action.select_border")
114         layout.operator("action.select_border", text="Border Axis Range").axis_range = True
115
116         layout.separator()
117         layout.operator("action.select_column", text="Columns on Selected Keys").mode = 'KEYS'
118         layout.operator("action.select_column", text="Column on Current Frame").mode = 'CFRA'
119
120         layout.operator("action.select_column", text="Columns on Selected Markers").mode = 'MARKERS_COLUMN'
121         layout.operator("action.select_column", text="Between Selected Markers").mode = 'MARKERS_BETWEEN'
122
123         layout.separator()
124         layout.operator("action.select_more")
125         layout.operator("action.select_less")
126
127
128 class DOPESHEET_MT_channel(bpy.types.Menu):
129     bl_label = "Channel"
130
131     def draw(self, context):
132         layout = self.layout
133
134         layout.operator_context = 'INVOKE_REGION_CHANNELS'
135
136         layout.column()
137         layout.operator("anim.channels_setting_toggle")
138         layout.operator("anim.channels_setting_enable")
139         layout.operator("anim.channels_setting_disable")
140
141         layout.separator()
142         layout.operator("anim.channels_editable_toggle")
143
144         layout.separator()
145         layout.operator("anim.channels_expand")
146         layout.operator("anim.channels_collapse")
147
148
149 class DOPESHEET_MT_key(bpy.types.Menu):
150     bl_label = "Key"
151
152     def draw(self, context):
153         layout = self.layout
154
155         layout.column()
156         layout.menu("DOPESHEET_MT_key_transform", text="Transform")
157
158         layout.operator_menu_enum("action.snap", "type", text="Snap")
159         layout.operator_menu_enum("action.mirror", "type", text="Mirror")
160
161         layout.separator()
162         layout.operator("action.keyframe_insert")
163
164         layout.separator()
165         layout.operator("action.duplicate")
166         layout.operator("action.delete")
167
168         layout.separator()
169         layout.operator_menu_enum("action.keyframe_type", "type", text="Keyframe Type")
170         layout.operator_menu_enum("action.handle_type", "type", text="Handle Type")
171         layout.operator_menu_enum("action.interpolation_type", "type", text="Interpolation Mode")
172         layout.operator_menu_enum("action.extrapolation_type", "type", text="Extrapolation Mode")
173
174         layout.separator()
175         layout.operator("action.clean")
176         layout.operator("action.sample")
177
178         layout.separator()
179         layout.operator("action.copy")
180         layout.operator("action.paste")
181
182
183 class DOPESHEET_MT_key_transform(bpy.types.Menu):
184     bl_label = "Transform"
185
186     def draw(self, context):
187         layout = self.layout
188
189         layout.column()
190         layout.operator("transform.transform", text="Grab/Move").mode = 'TIME_TRANSLATE'
191         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
192         layout.operator("transform.transform", text="Slide").mode = 'TIME_SLIDE'
193         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
194
195
196 classes = [
197     DOPESHEET_HT_header, # header/menu classes
198     DOPESHEET_MT_view,
199     DOPESHEET_MT_select,
200     DOPESHEET_MT_channel,
201     DOPESHEET_MT_key,
202     DOPESHEET_MT_key_transform]
203
204
205 def register():
206     register = bpy.types.register
207     for cls in classes:
208         register(cls)
209
210
211 def unregister():
212     unregister = bpy.types.unregister
213     for cls in classes:
214         unregister(cls)
215
216 if __name__ == "__main__":
217     register()