Moving classes to separate listing broke panel order
[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         layout.prop(st, "show_locked_time")
78
79         layout.prop(st, "show_strip_curves")
80         layout.prop(st, "show_local_markers")
81
82         layout.separator()
83         layout.operator("anim.previewrange_set")
84         layout.operator("anim.previewrange_clear")
85         layout.operator("nla.previewrange_set")
86
87         layout.separator()
88         layout.operator("nla.view_all")
89         layout.operator("nla.view_selected")
90         layout.operator("nla.view_frame")
91
92         layout.separator()
93         layout.operator("screen.area_dupli")
94         layout.operator("screen.screen_full_area")
95         layout.operator("screen.screen_full_area", text="Toggle Fullscreen Area").use_hide_panels = True
96
97
98 class NLA_MT_select(Menu):
99     bl_label = "Select"
100
101     def draw(self, context):
102         layout = self.layout
103
104         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
105         layout.operator("nla.select_all_toggle").invert = False
106         layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True
107
108         layout.separator()
109         layout.operator("nla.select_border").axis_range = False
110         layout.operator("nla.select_border", text="Border Axis Range").axis_range = True
111
112         layout.separator()
113         props = layout.operator("nla.select_leftright", text="Before Current Frame")
114         props.extend = False
115         props.mode = 'LEFT'
116         props = layout.operator("nla.select_leftright", text="After Current Frame")
117         props.extend = False
118         props.mode = 'RIGHT'
119
120
121 class NLA_MT_marker(Menu):
122     bl_label = "Marker"
123
124     def draw(self, context):
125         layout = self.layout
126
127         from bl_ui.space_time import marker_menu_generic
128         marker_menu_generic(layout)
129
130
131 class NLA_MT_edit(Menu):
132     bl_label = "Edit"
133
134     def draw(self, context):
135         layout = self.layout
136
137         scene = context.scene
138
139         layout.menu("NLA_MT_edit_transform", text="Transform")
140
141         layout.operator_menu_enum("nla.snap", "type", text="Snap")
142
143         layout.separator()
144         layout.operator("nla.duplicate", text="Duplicate").linked = False
145         layout.operator("nla.duplicate", text="Linked Duplicate").linked = True
146         layout.operator("nla.split")
147         layout.operator("nla.delete")
148
149         layout.separator()
150         layout.operator("nla.mute_toggle")
151
152         layout.separator()
153         layout.operator("nla.apply_scale")
154         layout.operator("nla.clear_scale")
155         layout.operator("nla.action_sync_length").active = False
156
157         layout.separator()
158         layout.operator("nla.make_single_user")
159
160         layout.separator()
161         layout.operator("nla.swap")
162         layout.operator("nla.move_up")
163         layout.operator("nla.move_down")
164
165         # TODO: this really belongs more in a "channel" (or better, "track") menu
166         layout.separator()
167         layout.operator_menu_enum("anim.channels_move", "direction", text="Track Ordering...")
168         layout.operator("anim.channels_clean_empty")
169
170         layout.separator()
171         # TODO: names of these tools for 'tweak-mode' need changing?
172         if scene.is_nla_tweakmode:
173             layout.operator("nla.tweakmode_exit", text="Stop Editing Stashed Action").isolate_action = True
174             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
175         else:
176             layout.operator("nla.tweakmode_enter", text="Start Editing Stashed Action").isolate_action = True
177             layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
178
179
180 class NLA_MT_add(Menu):
181     bl_label = "Add"
182
183     def draw(self, context):
184         layout = self.layout
185
186         layout.operator("nla.actionclip_add")
187         layout.operator("nla.transition_add")
188         layout.operator("nla.soundclip_add")
189
190         layout.separator()
191         layout.operator("nla.meta_add")
192         layout.operator("nla.meta_remove")
193
194         layout.separator()
195         layout.operator("nla.tracks_add").above_selected = False
196         layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
197
198         layout.separator()
199         layout.operator("nla.selected_objects_add")
200
201
202 class NLA_MT_edit_transform(Menu):
203     bl_label = "Transform"
204
205     def draw(self, context):
206         layout = self.layout
207
208         layout.operator("transform.translate", text="Grab/Move")
209         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
210         layout.operator("transform.transform", text="Scale").mode = 'TIME_SCALE'
211
212
213 classes = (
214     NLA_HT_header,
215     NLA_MT_edit,
216     NLA_MT_editor_menus,
217     NLA_MT_view,
218     NLA_MT_select,
219     NLA_MT_marker,
220     NLA_MT_add,
221     NLA_MT_edit_transform,
222 )
223
224 if __name__ == "__main__":  # only for live edit.
225     from bpy.utils import register_class
226     for cls in classes:
227         register_class(cls)