Sound clip NLA Strips for Nexyon
[blender-staging.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
23
24 class NLA_HT_header(bpy.types.Header):
25     bl_space_type = 'NLA_EDITOR'
26
27     def draw(self, context):
28         from bl_ui.space_dopesheet import dopesheet_filter
29
30         layout = self.layout
31
32         st = context.space_data
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         if context.area.show_menus:
38             sub = row.row(align=True)
39
40             sub.menu("NLA_MT_view")
41             sub.menu("NLA_MT_select")
42             sub.menu("NLA_MT_marker")
43             sub.menu("NLA_MT_edit")
44             sub.menu("NLA_MT_add")
45
46         dopesheet_filter(layout, context)
47
48         layout.prop(st, "auto_snap", text="")
49
50
51 class NLA_MT_view(bpy.types.Menu):
52     bl_label = "View"
53
54     def draw(self, context):
55         layout = self.layout
56
57         st = context.space_data
58
59         layout.column()
60
61         layout.operator("nla.properties", icon='MENU_PANEL')
62
63         layout.separator()
64
65         layout.prop(st, "use_realtime_update")
66         layout.prop(st, "show_frame_indicator")
67
68         layout.operator("anim.time_toggle", text="Show Frames" if st.show_seconds else "Show Seconds")
69
70         layout.prop(st, "show_strip_curves")
71
72         layout.separator()
73         layout.operator("anim.previewrange_set")
74         layout.operator("anim.previewrange_clear")
75         
76         layout.separator()
77         layout.operator("nla.view_all")
78         layout.operator("nla.view_selected")
79         
80         layout.separator()
81         layout.operator("screen.area_dupli")
82         layout.operator("screen.screen_full_area")
83
84
85 class NLA_MT_select(bpy.types.Menu):
86     bl_label = "Select"
87
88     def draw(self, context):
89         layout = self.layout
90
91         layout.column()
92         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
93         layout.operator("nla.select_all_toggle")
94         layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True
95
96         layout.separator()
97         layout.operator("nla.select_border")
98         layout.operator("nla.select_border", text="Border Axis Range").axis_range = True
99
100         layout.separator()
101         layout.operator("nla.select_leftright", text="Before Current Frame").mode = 'LEFT'
102         layout.operator("nla.select_leftright", text="After Current Frame").mode = 'RIGHT'
103
104
105 class NLA_MT_marker(bpy.types.Menu):
106     bl_label = "Marker"
107
108     def draw(self, context):
109         layout = self.layout
110
111         #layout.operator_context = 'EXEC_REGION_WIN'
112
113         layout.column()
114         layout.operator("marker.add", "Add Marker")
115         layout.operator("marker.duplicate", text="Duplicate Marker")
116         layout.operator("marker.delete", text="Delete Marker")
117
118         layout.separator()
119
120         layout.operator("marker.rename", text="Rename Marker")
121         layout.operator("marker.move", text="Grab/Move Marker")
122
123
124 class NLA_MT_edit(bpy.types.Menu):
125     bl_label = "Edit"
126
127     def draw(self, context):
128         layout = self.layout
129
130         scene = context.scene
131
132         layout.column()
133         layout.menu("NLA_MT_edit_transform", text="Transform")
134
135         layout.operator_menu_enum("nla.snap", "type", text="Snap")
136
137         layout.separator()
138         layout.operator("nla.duplicate")
139         layout.operator("nla.split")
140         layout.operator("nla.delete")
141
142         layout.separator()
143         layout.operator("nla.mute_toggle")
144
145         layout.separator()
146         layout.operator("nla.apply_scale")
147         layout.operator("nla.clear_scale")
148         layout.operator("nla.action_sync_length").active = False
149
150         layout.separator()
151         layout.operator("nla.swap")
152         layout.operator("nla.move_up")
153         layout.operator("nla.move_down")
154
155         # TODO: this really belongs more in a "channel" (or better, "track") menu
156         layout.separator()
157         layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
158
159         layout.separator()
160         # TODO: names of these tools for 'tweakmode' need changing?
161         if scene.is_nla_tweakmode:
162             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
163         else:
164             layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
165
166
167 class NLA_MT_add(bpy.types.Menu):
168     bl_label = "Add"
169
170     def draw(self, context):
171         layout = self.layout
172
173         layout.column()
174         layout.operator("nla.actionclip_add")
175         layout.operator("nla.transition_add")
176         layout.operator("nla.soundclip_add")
177
178         layout.separator()
179         layout.operator("nla.meta_add")
180         layout.operator("nla.meta_remove")
181
182         layout.separator()
183         layout.operator("nla.tracks_add")
184         layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
185
186
187 class NLA_MT_edit_transform(bpy.types.Menu):
188     bl_label = "Transform"
189
190     def draw(self, context):
191         layout = self.layout
192
193         layout.column()
194         layout.operator("transform.translate", text="Grab/Move")
195         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
196         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
197
198 if __name__ == "__main__":  # only for live edit.
199     bpy.utils.register_module(__name__)