operator renaming for more consistent word ordering (_add/_remmove shold be last...
[blender.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='ICON_REW').end = False
58         row.operator("screen.keyframe_jump", text="", icon='ICON_PREV_KEYFRAME').next = False
59         if not screen.animation_playing:
60             row.operator("screen.animation_play", text="", icon='ICON_PLAY_REVERSE').reverse = True
61             row.operator("screen.animation_play", text="", icon='ICON_PLAY')
62         else:
63             sub = row.row()
64             sub.scale_x = 2.0
65             sub.operator("screen.animation_play", text="", icon='ICON_PAUSE')
66         row.operator("screen.keyframe_jump", text="", icon='ICON_NEXT_KEYFRAME').next = True
67         row.operator("screen.frame_jump", text="", icon='ICON_FF').end = True
68
69         row = layout.row(align=True)
70         row.prop(tools, "enable_auto_key", text="", toggle=True, icon='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='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='ICON_KEY_HLT')
82         row.operator("anim.keyframe_delete", text="", icon='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
95         layout.separator()
96
97         layout.prop(st, "only_selected")
98
99
100 class TIME_MT_frame(bpy.types.Menu):
101     bl_label = "Frame"
102
103     def draw(self, context):
104         layout = self.layout
105         # tools = context.tool_settings
106
107         layout.operator("marker.add", text="Add Marker")
108         layout.operator("marker.duplicate", text="Duplicate Marker")
109         layout.operator("marker.move", text="Grab/Move Marker")
110         layout.operator("marker.delete", text="Delete Marker")
111         layout.label(text="ToDo: Name Marker")
112
113         layout.separator()
114
115         layout.operator("time.start_frame_set")
116         layout.operator("time.end_frame_set")
117
118         layout.separator()
119
120         sub = layout.row()
121         #sub.active = tools.enable_auto_key
122         sub.menu("TIME_MT_autokey")
123
124
125 class TIME_MT_playback(bpy.types.Menu):
126     bl_label = "Playback"
127
128     def draw(self, context):
129         layout = self.layout
130
131         st = context.space_data
132         scene = context.scene
133
134         layout.prop(st, "play_top_left")
135         layout.prop(st, "play_all_3d")
136         layout.prop(st, "play_anim")
137         layout.prop(st, "play_buttons")
138         layout.prop(st, "play_image")
139         layout.prop(st, "play_sequencer")
140         layout.prop(st, "play_nodes")
141
142         layout.separator()
143
144         layout.prop(st, "continue_physics")
145
146         layout.separator()
147
148         layout.prop(scene, "sync_audio", text="Realtime Playback", icon='ICON_SPEAKER')
149         layout.prop(scene, "mute_audio")
150         layout.prop(scene, "scrub_audio")
151
152
153 class TIME_MT_autokey(bpy.types.Menu):
154     bl_label = "Auto-Keyframing Mode"
155
156     def draw(self, context):
157         layout = self.layout
158         tools = context.tool_settings
159
160         layout.active = tools.enable_auto_key
161
162         layout.prop_enum(tools, "autokey_mode", 'ADD_REPLACE_KEYS')
163         layout.prop_enum(tools, "autokey_mode", 'REPLACE_KEYS')
164
165 bpy.types.register(TIME_HT_header)
166 bpy.types.register(TIME_MT_view)
167 bpy.types.register(TIME_MT_frame)
168 bpy.types.register(TIME_MT_autokey)
169 bpy.types.register(TIME_MT_playback)