Animation play: Follow feature. Enabled from playback menu in the
[blender-staging.git] / release / scripts / startup / bl_ui / space_time.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 import bpy
21 from bpy.types import Header, Menu
22
23
24 class TIME_HT_header(Header):
25     bl_space_type = 'TIMELINE'
26
27     def draw(self, context):
28         layout = self.layout
29
30         scene = context.scene
31         toolsettings = context.tool_settings
32         screen = context.screen
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         TIME_MT_editor_menus.draw_collapsible(context, layout)
38
39         row = layout.row(align=True)
40         row.prop(scene, "use_preview_range", text="", toggle=True)
41         row.prop(scene, "lock_frame_selection_to_range", text="", toggle=True)
42
43         row = layout.row(align=True)
44         if not scene.use_preview_range:
45             row.prop(scene, "frame_start", text="Start")
46             row.prop(scene, "frame_end", text="End")
47         else:
48             row.prop(scene, "frame_preview_start", text="Start")
49             row.prop(scene, "frame_preview_end", text="End")
50
51         layout.prop(scene, "frame_current", text="")
52
53         layout.separator()
54
55         row = layout.row(align=True)
56         row.operator("screen.frame_jump", text="", icon='REW').end = False
57         row.operator("screen.keyframe_jump", text="", icon='PREV_KEYFRAME').next = False
58         if not screen.is_animation_playing:
59             # if using JACK and A/V sync:
60             #   hide the play-reversed button
61             #   since JACK transport doesn't support reversed playback
62             if scene.sync_mode == 'AUDIO_SYNC' and context.user_preferences.system.audio_device == 'JACK':
63                 sub = row.row(align=True)
64                 sub.scale_x = 2.0
65                 sub.operator("screen.animation_play", text="", icon='PLAY')
66             else:
67                 row.operator("screen.animation_play", text="", icon='PLAY_REVERSE').reverse = True
68                 row.operator("screen.animation_play", text="", icon='PLAY')
69         else:
70             sub = row.row(align=True)
71             sub.scale_x = 2.0
72             sub.operator("screen.animation_play", text="", icon='PAUSE')
73         row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
74         row.operator("screen.frame_jump", text="", icon='FF').end = True
75
76         layout.prop(scene, "sync_mode", text="")
77
78         layout.separator()
79
80         row = layout.row(align=True)
81         row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True)
82         if toolsettings.use_keyframe_insert_auto:
83             row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True)
84
85             if screen.is_animation_playing:
86                 subsub = row.row(align=True)
87                 subsub.prop(toolsettings, "use_record_with_nla", toggle=True)
88
89         row = layout.row(align=True)
90         row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="")
91         row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
92         row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
93
94
95 class TIME_MT_editor_menus(Menu):
96     bl_idname = "TIME_MT_editor_menus"
97     bl_label = ""
98
99     def draw(self, context):
100         self.draw_menus(self.layout, context)
101
102     @staticmethod
103     def draw_menus(layout, context):
104         layout.menu("TIME_MT_view")
105         layout.menu("TIME_MT_marker")
106         layout.menu("TIME_MT_frame")
107         layout.menu("TIME_MT_playback")
108
109
110 class TIME_MT_marker(Menu):
111     bl_label = "Marker"
112
113     def draw(self, context):
114         layout = self.layout
115
116         marker_menu_generic(layout)
117
118
119 class TIME_MT_view(Menu):
120     bl_label = "View"
121
122     def draw(self, context):
123         layout = self.layout
124
125         scene = context.scene
126         st = context.space_data
127
128         layout.prop(st, "show_seconds")
129         layout.prop(st, "show_locked_time")
130         layout.operator("time.view_all")
131
132         layout.separator()
133
134         layout.prop(st, "show_frame_indicator")
135         layout.prop(scene, "show_keys_from_selected_only")
136
137         layout.separator()
138
139         layout.menu("TIME_MT_cache")
140
141         layout.separator()
142
143         layout.operator("marker.camera_bind")
144
145         layout.separator()
146
147         layout.operator("screen.area_dupli")
148         layout.operator("screen.screen_full_area", text="Toggle Maximize Area")
149         layout.operator("screen.screen_full_area").use_hide_panels = True
150
151
152 class TIME_MT_cache(Menu):
153     bl_label = "Cache"
154
155     def draw(self, context):
156         layout = self.layout
157
158         st = context.space_data
159
160         layout.prop(st, "show_cache")
161
162         layout.separator()
163
164         col = layout.column()
165         col.enabled = st.show_cache
166         col.prop(st, "cache_softbody")
167         col.prop(st, "cache_particles")
168         col.prop(st, "cache_cloth")
169         col.prop(st, "cache_smoke")
170         col.prop(st, "cache_dynamicpaint")
171         col.prop(st, "cache_rigidbody")
172
173
174 class TIME_MT_frame(Menu):
175     bl_label = "Frame"
176
177     def draw(self, context):
178         layout = self.layout
179
180         layout.operator("anim.previewrange_clear")
181         layout.operator("anim.previewrange_set")
182         layout.separator()
183         layout.operator("time.end_frame_set")
184         layout.operator("time.start_frame_set")
185
186         layout.separator()
187
188         layout.menu("TIME_MT_autokey")
189
190
191 class TIME_MT_playback(Menu):
192     bl_label = "Playback"
193
194     def draw(self, context):
195         layout = self.layout
196
197         screen = context.screen
198         scene = context.scene
199
200         layout.prop(screen, "use_play_top_left_3d_editor")
201         layout.prop(screen, "use_play_3d_editors")
202         layout.prop(screen, "use_play_animation_editors")
203         layout.prop(screen, "use_play_properties_editors")
204         layout.prop(screen, "use_play_image_editors")
205         layout.prop(screen, "use_play_sequence_editors")
206         layout.prop(screen, "use_play_node_editors")
207         layout.prop(screen, "use_play_clip_editors")
208
209         layout.separator()
210         layout.prop(screen, "use_follow")
211         layout.separator()
212
213         layout.prop(scene, "use_frame_drop", text="Frame Dropping")
214         layout.prop(scene, "use_audio_sync", text="AV-sync", icon='SPEAKER')
215         layout.prop(scene, "use_audio")
216         layout.prop(scene, "use_audio_scrub")
217
218
219 class TIME_MT_autokey(Menu):
220     bl_label = "Auto-Keyframing Mode"
221
222     def draw(self, context):
223         layout = self.layout
224         toolsettings = context.tool_settings
225
226         layout.prop_enum(toolsettings, "auto_keying_mode", 'ADD_REPLACE_KEYS')
227         layout.prop_enum(toolsettings, "auto_keying_mode", 'REPLACE_KEYS')
228
229
230 def marker_menu_generic(layout):
231
232     #layout.operator_context = 'EXEC_REGION_WIN'
233
234     layout.column()
235     layout.operator("marker.add", "Add Marker")
236     layout.operator("marker.duplicate", text="Duplicate Marker")
237
238     if len(bpy.data.scenes) > 10:
239         layout.operator_context = 'INVOKE_DEFAULT'
240         layout.operator("marker.make_links_scene", text="Duplicate Marker to Scene...", icon='OUTLINER_OB_EMPTY')
241     else:
242         layout.operator_menu_enum("marker.make_links_scene", "scene", text="Duplicate Marker to Scene...")
243
244     layout.operator("marker.delete", text="Delete Marker")
245
246     layout.separator()
247
248     layout.operator("marker.rename", text="Rename Marker")
249     layout.operator("marker.move", text="Grab/Move Marker")
250
251     layout.separator()
252
253     layout.operator("screen.marker_jump", text="Jump to Next Marker").next = True
254     layout.operator("screen.marker_jump", text="Jump to Previous Marker").next = False
255
256
257 if __name__ == "__main__":  # only for live edit.
258     bpy.utils.register_module(__name__)