12ed8aa77407e4ae1abe1dcd39e4280d573af3f0
[blender.git] / release / scripts / 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         layout = self.layout
29
30         st = context.space_data
31
32         row = layout.row(align=True)
33         row.template_header()
34
35         if context.area.show_menus:
36             sub = row.row(align=True)
37
38             sub.menu("NLA_MT_view")
39             sub.menu("NLA_MT_select")
40             sub.menu("NLA_MT_edit")
41             sub.menu("NLA_MT_add")
42
43         layout.template_dopesheet_filter(st.dopesheet)
44
45         layout.prop(st, "autosnap", text="")
46
47
48 class NLA_MT_view(bpy.types.Menu):
49     bl_label = "View"
50
51     def draw(self, context):
52         layout = self.layout
53
54         st = context.space_data
55
56         layout.column()
57
58         layout.operator("nla.properties", icon='MENU_PANEL')
59
60         layout.separator()
61
62         layout.prop(st, "realtime_updates")
63         layout.prop(st, "show_cframe_indicator")
64
65         layout.operator("anim.time_toggle", text="Show Frames" if st.show_seconds else "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("screen.area_dupli")
75         layout.operator("screen.screen_full_area")
76
77
78 class NLA_MT_select(bpy.types.Menu):
79     bl_label = "Select"
80
81     def draw(self, context):
82         layout = self.layout
83
84         layout.column()
85         # This is a bit misleading as the operator's default text is "Select All" while it actually *toggles* All/None
86         layout.operator("nla.select_all_toggle")
87         layout.operator("nla.select_all_toggle", text="Invert Selection").invert = True
88
89         layout.separator()
90         layout.operator("nla.select_border")
91         layout.operator("nla.select_border", text="Border Axis Range").axis_range = True
92
93
94 class NLA_MT_edit(bpy.types.Menu):
95     bl_label = "Edit"
96
97     def draw(self, context):
98         layout = self.layout
99
100         scene = context.scene
101
102         layout.column()
103         layout.menu("NLA_MT_edit_transform", text="Transform")
104
105         layout.operator_menu_enum("nla.snap", property="type", text="Snap")
106
107         layout.separator()
108         layout.operator("nla.duplicate")
109         layout.operator("nla.split")
110         layout.operator("nla.delete")
111
112         layout.separator()
113         layout.operator("nla.mute_toggle")
114
115         layout.separator()
116         layout.operator("nla.apply_scale")
117         layout.operator("nla.clear_scale")
118
119         layout.separator()
120         layout.operator("nla.move_up")
121         layout.operator("nla.move_down")
122
123         layout.separator()
124         # TODO: names of these tools for 'tweakmode' need changing?
125         if scene.nla_tweakmode_on:
126             layout.operator("nla.tweakmode_exit", text="Stop Tweaking Strip Actions")
127         else:
128             layout.operator("nla.tweakmode_enter", text="Start Tweaking Strip Actions")
129
130
131 class NLA_MT_add(bpy.types.Menu):
132     bl_label = "Add"
133
134     def draw(self, context):
135         layout = self.layout
136
137         layout.column()
138         layout.operator("nla.actionclip_add")
139         layout.operator("nla.transition_add")
140
141         layout.separator()
142         layout.operator("nla.meta_add")
143         layout.operator("nla.meta_remove")
144
145         layout.separator()
146         layout.operator("nla.tracks_add")
147         layout.operator("nla.tracks_add", text="Add Tracks Above Selected").above_selected = True
148
149
150 class NLA_MT_edit_transform(bpy.types.Menu):
151     bl_label = "Transform"
152
153     def draw(self, context):
154         layout = self.layout
155
156         layout.column()
157         layout.operator("transform.translate", text="Grab/Move")
158         layout.operator("transform.transform", text="Extend").mode = 'TIME_EXTEND'
159         layout.operator("transform.resize", text="Scale")
160
161
162 classes = [
163     NLA_HT_header, # header/menu classes
164     NLA_MT_view,
165     NLA_MT_select,
166     NLA_MT_edit,
167     NLA_MT_add,
168     NLA_MT_edit_transform]
169
170
171 def register():
172     register = bpy.types.register
173     for cls in classes:
174         register(cls)
175
176
177 def unregister():
178     unregister = bpy.types.unregister
179     for cls in classes:
180         unregister(cls)
181
182 if __name__ == "__main__":
183     register()