menus are now global (like operators), so for eg, the info add menu and the 3D add...
[blender-staging.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         __label__ = "View"
68
69         def draw(self, context):
70                 layout = self.layout
71                 
72                 st = context.space_data
73                 
74                 layout.itemO("anim.time_toggle")
75                 
76                 layout.itemS()
77                 
78                 layout.itemR(st, "only_selected")
79
80 class TIME_MT_frame(bpy.types.Menu):
81         __label__ = "Frame"
82
83         def draw(self, context):
84                 layout = self.layout
85                 tools = context.tool_settings
86                 
87                 layout.itemO("marker.add", text="Add Marker")
88                 layout.itemO("marker.duplicate", text="Duplicate Marker")
89                 layout.itemO("marker.move", text="Grab/Move Marker")
90                 layout.itemO("marker.delete", text="Delete Marker")
91                 layout.itemL(text="ToDo: Name Marker")
92                 
93                 layout.itemS()
94                 
95                 layout.itemO("time.start_frame_set")
96                 layout.itemO("time.end_frame_set")
97                 
98                 layout.itemS()
99                 
100                 sub = layout.row()
101                 #sub.active = tools.enable_auto_key
102                 sub.itemM("TIME_MT_autokey")
103
104 class TIME_MT_playback(bpy.types.Menu):
105         __label__ = "Playback"
106
107         def draw(self, context):
108                 layout = self.layout
109                 
110                 st = context.space_data
111                 scene = context.scene
112                 
113                 layout.itemR(st, "play_top_left")
114                 layout.itemR(st, "play_all_3d")
115                 layout.itemR(st, "play_anim")
116                 layout.itemR(st, "play_buttons")
117                 layout.itemR(st, "play_image")
118                 layout.itemR(st, "play_sequencer")
119                 layout.itemR(st, "play_nodes")
120                 
121                 layout.itemS()
122                 
123                 layout.itemR(st, "continue_physics")
124                 
125                 layout.itemS()
126                 
127                 layout.itemR(scene, "sync_audio", icon='ICON_SPEAKER')
128                 layout.itemR(scene, "mute_audio")
129                 layout.itemR(scene, "scrub_audio")
130
131 class TIME_MT_autokey(bpy.types.Menu):
132         __label__ = "Auto-Keyframing Mode"
133
134         def draw(self, context):
135                 layout = self.layout
136                 tools = context.tool_settings
137                 
138                 layout.active = tools.enable_auto_key
139                 
140                 layout.item_enumR(tools, "autokey_mode", 'ADD_REPLACE_KEYS')
141                 layout.item_enumR(tools, "autokey_mode", 'REPLACE_KEYS')
142
143 bpy.types.register(TIME_HT_header)
144 bpy.types.register(TIME_MT_view)
145 bpy.types.register(TIME_MT_frame)
146 bpy.types.register(TIME_MT_autokey)
147 bpy.types.register(TIME_MT_playback)