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