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