camera switching via markers
[blender-staging.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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="PR")
43
44         row = layout.row(align=True)
45         if not scene.use_preview_range:
46             row.prop(scene, "start_frame", text="Start")
47             row.prop(scene, "end_frame", text="End")
48         else:
49             row.prop(scene, "preview_range_start_frame", text="Start")
50             row.prop(scene, "preview_range_end_frame", text="End")
51
52         layout.prop(scene, "current_frame", 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.animation_playing:
60             row.operator("screen.animation_play", text="", icon='PLAY_REVERSE').reverse = True
61             row.operator("screen.animation_play", text="", icon='PLAY')
62         else:
63             sub = row.row()
64             sub.scale_x = 2.0
65             sub.operator("screen.animation_play", text="", icon='PAUSE')
66         row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
67         row.operator("screen.frame_jump", text="", icon='FF').end = True
68
69         row = layout.row(align=True)
70         row.prop(tools, "enable_auto_key", text="", toggle=True, icon='REC')
71         if screen.animation_playing and tools.enable_auto_key:
72             subsub = row.row()
73             subsub.prop(tools, "record_with_nla", toggle=True)
74
75         layout.prop(scene, "sync_audio", text="Realtime", toggle=True, icon='SPEAKER')
76
77         layout.separator()
78
79         row = layout.row(align=True)
80         row.prop_object(scene, "active_keying_set", scene, "keying_sets", text="")
81         row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
82         row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
83
84
85 class TIME_MT_view(bpy.types.Menu):
86     bl_label = "View"
87
88     def draw(self, context):
89         layout = self.layout
90
91         st = context.space_data
92
93         layout.operator("anim.time_toggle")
94         layout.operator("time.view_all")
95
96         layout.separator()
97
98         layout.prop(st, "show_cframe_indicator")
99         layout.prop(st, "only_selected")
100
101         layout.separator()
102
103         layout.operator("marker.camera_bind")
104
105 class TIME_MT_frame(bpy.types.Menu):
106     bl_label = "Frame"
107
108     def draw(self, context):
109         layout = self.layout
110         # tools = context.tool_settings
111
112         layout.operator("marker.add", text="Add Marker")
113         layout.operator("marker.duplicate", text="Duplicate Marker")
114         layout.operator("marker.move", text="Grab/Move Marker")
115         layout.operator("marker.delete", text="Delete Marker")
116         layout.label(text="ToDo: Name Marker")
117
118         layout.separator()
119
120         layout.operator("time.start_frame_set")
121         layout.operator("time.end_frame_set")
122
123         layout.separator()
124
125         sub = layout.row()
126         #sub.active = tools.enable_auto_key
127         sub.menu("TIME_MT_autokey")
128
129
130 class TIME_MT_playback(bpy.types.Menu):
131     bl_label = "Playback"
132
133     def draw(self, context):
134         layout = self.layout
135
136         st = context.space_data
137         scene = context.scene
138
139         layout.prop(st, "play_top_left")
140         layout.prop(st, "play_all_3d")
141         layout.prop(st, "play_anim")
142         layout.prop(st, "play_buttons")
143         layout.prop(st, "play_image")
144         layout.prop(st, "play_sequencer")
145         layout.prop(st, "play_nodes")
146
147         layout.separator()
148
149         layout.prop(scene, "sync_audio", text="Realtime Playback", icon='SPEAKER')
150         layout.prop(scene, "mute_audio")
151         layout.prop(scene, "scrub_audio")
152
153
154 class TIME_MT_autokey(bpy.types.Menu):
155     bl_label = "Auto-Keyframing Mode"
156
157     def draw(self, context):
158         layout = self.layout
159         tools = context.tool_settings
160
161         layout.active = tools.enable_auto_key
162
163         layout.prop_enum(tools, "autokey_mode", 'ADD_REPLACE_KEYS')
164         layout.prop_enum(tools, "autokey_mode", 'REPLACE_KEYS')
165
166 bpy.types.register(TIME_HT_header)
167 bpy.types.register(TIME_MT_view)
168 bpy.types.register(TIME_MT_frame)
169 bpy.types.register(TIME_MT_autokey)
170 bpy.types.register(TIME_MT_playback)