Merge with -r 22620:23107.
[blender.git] / release / 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                 rd = context.scene.render_data
13                 tools = context.tool_settings
14                 screen = context.screen
15
16                 row = layout.row(align=True)
17                 row.template_header()
18
19                 if context.area.show_menus:
20                         sub = row.row(align=True)
21                         sub.itemM("TIME_MT_view")
22                         sub.itemM("TIME_MT_frame")
23                         sub.itemM("TIME_MT_playback")
24
25                 layout.itemR(scene, "use_preview_range", text="PR")
26                 
27                 row = layout.row(align=True)
28                 if not scene.use_preview_range:
29                         row.itemR(scene, "start_frame", text="Start")
30                         row.itemR(scene, "end_frame", text="End")
31                 else:
32                         row.itemR(scene, "preview_range_start_frame", text="Start")
33                         row.itemR(scene, "preview_range_end_frame", text="End")
34                 
35                 layout.itemR(scene, "current_frame", text="")
36                 
37                 layout.itemS()
38
39                 row = layout.row(align=True)
40                 row.item_booleanO("screen.frame_jump", "end", False, text="", icon='ICON_REW')
41                 row.item_booleanO("screen.keyframe_jump", "next", False, text="", icon='ICON_PREV_KEYFRAME')
42                 if not screen.animation_playing:
43                         row.item_booleanO("screen.animation_play", "reverse", True, text="", icon='ICON_PLAY_REVERSE')
44                         row.itemO("screen.animation_play", text="", icon='ICON_PLAY')
45                 else:
46                         sub = row.row()
47                         sub.scale_x = 2.0
48                         sub.itemO("screen.animation_play", text="", icon='ICON_PAUSE')
49                 row.item_booleanO("screen.keyframe_jump", "next", True, text="", icon='ICON_NEXT_KEYFRAME')
50                 row.item_booleanO("screen.frame_jump", "end", True, text="", icon='ICON_FF')
51                 
52                 row = layout.row(align=True)
53                 row.itemR(tools, "enable_auto_key", text="", toggle=True, icon='ICON_REC')
54                 if screen.animation_playing and tools.enable_auto_key:
55                         subsub = row.row()
56                         subsub.itemR(tools, "record_with_nla", toggle=True)
57                         
58                 layout.itemR(rd, "sync_audio", text="", toggle=True, icon='ICON_SPEAKER')
59                 
60                 layout.itemS()
61                 
62                 row = layout.row(align=True)
63                 row.item_pointerR(scene, "active_keying_set", scene, "keying_sets", text="")
64                 row.itemO("anim.insert_keyframe", text="", icon='ICON_KEY_HLT')
65                 row.itemO("anim.delete_keyframe", text="", icon='ICON_KEY_DEHLT')
66
67 class TIME_MT_view(bpy.types.Menu):
68         __space_type__ = 'TIMELINE'
69         __label__ = "View"
70
71         def draw(self, context):
72                 layout = self.layout
73                 
74                 st = context.space_data
75                 
76                 layout.itemO("anim.time_toggle")
77                 
78                 layout.itemS()
79                 
80                 layout.itemR(st, "only_selected")
81
82 class TIME_MT_frame(bpy.types.Menu):
83         __space_type__ = 'TIMELINE'
84         __label__ = "Frame"
85
86         def draw(self, context):
87                 layout = self.layout
88                 tools = context.tool_settings
89                 
90                 layout.itemO("marker.add", text="Add Marker")
91                 layout.itemO("marker.duplicate", text="Duplicate Marker")
92                 layout.itemO("marker.move", text="Grab/Move Marker")
93                 layout.itemO("marker.delete", text="Delete Marker")
94                 layout.itemL(text="ToDo: Name Marker")
95                 
96                 layout.itemS()
97                 
98                 layout.itemO("time.start_frame_set")
99                 layout.itemO("time.end_frame_set")
100                 
101                 layout.itemS()
102                 
103                 sub = layout.row()
104                 sub.active = tools.enable_auto_key
105                 sub.itemM("TIME_MT_autokey")
106
107 class TIME_MT_playback(bpy.types.Menu):
108         __space_type__ = 'TIMELINE'
109         __label__ = "Playback"
110
111         def draw(self, context):
112                 layout = self.layout
113                 
114                 st = context.space_data
115                 rd = context.scene.render_data
116                 
117                 layout.itemR(st, "play_top_left")
118                 layout.itemR(st, "play_all_3d")
119                 layout.itemR(st, "play_anim")
120                 layout.itemR(st, "play_buttons")
121                 layout.itemR(st, "play_image")
122                 layout.itemR(st, "play_sequencer")
123                 
124                 layout.itemS()
125                 
126                 layout.itemR(st, "continue_physics")
127                 
128                 layout.itemS()
129                 
130                 layout.itemR(rd, "sync_audio", icon='ICON_SPEAKER')
131
132                 
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)