fix [#27675] Bones shift out of place when leaving edit mode
[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
22
23 class TIME_HT_header(bpy.types.Header):
24     bl_space_type = 'TIMELINE'
25
26     def draw(self, context):
27         layout = self.layout
28
29         scene = context.scene
30         tools = context.tool_settings
31         screen = context.screen
32
33         row = layout.row(align=True)
34         row.template_header()
35
36         if context.area.show_menus:
37             sub = row.row(align=True)
38             sub.menu("TIME_MT_view")
39             sub.menu("TIME_MT_frame")
40             sub.menu("TIME_MT_playback")
41
42         layout.prop(scene, "use_preview_range", text="", toggle=True)
43
44         row = layout.row(align=True)
45         if not scene.use_preview_range:
46             row.prop(scene, "frame_start", text="Start")
47             row.prop(scene, "frame_end", text="End")
48         else:
49             row.prop(scene, "frame_preview_start", text="Start")
50             row.prop(scene, "frame_preview_end", text="End")
51
52         layout.prop(scene, "frame_current", text="")
53
54         layout.separator()
55
56         row = layout.row(align=True)
57         row.operator("screen.frame_jump", text="", icon='REW').end = False
58         row.operator("screen.keyframe_jump", text="", icon='PREV_KEYFRAME').next = False
59         if not screen.is_animation_playing:
60             # if using JACK and A/V sync:
61             #   hide the play-reversed button
62             #   since JACK transport doesn't support reversed playback
63             if (context.user_preferences.system.audio_device == 'JACK' and scene.sync_mode == 'AUDIO_SYNC'):
64                 sub = row.row()
65                 sub.scale_x = 2.0
66                 sub.operator("screen.animation_play", text="", icon='PLAY')
67             else:
68                 row.operator("screen.animation_play", text="", icon='PLAY_REVERSE').reverse = True
69                 row.operator("screen.animation_play", text="", icon='PLAY')
70         else:
71             sub = row.row()
72             sub.scale_x = 2.0
73             sub.operator("screen.animation_play", text="", icon='PAUSE')
74         row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
75         row.operator("screen.frame_jump", text="", icon='FF').end = True
76
77         layout.prop(scene, "sync_mode", text="")
78
79         layout.separator()
80
81         row = layout.row(align=True)
82         row.prop(tools, "use_keyframe_insert_auto", text="", toggle=True)
83         row.prop(tools, "use_keyframe_insert_keyingset", text="", toggle=True)
84         if screen.is_animation_playing and tools.use_keyframe_insert_auto:
85             subsub = row.row()
86             subsub.prop(tools, "use_record_with_nla", toggle=True)
87
88         row = layout.row(align=True)
89         row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="")
90         row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
91         row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
92
93
94 class TIME_MT_view(bpy.types.Menu):
95     bl_label = "View"
96
97     def draw(self, context):
98         layout = self.layout
99
100         st = context.space_data
101
102         layout.operator("anim.time_toggle")
103         layout.operator("time.view_all")
104
105         layout.separator()
106
107         layout.prop(st, "show_frame_indicator")
108         layout.prop(st, "show_only_selected")
109
110         layout.separator()
111
112         layout.menu("TIME_MT_cache")
113
114         layout.separator()
115
116         layout.operator("marker.camera_bind")
117
118
119 class TIME_MT_cache(bpy.types.Menu):
120     bl_label = "Cache"
121
122     def draw(self, context):
123         layout = self.layout
124
125         st = context.space_data
126
127         layout.prop(st, "show_cache")
128
129         layout.separator()
130
131         col = layout.column()
132         col.enabled = st.show_cache
133         col.prop(st, "cache_softbody")
134         col.prop(st, "cache_particles")
135         col.prop(st, "cache_cloth")
136         col.prop(st, "cache_smoke")
137
138
139 class TIME_MT_frame(bpy.types.Menu):
140     bl_label = "Frame"
141
142     def draw(self, context):
143         layout = self.layout
144
145         layout.operator("marker.add", text="Add Marker")
146         layout.operator("marker.duplicate", text="Duplicate Marker")
147         layout.operator("marker.delete", text="Delete Marker")
148
149         layout.separator()
150
151         layout.operator("marker.rename", text="Rename Marker")
152         layout.operator("marker.move", text="Grab/Move Marker")
153
154         layout.separator()
155
156         layout.operator("time.start_frame_set")
157         layout.operator("time.end_frame_set")
158
159         layout.separator()
160
161         sub = layout.row()
162         sub.menu("TIME_MT_autokey")
163
164
165 class TIME_MT_playback(bpy.types.Menu):
166     bl_label = "Playback"
167
168     def draw(self, context):
169         layout = self.layout
170
171         screen = context.screen
172         scene = context.scene
173
174         layout.prop(screen, "use_play_top_left_3d_editor")
175         layout.prop(screen, "use_play_3d_editors")
176         layout.prop(screen, "use_play_animation_editors")
177         layout.prop(screen, "use_play_properties_editors")
178         layout.prop(screen, "use_play_image_editors")
179         layout.prop(screen, "use_play_sequence_editors")
180         layout.prop(screen, "use_play_node_editors")
181
182         layout.separator()
183
184         layout.prop(scene, "use_frame_drop", text="Frame Dropping")
185         layout.prop(scene, "use_audio_sync", text="AV-sync", icon='SPEAKER')
186         layout.prop(scene, "use_audio")
187         layout.prop(scene, "use_audio_scrub")
188
189
190 class TIME_MT_autokey(bpy.types.Menu):
191     bl_label = "Auto-Keyframing Mode"
192
193     def draw(self, context):
194         layout = self.layout
195         tools = context.tool_settings
196
197         layout.prop_enum(tools, "auto_keying_mode", 'ADD_REPLACE_KEYS')
198         layout.prop_enum(tools, "auto_keying_mode", 'REPLACE_KEYS')
199
200 if __name__ == "__main__":  # only for live edit.
201     bpy.utils.register_module(__name__)