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