Merging r43501 through r43720 form trunk into soc-2011-tomato
[blender.git] / release / scripts / startup / bl_ui / space_nla.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20
21 import bpy
22 from bpy.types import Header, Menu
23
24
25 class NLA_HT_header(Header):
26     bl_space_type = 'NLA_EDITOR'
27
28     def draw(self, context):
29         from .space_dopesheet import dopesheet_filter
30
31         layout = self.layout
32
33         st = context.space_data
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         if context.area.show_menus:
39             row.menu("NLA_MT_view")
40             row.menu("NLA_MT_select")
41             row.menu("NLA_MT_marker")
42             row.menu("NLA_MT_edit")
43             row.menu("NLA_MT_add")
44
45         dopesheet_filter(layout, context)
46
47         layout.prop(st, "auto_snap", text="")
48
49
50 class NLA_MT_view(Menu):
51     bl_label = "View"
52
53     def draw(self, context):
54         layout = self.layout
55
56         st = context.space_data
57
58         layout.operator("nla.properties", icon='MENU_PANEL')
59
60         layout.separator()
61
62         layout.prop(st, "use_realtime_update")
63         layout.prop(st, "show_frame_indicator")
64
65         layout.prop(st, "show_seconds")
66
67         layout.prop(st, "show_strip_curves")
68
69         layout.separator()
70         layout.operator("anim.previewrange_set")
71         layout.operator("anim.previewrange_clear")
72
73         layout.separator()
74         layout.operator("nla.view_all")
75         layout.operator("nla.view_selected")
76
77         layout.separator()
78         layout.operator("screen.area_dupli")
79         layout.operator("screen.screen_full_area")
80
81
82 class NLA_MT_select(Menu):
83     bl_label = "Select"
84
85     def draw(self, context):
86         layout = self.layout
87
88         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
89         layout.operator("nla.select_all_toggle").invert = False
90         layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True
91
92         layout.separator()
93         layout.operator("nla.select_border").axis_range = False
94         layout.operator("nla.select_border", text="Border Axis Range").axis_range = True
95
96         layout.separator()
97         layout.operator("nla.select_leftright", text="Before Current Frame").mode = 'LEFT'
98         layout.operator("nla.select_leftright", text="After Current Frame").mode = 'RIGHT'
99
100
101 class NLA_MT_marker(Menu):
102     bl_label = "Marker"
103
104     def draw(self, context):
105         layout = self.layout
106
107         from .space_time import marker_menu_generic
108         marker_menu_generic(layout)
109
110
111 class NLA_MT_edit(Menu):
112     bl_label = "Edit"
113
114     def draw(self, context):
115         layout = self.layout
116
117         scene = context.scene
118
119         layout.menu("NLA_MT_edit_transform", text="Transform")
120
121         layout.operator_menu_enum("nla.snap", "type", text="Snap")
122
123         layout.separator()
124         layout.operator("nla.duplicate")
125         layout.operator("nla.split")
126         layout.operator("nla.delete")
127
128         layout.separator()
129         layout.operator("nla.mute_toggle")
130
131         layout.separator()
132         layout.operator("nla.apply_scale")
133         layout.operator("nla.clear_scale")
134         layout.operator("nla.action_sync_length").active = False
135
136         layout.separator()
137         layout.operator("nla.swap")
138         layout.operator("nla.move_up")
139         layout.operator("nla.move_down")
140
141         # TODO: this really belongs more in a "channel" (or better, "track") menu
142         layout.separator()
143         layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
144
145         layout.separator()
146         # TODO: names of these tools for 'tweakmode' need changing?
147         if scene.is_nla_tweakmode:
148             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
149         else:
150             layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
151
152
153 class NLA_MT_add(Menu):
154     bl_label = "Add"
155
156     def draw(self, context):
157         layout = self.layout
158
159         layout.operator("nla.actionclip_add")
160         layout.operator("nla.transition_add")
161         layout.operator("nla.soundclip_add")
162
163         layout.separator()
164         layout.operator("nla.meta_add")
165         layout.operator("nla.meta_remove")
166
167         layout.separator()
168         layout.operator("nla.tracks_add").above_selected = False
169         layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
170
171
172 class NLA_MT_edit_transform(Menu):
173     bl_label = "Transform"
174
175     def draw(self, context):
176         layout = self.layout
177
178         layout.operator("transform.translate", text="Grab/Move")
179         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
180         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
181
182 if __name__ == "__main__":  # only for live edit.
183     bpy.utils.register_module(__name__)