patch [#27917] MARKER MENUS: Unification and adding "Duplicate Marker to Scene..."
[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         tools = 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 (context.user_preferences.system.audio_device == 'JACK' and scene.sync_mode == 'AUDIO_SYNC'):
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(tools, "use_keyframe_insert_auto", text="", toggle=True)
84         row.prop(tools, "use_keyframe_insert_keyingset", text="", toggle=True)
85         if screen.is_animation_playing and tools.use_keyframe_insert_auto:
86             subsub = row.row()
87             subsub.prop(tools, "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_marker(bpy.types.Menu):
96     bl_label = "Marker"
97
98     def draw(self, context):
99         layout = self.layout
100
101         marker_menu_generic(layout)
102
103
104 class TIME_MT_view(Menu):
105     bl_label = "View"
106
107     def draw(self, context):
108         layout = self.layout
109
110         st = context.space_data
111
112         layout.operator("anim.time_toggle")
113         layout.operator("time.view_all")
114
115         layout.separator()
116
117         layout.prop(st, "show_frame_indicator")
118         layout.prop(st, "show_only_selected")
119
120         layout.separator()
121
122         layout.menu("TIME_MT_cache")
123
124         layout.separator()
125
126         layout.operator("marker.camera_bind")
127
128
129 class TIME_MT_cache(Menu):
130     bl_label = "Cache"
131
132     def draw(self, context):
133         layout = self.layout
134
135         st = context.space_data
136
137         layout.prop(st, "show_cache")
138
139         layout.separator()
140
141         col = layout.column()
142         col.enabled = st.show_cache
143         col.prop(st, "cache_softbody")
144         col.prop(st, "cache_particles")
145         col.prop(st, "cache_cloth")
146         col.prop(st, "cache_smoke")
147
148
149 class TIME_MT_frame(Menu):
150     bl_label = "Frame"
151
152     def draw(self, context):
153         layout = self.layout
154
155         layout.operator("time.start_frame_set")
156         layout.operator("time.end_frame_set")
157
158         layout.separator()
159
160         sub = layout.row()
161         sub.menu("TIME_MT_autokey")
162
163
164 class TIME_MT_playback(Menu):
165     bl_label = "Playback"
166
167     def draw(self, context):
168         layout = self.layout
169
170         screen = context.screen
171         scene = context.scene
172
173         layout.prop(screen, "use_play_top_left_3d_editor")
174         layout.prop(screen, "use_play_3d_editors")
175         layout.prop(screen, "use_play_animation_editors")
176         layout.prop(screen, "use_play_properties_editors")
177         layout.prop(screen, "use_play_image_editors")
178         layout.prop(screen, "use_play_sequence_editors")
179         layout.prop(screen, "use_play_node_editors")
180
181         layout.separator()
182
183         layout.prop(scene, "use_frame_drop", text="Frame Dropping")
184         layout.prop(scene, "use_audio_sync", text="AV-sync", icon='SPEAKER')
185         layout.prop(scene, "use_audio")
186         layout.prop(scene, "use_audio_scrub")
187
188
189 class TIME_MT_autokey(Menu):
190     bl_label = "Auto-Keyframing Mode"
191
192     def draw(self, context):
193         layout = self.layout
194         tools = context.tool_settings
195
196         layout.prop_enum(tools, "auto_keying_mode", 'ADD_REPLACE_KEYS')
197         layout.prop_enum(tools, "auto_keying_mode", 'REPLACE_KEYS')
198
199
200 def marker_menu_generic(layout):
201
202     #layout.operator_context = 'EXEC_REGION_WIN'
203
204     layout.column()
205     layout.operator("marker.add", "Add Marker")
206     layout.operator("marker.duplicate", text="Duplicate Marker")
207
208     if(len(bpy.data.scenes) > 10):
209         layout.operator_context = 'INVOKE_DEFAULT'
210         layout.operator("marker.make_links_scene", text="Duplicate Marker to Scene...", icon='OUTLINER_OB_EMPTY')
211     else:
212         layout.operator_menu_enum("marker.make_links_scene", "scene", text="Duplicate Marker to Scene...")
213
214     layout.operator("marker.delete", text="Delete Marker")
215
216     layout.separator()
217
218     layout.operator("marker.rename", text="Rename Marker")
219     layout.operator("marker.move", text="Grab/Move Marker")
220
221
222 if __name__ == "__main__":  # only for live edit.
223     bpy.utils.register_module(__name__)