rna data path names which are more likely to break animations.
[blender-staging.git] / release / scripts / ui / space_info.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 import bpy
21
22
23 class INFO_HT_header(bpy.types.Header):
24     bl_space_type = 'INFO'
25
26     def draw(self, context):
27         layout = self.layout
28
29         wm = context.manager
30         if wm and wm.operators:
31             last_op = wm.operators[-1]
32         else:
33             last_op = None
34         window = context.window
35         scene = context.scene
36         rd = scene.render
37
38         row = layout.row(align=True)
39         row.template_header()
40
41         if context.area.show_menus:
42             sub = row.row(align=True)
43             sub.menu("INFO_MT_file")
44             sub.menu("INFO_MT_add")
45             if rd.use_game_engine:
46                 sub.menu("INFO_MT_game")
47             else:
48                 sub.menu("INFO_MT_render")
49             sub.menu("INFO_MT_help")
50
51         if window.screen.show_fullscreen:
52             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
53             layout.separator()
54         else:
55             layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
56
57         layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
58
59         layout.separator()
60
61         if rd.has_multiple_engines:
62             layout.prop(rd, "engine", text="")
63
64         layout.separator()
65
66         layout.template_running_jobs()
67
68         layout.template_reports_banner()
69
70         layout.label(text=scene.statistics())
71
72         # XXX: this should be right-aligned to the RHS of the region
73         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
74
75
76 class INFO_MT_file(bpy.types.Menu):
77     bl_label = "File"
78
79     def draw(self, context):
80         layout = self.layout
81
82         layout.operator_context = 'EXEC_AREA'
83         layout.operator("wm.read_homefile", text="New", icon='NEW')
84         layout.operator_context = 'INVOKE_AREA'
85         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
86         layout.menu("INFO_MT_file_open_recent")
87         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
88         layout.operator("wm.recover_auto_save", text="Recover Auto Save...")
89
90         layout.separator()
91
92         layout.operator_context = 'INVOKE_AREA'
93         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK').check_existing = False
94         layout.operator_context = 'INVOKE_AREA'
95         layout.operator("wm.save_as_mainfile", text="Save As...")
96         layout.operator_context = 'INVOKE_AREA'
97         layout.operator("wm.save_as_mainfile", text="Save Copy...").copy = True
98
99         layout.separator()
100
101         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
102
103         layout.operator_context = 'EXEC_AREA'
104         layout.operator("wm.read_homefile", text="Load Factory Settings").factory = True
105
106         layout.separator()
107
108         layout.operator_context = 'INVOKE_AREA'
109         layout.operator("wm.link_append", text="Link")
110         props = layout.operator("wm.link_append", text="Append")
111         props.link = False
112         props.instance_groups = False
113
114         layout.separator()
115
116         layout.menu("INFO_MT_file_import")
117         layout.menu("INFO_MT_file_export")
118
119         layout.separator()
120
121         layout.menu("INFO_MT_file_external_data")
122
123         layout.separator()
124
125         layout.operator_context = 'EXEC_AREA'
126         layout.operator("wm.exit_blender", text="Quit", icon='QUIT')
127
128
129 class INFO_MT_file_import(bpy.types.Menu):
130     bl_idname = "INFO_MT_file_import"
131     bl_label = "Import"
132
133     def draw(self, context):
134         if hasattr(bpy.types, "WM_OT_collada_import"):
135             self.layout.operator("wm.collada_import", text="COLLADA (.dae)")
136
137
138 class INFO_MT_file_export(bpy.types.Menu):
139     bl_idname = "INFO_MT_file_export"
140     bl_label = "Export"
141
142     def draw(self, context):
143         if hasattr(bpy.types, "WM_OT_collada_export"):
144             self.layout.operator("wm.collada_export", text="COLLADA (.dae)")
145
146
147 class INFO_MT_file_external_data(bpy.types.Menu):
148     bl_label = "External Data"
149
150     def draw(self, context):
151         layout = self.layout
152
153         layout.operator("file.pack_all", text="Pack into .blend file")
154         layout.operator("file.unpack_all", text="Unpack into Files")
155
156         layout.separator()
157
158         layout.operator("file.make_paths_relative")
159         layout.operator("file.make_paths_absolute")
160         layout.operator("file.report_missing_files")
161         layout.operator("file.find_missing_files")
162
163
164 class INFO_MT_mesh_add(bpy.types.Menu):
165     bl_idname = "INFO_MT_mesh_add"
166     bl_label = "Mesh"
167
168     def draw(self, context):
169         layout = self.layout
170         layout.operator_context = 'INVOKE_REGION_WIN'
171         layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
172         layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
173         layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
174         layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
175         layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
176         layout.operator("mesh.primitive_tube_add", icon='MESH_TUBE', text="Tube")
177         layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
178         layout.separator()
179         layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
180         layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
181
182
183 class INFO_MT_curve_add(bpy.types.Menu):
184     bl_idname = "INFO_MT_curve_add"
185     bl_label = "Curve"
186
187     def draw(self, context):
188         layout = self.layout
189         layout.operator_context = 'INVOKE_REGION_WIN'
190         layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
191         layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
192         layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
193         layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
194         layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
195
196
197 class INFO_MT_surface_add(bpy.types.Menu):
198     bl_idname = "INFO_MT_surface_add"
199     bl_label = "Surface"
200
201     def draw(self, context):
202         layout = self.layout
203         layout.operator_context = 'INVOKE_REGION_WIN'
204         layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
205         layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
206         layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
207         layout.operator("surface.primitive_nurbs_surface_tube_add", icon='SURFACE_NTUBE', text="NURBS Tube")
208         layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
209         layout.operator("surface.primitive_nurbs_surface_donut_add", icon='SURFACE_NDONUT', text="NURBS Torus")
210
211
212 class INFO_MT_armature_add(bpy.types.Menu):
213     bl_idname = "INFO_MT_armature_add"
214     bl_label = "Armature"
215
216     def draw(self, context):
217         layout = self.layout
218         layout.operator_context = 'INVOKE_REGION_WIN'
219         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
220
221
222 class INFO_MT_add(bpy.types.Menu):
223     bl_label = "Add"
224
225     def draw(self, context):
226         layout = self.layout
227
228         layout.operator_context = 'EXEC_SCREEN'
229
230         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
231         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
232
233         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
234         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
235         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
236         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
237         layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
238         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
239         layout.separator()
240
241         layout.operator_context = 'INVOKE_REGION_WIN'
242         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
243         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
244         layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY'
245         layout.separator()
246
247         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
248         layout.operator_context = 'EXEC_SCREEN'
249         layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
250         layout.separator()
251
252         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
253         layout.separator()
254
255         if(len(bpy.data.groups) > 10):
256             layout.operator_context = 'INVOKE_DEFAULT'
257             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
258         else:
259             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
260
261
262 class INFO_MT_game(bpy.types.Menu):
263     bl_label = "Game"
264
265     def draw(self, context):
266         layout = self.layout
267
268         gs = context.scene.game_settings
269
270         layout.operator("view3d.game_start")
271
272         layout.separator()
273
274         layout.prop(gs, "show_debug_properties")
275         layout.prop(gs, "show_framerate_profile")
276         layout.prop(gs, "show_physics_visualization")
277         layout.prop(gs, "use_deprecation_warnings")
278         layout.prop(gs, "use_animation_record")
279         layout.separator()
280         layout.prop(gs, "use_auto_start")
281
282
283 class INFO_MT_render(bpy.types.Menu):
284     bl_label = "Render"
285
286     def draw(self, context):
287         layout = self.layout
288
289         # rd = context.scene.render
290
291         layout.operator("render.render", text="Render Image", icon='RENDER_STILL')
292         layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION').animation = True
293
294         layout.separator()
295
296         layout.operator("render.opengl", text="OpenGL Render Image")
297         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
298
299         layout.separator()
300
301         layout.operator("render.view_show")
302         layout.operator("render.play_rendered_anim")
303
304
305 class INFO_MT_help(bpy.types.Menu):
306     bl_label = "Help"
307
308     def draw(self, context):
309         layout = self.layout
310
311         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
312         layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-250/'
313
314         layout.separator()
315
316         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/'
317         layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop'
318         layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/'
319         layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/'
320         layout.separator()
321         layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse'
322         layout.separator()
323         layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = 'http://www.blender.org/documentation/250PythonDoc/contents.html'
324         layout.operator("help.operator_cheat_sheet")
325         layout.separator()
326         layout.operator("wm.splash")
327
328
329 # Help operators
330
331
332 class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
333     bl_idname = "help.operator_cheat_sheet"
334     bl_label = "Operator Cheat Sheet"
335
336     def execute(self, context):
337         op_strings = []
338         tot = 0
339         for op_module_name in dir(bpy.ops):
340             op_module = getattr(bpy.ops, op_module_name)
341             for op_submodule_name in dir(op_module):
342                 op = getattr(op_module, op_submodule_name)
343                 text = repr(op)
344                 if text.startswith('bpy.ops.'):
345                     op_strings.append(text)
346                     tot += 1
347
348             op_strings.append('')
349
350         textblock = bpy.data.texts.new("OperatorList.txt")
351         textblock.write('# %d Operators\n\n' % tot)
352         textblock.write('\n'.join(op_strings))
353         self.report({'INFO'}, "See OperatorList.txt textblock")
354         return {'FINISHED'}
355
356
357
358 def register():
359     pass
360
361
362 def unregister():
363     pass
364
365 if __name__ == "__main__":
366     register()