7408868f10aeb5dd5fdbe97c018bc1d3479f9443
[blender-staging.git] / release / scripts / ui / space_time.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6
7 import bpy
8
9 class TIME_HT_header(bpy.types.Header):
10     bl_space_type = 'TIMELINE'
11
12     def draw(self, context):
13         layout = self.layout
14
15         st = context.space_data
16         scene = context.scene
17         tools = context.tool_settings
18         screen = context.screen
19
20         row = layout.row(align=True)
21         row.template_header()
22
23         if context.area.show_menus:
24             sub = row.row(align=True)
25             sub.itemM("TIME_MT_view")
26             sub.itemM("TIME_MT_frame")
27             sub.itemM("TIME_MT_playback")
28
29         layout.itemR(scene, "use_preview_range", text="PR")
30
31         row = layout.row(align=True)
32         if not scene.use_preview_range:
33             row.itemR(scene, "start_frame", text="Start")
34             row.itemR(scene, "end_frame", text="End")
35         else:
36             row.itemR(scene, "preview_range_start_frame", text="Start")
37             row.itemR(scene, "preview_range_end_frame", text="End")
38
39         layout.itemR(scene, "current_frame", text="")
40
41         layout.itemS()
42
43         row = layout.row(align=True)
44         row.item_booleanO("screen.frame_jump", "end", False, text="", icon='ICON_REW')
45         row.item_booleanO("screen.keyframe_jump", "next", False, text="", icon='ICON_PREV_KEYFRAME')
46         if not screen.animation_playing:
47             row.item_booleanO("screen.animation_play", "reverse", True, text="", icon='ICON_PLAY_REVERSE')
48             row.itemO("screen.animation_play", text="", icon='ICON_PLAY')
49         else:
50             sub = row.row()
51             sub.scale_x = 2.0
52             sub.itemO("screen.animation_play", text="", icon='ICON_PAUSE')
53         row.item_booleanO("screen.keyframe_jump", "next", True, text="", icon='ICON_NEXT_KEYFRAME')
54         row.item_booleanO("screen.frame_jump", "end", True, text="", icon='ICON_FF')
55
56         row = layout.row(align=True)
57         row.itemR(tools, "enable_auto_key", text="", toggle=True, icon='ICON_REC')
58         if screen.animation_playing and tools.enable_auto_key:
59             subsub = row.row()
60             subsub.itemR(tools, "record_with_nla", toggle=True)
61
62         layout.itemR(scene, "sync_audio", text="", toggle=True, icon='ICON_SPEAKER')
63
64         layout.itemS()
65
66         row = layout.row(align=True)
67         row.item_pointerR(scene, "active_keying_set", scene, "keying_sets", text="")
68         row.itemO("anim.insert_keyframe", text="", icon='ICON_KEY_HLT')
69         row.itemO("anim.delete_keyframe", text="", icon='ICON_KEY_DEHLT')
70
71 class TIME_MT_view(bpy.types.Menu):
72     bl_label = "View"
73
74     def draw(self, context):
75         layout = self.layout
76
77         st = context.space_data
78
79         layout.itemO("anim.time_toggle")
80
81         layout.itemS()
82
83         layout.itemR(st, "only_selected")
84
85 class TIME_MT_frame(bpy.types.Menu):
86     bl_label = "Frame"
87
88     def draw(self, context):
89         layout = self.layout
90         tools = context.tool_settings
91
92         layout.itemO("marker.add", text="Add Marker")
93         layout.itemO("marker.duplicate", text="Duplicate Marker")
94         layout.itemO("marker.move", text="Grab/Move Marker")
95         layout.itemO("marker.delete", text="Delete Marker")
96         layout.itemL(text="ToDo: Name Marker")
97
98         layout.itemS()
99
100         layout.itemO("time.start_frame_set")
101         layout.itemO("time.end_frame_set")
102
103         layout.itemS()
104
105         sub = layout.row()
106         #sub.active = tools.enable_auto_key
107         sub.itemM("TIME_MT_autokey")
108
109 class TIME_MT_playback(bpy.types.Menu):
110     bl_label = "Playback"
111
112     def draw(self, context):
113         layout = self.layout
114
115         st = context.space_data
116         scene = context.scene
117
118         layout.itemR(st, "play_top_left")
119         layout.itemR(st, "play_all_3d")
120         layout.itemR(st, "play_anim")
121         layout.itemR(st, "play_buttons")
122         layout.itemR(st, "play_image")
123         layout.itemR(st, "play_sequencer")
124         layout.itemR(st, "play_nodes")
125
126         layout.itemS()
127
128         layout.itemR(st, "continue_physics")
129
130         layout.itemS()
131
132         layout.itemR(scene, "sync_audio", icon='ICON_SPEAKER')
133         layout.itemR(scene, "mute_audio")
134         layout.itemR(scene, "scrub_audio")
135
136 class TIME_MT_autokey(bpy.types.Menu):
137     bl_label = "Auto-Keyframing Mode"
138
139     def draw(self, context):
140         layout = self.layout
141         tools = context.tool_settings
142
143         layout.active = tools.enable_auto_key
144
145         layout.item_enumR(tools, "autokey_mode", 'ADD_REPLACE_KEYS')
146         layout.item_enumR(tools, "autokey_mode", 'REPLACE_KEYS')
147
148 bpy.types.register(TIME_HT_header)
149 bpy.types.register(TIME_MT_view)
150 bpy.types.register(TIME_MT_frame)
151 bpy.types.register(TIME_MT_autokey)
152 bpy.types.register(TIME_MT_playback)