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