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